Working with R-output (1)
The p-value given by the lm
output is a two-sided p-value by default. In the twin study, it might seem more reasonable to follow along the one-sided scientific hypothesis that the IQ scores of the twins are positively associated. Because the p-value is the probability of the observed data or more extreme, the two-sided test p-value is twice as big as the one-sided result. That is, to get a one-sided p-value from the two-sided output in R, divide the p-value by two.
The linear regression model of Foster
vs. Biological
, model
, is provided in the script.
This exercise is part of the course
Inference for Linear Regression in R
Exercise instructions
- Get the Biological coefficient from the model.
- Tidy the model.
- Filter for the
term
"Biological"
.
- Add a column,
one_sided_p_value
, of the one-sided p-value.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
model <- lm(Foster ~ Biological, data = twins)
# Get the Biological model coefficient
biological_term <- model %>%
# Tidy the model
___ %>%
# Filter for term equal to "Biological"
___
biological_term %>%
# Add a column of one-sided p-values
___(one_sided_p_value = ___)