Introduction.

This is a worksheet for use with Lecture 9.

You have a videos 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

Why is this useful again? (Slide 5)

Think back to a couple of weeks ago where we build mediation models.

Please complete the following.

Mediation models are related to _____ models

  1. Factor
  2. Path
  3. Logistic
  4. Moderation

My answer:

Go back over the slides from session 6

Back to our hypothetical example (Slide 6)

Please complete the following.

In the session we first used Baron and Kenny's steps approach.

, Aroian and Goodman's test were then covered.

Next we used the '' package to test the mediation via bootstrapping.

The '' package can be used to calculate analyses, such as \(R^2_M*R^2_Y\) and \(\widetilde{R^2_M}\widetilde{R^2_Y}\).

Go back over the slides from session 6 in chronological order. We are looking for one word in each gap.

Lavaan (Slide 8)

We have used 'lavaan' also to model latent factors, which symbols were used to indicate a factor? '' (2 symbols)

Model (Slide 9)

Code along.

What is the estimate of the 'ab path': (3 decimals).

Summary (Slide 11)

True or False.

The conclusion on the size of the mediation effect is the same regardless of using 'lavaan' or 'mediate'.

Direct Model (Slide 14)

Code along and evaluate the model.

The AIC and the BIC for this model are and respectively.

Some further 'dplyr' exercises and useful functions. (Slide 23)

Go back over the slides from Week 1 if you don't recall how to load a dataset.

Exercise (Slide 24)

Try not to click the solution on the following slide but complete all the tasks. Ask your neighbour or tutor for advice.

Make covariance matrix. (Slide 28)

The input for getCov() in this case is a

  1. vector
  2. matrix
  3. data frame
  4. tibble

My answer:

Have a look in the help function and look up getCov()

Question? (Slide 30)

Discuss with your group members. Think back over the previous session.

What is missing in the diagram? (Slide 32)

What is missing from the diagram

  1. errors
  2. variances
  3. latent factors
  4. correlated residuals

My answer:

Look back over slide 31 and compare to the Figure.

Exercise (Slide 36)

Complete the exercise and submit via Blackboard!

Going further.

Session Info.

Thanks to Lisa DeBruine for the webexercises package. Please see general disclaimer.

sessionInfo()
## R version 4.2.1 (2022-06-23)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Big Sur ... 10.16
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] webexercises_1.0.0
## 
## loaded via a namespace (and not attached):
##  [1] digest_0.6.31   R6_2.5.1        jsonlite_1.8.4  evaluate_0.20  
##  [5] cachem_1.0.7    rlang_1.1.0     cli_3.6.1       rstudioapi_0.14
##  [9] jquerylib_0.1.4 bslib_0.4.2     rmarkdown_2.21  tools_4.2.1    
## [13] xfun_0.38       yaml_2.3.7      fastmap_1.1.1   compiler_4.2.1 
## [17] htmltools_0.5.5 knitr_1.42      sass_0.4.5

The end...