This is a worksheet for use with Lecture 10.
You have a video of me narrating these slides. Note that there are potentially minor discrepancies between the current set of slides and the one in the video. The slide numbers refer to the current set. I do not cover every single slide but you can code along!
If you answer correctly the colour of the box will change from red dashed to full blue! (Don't worry about bonus questions, they are very much just that: a bonus!)
A famous example of Simpson's Paradox comes from admission data to a University: UC
Use your search skills in scholar google to find this information.
Click the link with 'country' and have a look at the paper.
Read the section on cross-level interactions (p. 416). Complete the following:
The section covers an example with consumption and per capita.
Contrary to the country level data, , a poorer region, consumed more meat on average than Flanders, an affluent region.
Please complete the following:
There were assumptions with OLS regression.
The Durbin-Watson test can be used to test the assumption of .
The graph below illustrates .
Go back over the slides for regression, week 4.
In order to avoid confusion this is now called 'Exam' (data<- stores it elsewhere, but it was still called as the package was loaded).
There were pupils from schools.
True or False.
The fixed estimate of the intercept is the same to the 3rd decimal regardless of using 'lme4' or 'nlme'.
Run the code on the slides.
What is the t-value for the fixed effect? (2 decimals)
Run the code on the slides.
What it the t value for the fixed effect? (3 decimals)
Run the code on the slides. You will require the lmerTest package to print p values.
What it the p value for the fixed effect of school average? (3 decimals)
Use the previous slides, try and complete the questions. Speak to your group members if you run into issues
True or False.
The residuals are normally distributed.
Note that the commands have changed between the video and the slides
This will look different from the video as I have used
print()
now. Run the code from the previous slides.
What is the bootstrapped standard deviation for 'standLRT'? (3 decimals)
What is the bootstrapped mean for 'schavg'? (3 decimals)
What is the bootstrapped maximum for 'schavg'? (3 decimals)
Complete the exercise and submit via Blackboard!
Thanks to Lisa DeBruine for the webex package. Please see general disclaimer.
sessionInfo()
## R version 4.3.2 (2023-10-31)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS Ventura 13.4
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## time zone: Europe/London
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] webexercises_1.1.0
##
## loaded via a namespace (and not attached):
## [1] digest_0.6.35 R6_2.5.1 fastmap_1.1.1 xfun_0.43
## [5] cachem_1.0.8 knitr_1.45 htmltools_0.5.8.1 rmarkdown_2.26
## [9] lifecycle_1.0.4 cli_3.6.2 sass_0.4.9 jquerylib_0.1.4
## [13] compiler_4.3.2 highr_0.10 rstudioapi_0.16.0 tools_4.3.2
## [17] evaluate_0.23 bslib_0.7.0 yaml_2.3.8 jsonlite_1.8.8
## [21] rlang_1.1.3