以下のエントリではStataで行ったが、今回はRのlavaanパッケージで行う。
データ
こちらのnes3wave.dtaを使用する。
データ読み込み
library(rio)
nes3wave <-import("nes3wave.dta")
今回のパス図を先に表示しておこう。

library(lavaan) AR_model<- ' pid2002 ~ pid2000 pid2004 ~ pid2002 '
実行・結果表示
推定法はデフォルトの最尤法を用いている。
fit_AR<- sem(AR_model, data=nes3wave) summary(fit_AR, standardized=TRUE)
結果
Regressions:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
pid2002 ~
pid2000 0.878 0.017 50.608 0.000 0.878 0.872
pid2004 ~
pid2002 0.941 0.018 52.954 0.000 0.941 0.881
Variances:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
.pid2002 1.141 0.057 20.125 0.000 1.141 0.240
.pid2004 1.215 0.060 20.125 0.000 1.215 0.224
パス図
library(semPlot)
semPaths(fit_AR, layout = "tree", shapeLat="ellipse", whatLabels = "est",
nDigits=3, shapeMan="square", sizeMan =6, sizeMan2= 10,
style = "lisrel",rotation = 2,residScale=12, curve=2.5,
edge.color="black", edge.label.cex=1)