Introduction.

This is a worksheet for use with Lecture 5.

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! (Don't worry about bonus questions, they are very much just that: a bonus!)

Slides

Types of errors I,II,III (Slide 6)

Are the following statements true or false?

Type I errors is the default type in SPSS.

Type III errors are not dependent on the order in which effects were included in the model.

If the design is balanced, then the type of errors does not matter.

Go back over the slides from week 3 where we covered ANOVA or you can have a read here

Interaction effects? (Slide 10)

What exactly is an interaction/moderation effect?

  1. When a third variable (X1) and an independent variable (X2) affect the dependent variable (Y) simultaneously

  2. When a third variable (X1) reduces the effect of an independent variable (X2) on the dependent variable (Y)

  3. When a third variable (X1) affects the relation between an independent variable (X2) and the dependent variable (Y)

  4. When a third variable (X1) affects an independent variable (X2) but not the dependent variable (Y)

My answer:

What is a product-term the result of?

  1. Multiplying two variables
  2. Taking the ratio of two variables
  3. Subtracting one variable from another
  4. Adding two variables

My answer:

Talk to your neighbour (Slide 14)

This will be virtual, rather than in person if there is a pandemic :).

Assumption checks (Slide 17)

Remember that you can use the help function.

In addition to the assumption checks, see if you can answer the below.

How many received the Orange Juice supplement?

My answer:

What is the median for length ('len') (1 decimal)

My answer:

The ToothGrowth are part of datasets.

You can also check the solution, for some further information. Also check back over the slides of week 3.

Results (Slide 22)

What would be the degrees of freedom you would need to report for the interaction effect?

and

You can skip some slides ahead. The order matters here.

Alternative route (Slide 24)

Is the significance of the interaction effect the same as with the Anova() command? (True or False)

Compare to slide 22.

Plot to show the interaction? (Slide 31)

Bonus

Which command would I use to add p values to the plot.

Have you added ()?

Look in the manual or here

Bootstrap! (Slide 33)

The set.seed() function ensures that the results are replicable. (True or False)

Continuous variables and interactions (Slide 40)

What is the median monthly salary? (2 decimals)

What is the minimum and maximum for years since PhD? (no decimals)

minimum: maximum:

Try it yourself (Slide 45)

Follow the information on the previous slides.

What is the median for years of service?

Model (Slide 48)

Note that this is different from the screencast. The data are now in the 'psychTools' package rather than the 'psych' package.

Simple Slopes method (Slide 50)

The slope of 'EpiNeur' is significantly smaller at larger values of 'stateanx'. (True or False)

Problems with heteroscedasticity? (Slide 53)

What is the t-value associated with the slope of epiNeur when stateanx = 51.33 (+ 1 SD)? (2 decimals)

You will have to run the code from the slide.

My answer:

RM-ANOVA: Talk to your neighbour. (Slide 55)

Talk to your virtual classmates. Did you conduct a RM-ANOVA?

Work through the output. (Slide 58)

This output shows evidence for a three-way interaction effect. (True or False)

Sphericity test (Slide 59)

The assumption of sphericity is upheld.

Exercise (Slide 61)

Complete the exercise and submit via Blackboard!

Going further.

Session Info.

Thanks to Lisa DeBruine for the webex package. Some of the multiple choice questions are from Applied Statistics Using Stata, First Edition, by Mehmet Mehmetoglu and Tor Georg Jakobsen. 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] dplyr_1.1.3        car_3.1-2          carData_3.0-5      skimr_2.1.5       
## [5] webexercises_1.1.0
## 
## loaded via a namespace (and not attached):
##  [1] jsonlite_1.8.7    compiler_4.3.2    tidyselect_1.2.0  stringr_1.5.0    
##  [5] tidyr_1.3.0       jquerylib_0.1.4   yaml_2.3.7        fastmap_1.1.1    
##  [9] R6_2.5.1          generics_0.1.3    knitr_1.45        tibble_3.2.1     
## [13] bslib_0.5.1       pillar_1.9.0      rlang_1.1.1       utf8_1.2.4       
## [17] cachem_1.0.8      stringi_1.7.12    repr_1.1.6        xfun_0.41        
## [21] sass_0.4.7        cli_3.6.1         withr_2.5.2       magrittr_2.0.3   
## [25] digest_0.6.33     rstudioapi_0.15.0 base64enc_0.1-3   lifecycle_1.0.3  
## [29] vctrs_0.6.4       evaluate_0.23     glue_1.6.2        abind_1.4-5      
## [33] fansi_1.0.5       rmarkdown_2.25    purrr_1.0.2       tools_4.3.2      
## [37] pkgconfig_2.0.3   htmltools_0.5.7

The end...