Skip to content

Instantly share code, notes, and snippets.

@masaha03
Created May 4, 2012 18:41
Show Gist options
  • Save masaha03/2596854 to your computer and use it in GitHub Desktop.
Save masaha03/2596854 to your computer and use it in GitHub Desktop.
library(sem)
cor.1 <- readMoments(diag=FALSE,
names=c("年齢", "個人年収", "教育年数", "職業威信"))
0.12107847
-0.28075478 0.2329769
-0.04963399 0.3954726 0.2921118
# 従来の記法
model.a1 <- specifyModel()
個人年収 <- 年齢, a1, NA
個人年収 <- 教育年数, a2, NA
個人年収 <- 職業威信, a3, NA
個人年収 <-> 個人年収, e1, NA
# LISREL風の記法
model.a2 <- specifyEquations()
個人年収 = a1*年齢 + a2*教育年数 + a3*職業威信
V(個人年収) = e1
# 上記2つは全く同じモデル
print(model.a1)
print(model.a2)
# sem.a <- sem(model.a1, cor.1, N=685,
# fixed.x=c("年齢", "教育年数", "職業威信"))
sem.a <- sem(model.a2, cor.1, N=685,
fixed.x=c("年齢", "教育年数", "職業威信"))
summary(sem.a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment