mediation_analysis
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mediation_analysis [2024/10/31 08:52] – [Poking the above] hkimscil | mediation_analysis [2024/11/03 22:37] (current) – [What about this output] hkimscil | ||
|---|---|---|---|
| Line 861: | Line 861: | ||
| 그 외의 지수는? | 그 외의 지수는? | ||
| 어떤 모델이 지금의 현상을 가장 잘 설명하는다고 판단하는가? | 어떤 모델이 지금의 현상을 가장 잘 설명하는다고 판단하는가? | ||
| + | |||
| + | * Model fit | ||
| + | * Chi-square Test: p-value less than p-critical value (.05 for example) indicates that model does not fit well enough. p-value more than critical value means the model fits the data relatively well. The test is sensitive to the sample size and normality of the data. | ||
| + | * CFI (Comparative Fit Index): greater than .90 indicates good fit to the data. It is less sensitive to the sample size and normality of the data than chi-square test. | ||
| + | * TLI (Tucker-Lewis Index): greater than .95 (sometimes .90) indicates good fit. It is less sensitive to the sample size. | ||
| + | * RMSEA (Root Mean Square Error of Approximation): | ||
| + | * SRMR (Standard Root Mean square Residual): less than or equal to .08 indicates good fit to the data. | ||
| + | |||
| + | | $\chi^2$ | ||
| + | | $p \ge .05$ | $p \ge .90$ | $p \ge .95$ | $p \le .08$ | $p \le .08$ | | ||
| + | |||
| + | Then what is SEM (Structural Equation Modeling) | ||
| + | * Relationships within and among variables and constructs | ||
| + | |||
| Line 973: | Line 987: | ||
| </ | </ | ||
| + | ====== e.g. with a categorical variable ====== | ||
| + | < | ||
| + | # regression with job placement data | ||
| + | |||
| + | df <- read.csv(" | ||
| + | head(df) | ||
| + | |||
| + | df<- within(df, { | ||
| + | norms.cat <- NA # need to initialize variable | ||
| + | norms.cat[norms < tmp[2]] <- " | ||
| + | norms.cat[norms >= tmp[2] & norms < tmp[3]] <- " | ||
| + | norms.cat[norms >= tmp[3]] <- " | ||
| + | } ) | ||
| + | head(df) | ||
| + | |||
| + | med.m.01 <- ' | ||
| + | # mediator | ||
| + | intention ~ a*attitude | ||
| + | behavior ~ b*intention | ||
| + | | ||
| + | # direct effect c | ||
| + | behavior ~ c*attitude | ||
| + | | ||
| + | # indirect effect | ||
| + | ab := a*b | ||
| + | | ||
| + | # total effect | ||
| + | tot := c + ab | ||
| + | ' | ||
| + | fit <- sem(med.m.01, | ||
| + | | ||
| + | se = " | ||
| + | summary(fit, | ||
| + | standardized = T, | ||
| + | ci = T) | ||
| + | |||
| + | ### | ||
| + | mod.m.02 <- ' | ||
| + | # mediator | ||
| + | intention ~ c(ag1, | ||
| + | behavior ~ c(bg1, | ||
| + | | ||
| + | # direct effect | ||
| + | behavior ~ c(cg1, | ||
| + | | ||
| + | # indirect effect | ||
| + | abg1 := ag1*bg1 # for group 1 | ||
| + | abg2 := ag2*bg2 | ||
| + | abg3 := ag3*bg3 | ||
| + | |||
| + | # tot effect | ||
| + | totalg1 := cg1 + (ag1*bg1) | ||
| + | totalg2 := cg2 + (ag2*bg2) | ||
| + | totalg3 := cg3 + (ag3*bg3) | ||
| + | ' | ||
| + | |||
| + | fit.by.norms.cat <- sem(mod.m.02, | ||
| + | group = " | ||
| + | se = " | ||
| + | meanstructure = T) | ||
| + | summary(fit.by.norms.cat, | ||
| + | fit.measures = T, | ||
| + | standardized = T, | ||
| + | ci = T) | ||
| + | |||
| + | all.constraints <- ' | ||
| + | ag1 == ag2 == ag3 | ||
| + | bg1 == bg2 == bg3 | ||
| + | cg1 == cg2 == cg3 | ||
| + | ' | ||
| + | |||
| + | lavTestWald(fit.by.norms.cat, | ||
| + | constraints = all.constraints) | ||
| + | |||
| + | lavTestWald(fit.by.norms.cat, | ||
| + | constraints = " | ||
| + | lavTestWald(fit.by.norms.cat, | ||
| + | constraints = " | ||
| + | lavTestWald(fit.by.norms.cat, | ||
| + | constraints = " | ||
| + | |||
| + | # or | ||
| + | full.mod.mediation <- ' | ||
| + | # mediator | ||
| + | intention ~ a*attitude | ||
| + | behavior ~ b*intention + w*norms.cat | ||
| + | | ||
| + | # define moderator | ||
| + | Z := w*b | ||
| + | | ||
| + | # direct effect | ||
| + | behavior ~ c*attitude | ||
| + | | ||
| + | # indirect effect | ||
| + | ab := a*b | ||
| + | |||
| + | # tot effect | ||
| + | total := c + (a*b) | ||
| + | ' | ||
| + | |||
| + | full.mod <- sem (full.mod.mediation, | ||
| + | se = " | ||
| + | | ||
| + | summary(full.mod, | ||
| + | stand = T, ci = T) | ||
| + | |||
| + | </ | ||
| + | |||
| + | |||
| ====== e.gs ====== | ====== e.gs ====== | ||
| < | < | ||
mediation_analysis.1730332362.txt.gz · Last modified: by hkimscil
