EXERCISE 01
Part (a)
We have 10 variance/covariance data points.
4*(4+1)/2
## [1] 10
Part (b)
We should fix the pathway from Healthcare Plan to Benefits to 1. Alternatively, we could have set the pathway from Healthcare Plan to Anonymity to 1, but I chose the other one. Only ONE of these is set.
Part (c)
There are 12 parameters/paths in total. One of those is already fixed, so we have 11 left to solve. Unfortunately, 11 is greater than 10, so we need to fix more paths. To get our parameters under 10, we will set the path from E1 to Benefits to 1 as well as the path from E2 to Anonymity to 1. Now we only have 9 parameters :)
Part (d)
Ignore how the arrow behind the 1 from healthcare plan to benefits looks weird. It should just be an arrow from healthcare plan to benefits with the 1 directly on top of it, it kept acting funky.
library(knitr)
include_graphics("C:/Users/Sarah Chock/OneDrive - University of St. Thomas/Senior Year/STAT 360 Comp Stat and Data Analysis/Structural Equation Models/PS14 Q1.png")

EXERCISE 02
Part (a)
beta <- matrix(0, nrow = 6, ncol = 6)
rownames(beta)<- c("Threats", "Assaults", "Fights", "Depression", "Anxiety", "Psychological Distress")
colnames(beta)<- c("Threats", "Assaults", "Fights", "Depression", "Anxiety", "Psychological Distress")
beta["Depression","Psychological Distress"] = 1
beta["Anxiety","Psychological Distress"] = .3
beta
## Threats Assaults Fights Depression Anxiety
## Threats 0 0 0 0 0
## Assaults 0 0 0 0 0
## Fights 0 0 0 0 0
## Depression 0 0 0 0 0
## Anxiety 0 0 0 0 0
## Psychological Distress 0 0 0 0 0
## Psychological Distress
## Threats 0.0
## Assaults 0.0
## Fights 0.0
## Depression 1.0
## Anxiety 0.3
## Psychological Distress 0.0
Part (b)
identity <- diag(c(1,1,1,1,1,1))
identity
## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 0 0 0 0 0
## [2,] 0 1 0 0 0 0
## [3,] 0 0 1 0 0 0
## [4,] 0 0 0 1 0 0
## [5,] 0 0 0 0 1 0
## [6,] 0 0 0 0 0 1
Part (c)
gamma <- matrix(0, nrow = 6, ncol = 8)
rownames(gamma)<- c("Threats", "Assaults", "Fights", "Depression", "Anxiety", "Pyschological Distress")
colnames(gamma)<- c("Housing", "Violence", "E1", "E2", "E3", "E4", "E5", "D1")
gamma[6,1] = .7
gamma[6,2] = .7
gamma[6,8] = 1
gamma[5,7] = 1
gamma[4,6] = 1
gamma[3,2] = .7
gamma[3,5] = 1
gamma[2,2] = .7
gamma[2,4] = 1
gamma[1,2] = 1
gamma[1,3] = 1
gamma
## Housing Violence E1 E2 E3 E4 E5 D1
## Threats 0.0 1.0 1 0 0 0 0 0
## Assaults 0.0 0.7 0 1 0 0 0 0
## Fights 0.0 0.7 0 0 1 0 0 0
## Depression 0.0 0.0 0 0 0 1 0 0
## Anxiety 0.0 0.0 0 0 0 0 1 0
## Pyschological Distress 0.7 0.7 0 0 0 0 0 1
Part (d)
phi <- diag(rep(.5,8))
rownames(phi)<- c("Housing", "Violence", "E1", "E2", "E3", "E4", "E5", "D1")
colnames(phi)<- c("Housing", "Violence", "E1", "E2", "E3", "E4", "E5", "D1")
phi
## Housing Violence E1 E2 E3 E4 E5 D1
## Housing 0.5 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## Violence 0.0 0.5 0.0 0.0 0.0 0.0 0.0 0.0
## E1 0.0 0.0 0.5 0.0 0.0 0.0 0.0 0.0
## E2 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0
## E3 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0
## E4 0.0 0.0 0.0 0.0 0.0 0.5 0.0 0.0
## E5 0.0 0.0 0.0 0.0 0.0 0.0 0.5 0.0
## D1 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.5
Part (e)
Gy <- matrix(0, nrow = 5, ncol = 6)
rownames(Gy)<- c("Threats", "Assaults", "Fights", "Depression", "Anxiety")
colnames(Gy)<- c("Threats", "Assaults", "Fights", "Depression", "Anxiety", "Psychological Distress")
Gy[1,1] = 1
Gy[2,2] = 1
Gy[3,3] = 1
Gy[4,4] = 1
Gy[5,5] = 1
Gy
## Threats Assaults Fights Depression Anxiety Psychological Distress
## Threats 1 0 0 0 0 0
## Assaults 0 1 0 0 0 0
## Fights 0 0 1 0 0 0
## Depression 0 0 0 1 0 0
## Anxiety 0 0 0 0 1 0
Part (f)
Gx <- matrix(0, nrow = 1, ncol = 8)
rownames(Gx)<- c("Housing")
colnames(Gx)<- c("Housing", "Violence", "E1", "E2", "E3", "E4", "E5", "D1")
Gx[1,1] = 1
Gx
## Housing Violence E1 E2 E3 E4 E5 D1
## Housing 1 0 0 0 0 0 0 0
Part (g)
library(cats)
here_kitty()

## meow