| variable | description |
|---|---|
| age | Age in years of respondent |
| outdoor_time | Self report estimated number of hours per week spent outdoors |
| social_int | Self report estimated number of social interactions per week (both online and in-person) |
| routine | Binary 1=Yes/0=No response to the question 'Do you follow a daily routine throughout the week?' |
| wellbeing | Warwick-Edinburgh Mental Wellbeing Scale (WEMWBS), a self-report measure of mental health and wellbeing. The scale is scored by summing responses to each item, with items answered on a 1 to 5 Likert scale. The minimum scale score is 14 and the maximum is 70 |
| location | Location of primary residence (City, Suburb, Rural) |
| steps_k | Average weekly number of steps in thousands (as given by activity tracker if available) |
03: Significance tests
This week, you’ll revisit the same model you fit last week, focusing now on manually recreating the significance tests reported in summary(). You’ll also practice writing up the model results using APA-style reporting.
- Open RStudio.
- Create a new .Rmd file for this week’s exercises.
- Save it somewhere you can find it again.
- Give it a clear name (for example,
dapr2_lab03.Rmd). - In the first code chunk, load the packages you’ll need this week (and install them if you don’t have them already):
tidyverse
Research question (RQ): Is there an association between wellbeing and time spent outdoors, when controlling for the effect that social interaction has on wellbeing?
Data dictionary:
From the Edinburgh & Lothians, 100 city/suburb residences and 100 rural residences were chosen at random and contacted to participate in the study. The Warwick-Edinburgh Mental Wellbeing Scale (WEMWBS) was used to measure mental health and wellbeing.
Participants filled out a questionnaire including items concerning: estimated average number of hours spent outdoors each week, estimated average number of social interactions each week (whether on-line or in-person), whether a daily routine is followed (yes/no). For those respondents who had an activity tracker app or smart watch, they were asked to provide their average weekly number of steps.
Recap from last week
Read in the data from https://uoepsy.github.io/data/wellbeing_rural.csv and store it in a variable named mwdata (“mw” stands for “mental wellbeing”).
Use the function lm() to fit the linear model represented by the mathematical model formulation below, and name the result mdl.
\[ \text{wellbeing} = \beta_0 + (\beta_1 \cdot \text{outdoor\_time}) + (\beta_2 \cdot \text{social\_int}) + \epsilon \]
Test significance of \(\beta_1\)
Our RQ is interested in the association between hours spent outdoors and wellbeing, holding social interaction constant. Thus the coefficient we’re interested in testing for this RQ is \(\beta_1\).
We’ll start by defining our null hypothesis H0 and our alternative hypothesis H1.
Write the null and alternative hypotheses for the significance test for \(\beta_1\), using mathematical notation. Also write the hypotheses out in one sentence each, using plain English.
🗂️ See Specifying hypotheses flash card.
Run the code summary(mdl) to produce the model summary.
The summary shows that for the outdoor_time coefficient, which corresponds to \(\beta_1\), the estimated coefficient is 0.19909 and the estimated standard error is 0.05060.
Use these two values to calculate the observed t-statistic for \(\beta_1\).
Does it match the t-statistic presented in the model summary?
🗂️ See Reconstructing model estimates > t value flash card.
This t-statistic must be compared to a t-distribution with degrees of freedom equal to \(n - k - 1\).
- \(n\) = sample size, i.e., number of observations
- \(k\) = number of predictors, i.e., number of \(\beta\) coefficients not including the intercept
Calculate how many degrees of freedom this coefficient’s t-distribution should have.
Assume \(\alpha = .05\) (the standard in Psychology) and a two-tailed test.
Find the critical t-values (that is, the t-values which establish the boundaries for statistical significance) on the t-distribution with the degrees of freedom determined in Q4.
Does the observed t-value for \(\beta_1\) fall beyond these critical values? Can we reject the H0?
🗂️ See Reconstructing model estimates > t value flash card.
Variance explained
All model summaries present two \(R^2\) values. For this model, which one should we pay attention to? Why?
🗂️ See Assessing model fit > R-squared and adjusted R-squared flash card.
How much variance in wellbeing scores does our model explain?
🗂️ See Assessing model fit > R-squared and adjusted R-squared flash card.
Report regression models
Imagine you’re writing a report to describe this analysis. Write one sentence that describes the structure of your model: what’s the outcome? what are the predictors? Try to also include the units/measurement scale of each variable.
There are official APA guidelines on how to report regression coefficient estimates.
- For reporting an unstandardised coefficient, use this template structure (filled in with nonsense values for the sake of illustration): (\(b\) = 0.54, 95% CI [0.32, 0.76], \(p\) = .041).
- For a standardised coefficient, replace \(b\) with \(\beta\).
- For p-values, you should report exact p-values to three decimal places (like \(p\) = .041) unless \(p\) is smaller than .001, in which case you can just write \(p\) < .001.
Based on these guidelines, write a couple sentences which
- interpret the
outdoor_timecoefficient, - include APA-formatted estimates of the relevant statistical quantities, and
- address whether the coefficient is significantly different from zero and what this means for the H0.
(Tip: use confint(mdl) to get each coefficient’s 95% CI.)
🗂️ See the APA Numbers and Statistics Guide.
Bonus conceptual question
You’ll notice that in the model summary, all \(\beta\) coefficients (intercept AND slopes) are associated with a t-value and a p-value. The H0 being tested for all of these parameters is that their estimates are equal to zero.
This H0 makes a lot of sense for the slope coefficients: if a slope is equal to zero, then the line is flat, meaning there’s no association between \(x\) and \(y\).
Does this H0 also make sense for the intercept? If our intercept estimate is significantly different from zero, does that tell us anything interesting?