r:path_analysis:exercise
Differences
This shows you the differences between two versions of the page.
| r:path_analysis:exercise [2025/12/01 01:36] – created hkimscil | r:path_analysis:exercise [2025/12/01 01:39] (current) – hkimscil | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| library(lavaan) | library(lavaan) | ||
| - | gpadata <- read.table(file=' | ||
| - | nlsy <- read.csv(" | ||
| active.f <- read.csv(" | active.f <- read.csv(" | ||
| active <- read.csv(" | active <- read.csv(" | ||
| - | |||
| - | gpa <- read.csv(" | ||
| - | mamm <- read.csv(" | ||
| - | # outcome y: whether a woman is in compliance with mammography screening recommendations (1: in compliance; 0: not in compliance) | ||
| - | # Predictors: | ||
| - | # x1: whether she has received a recommendation for screening from a physician; | ||
| - | # x2: her knowledge about breast cancer and mammography screening; | ||
| - | # x3: her perception of benefit of such a screening; | ||
| - | # x4: her perception of the barriers to being screened. | ||
| - | |||
| - | |||
| - | |||
| - | # National Longitudinal Surveys (NLS) | ||
| - | head(nlsy) | ||
| - | |||
| - | spec.mod <- ' | ||
| - | math ~ b*HE + cp*ME | ||
| - | HE ~ a*ME | ||
| - | ab := a*b | ||
| - | total := a*b + cp | ||
| - | ' | ||
| - | mod.fit< | ||
| - | summary(mod.fit) | ||
| - | |||
| - | spec.mod2 <- ' | ||
| - | math ~ b*HE | ||
| - | HE ~ a*ME | ||
| - | ' | ||
| - | |||
| - | fit.mod2< | ||
| - | summary(fit.mod2) | ||
| head(active.f) | head(active.f) | ||
| Line 56: | Line 23: | ||
| # ls: letter series to measure reasoning ability | # ls: letter series to measure reasoning ability | ||
| # lt: letter set to measure reasoning ability | # lt: letter set to measure reasoning ability | ||
| - | |||
| - | |||
| # ept: everyday problem solving test | # ept: everyday problem solving test | ||
| - | |||
| - | spec.mod.active <- ' | ||
| - | hvltt1 ~ p1*age + edu | ||
| - | ws1 ~ p2*age + edu | ||
| - | ls1 ~ p3*age + edu | ||
| - | lt1 ~ p4*age + edu | ||
| - | ept1 ~ p5*age + p6*edu + p7*hvltt1 + p8*ws1 + p9*ls1 + p10*lt1 | ||
| - | ws1~~ls1 | ||
| - | ws1~~lt1 | ||
| - | ls1~~lt1 | ||
| - | hvltt1~~ls1 | ||
| - | hvltt1~~ws1 | ||
| - | hvltt1~~lt1 | ||
| - | ind1 := p1*p7 | ||
| - | total := p5 + p1*p7 + p2*p8 + p3*p9 + p4*p10 | ||
| - | indirect := p1*p7 + p2*p8 + p3*p9 + p4*p10 | ||
| - | ' | ||
| - | fit.mod.active< | ||
| - | summary(fit.mod.active) | ||
| - | |||
| - | |||
| </ | </ | ||
r/path_analysis/exercise.1764552975.txt.gz · Last modified: by hkimscil
