#Loehlin problem 2.5
obs.var2.5 = c('Ach1', 'Ach2', 'Amb1', 'Amb2', 'Amb3')
R.prob2.5 = matrix(c(
1.00 , .60 , .30, .20, .20,
.60, 1.00, .20, .30, .10,
.30, .20, 1.00, .70, .60 ,
.20, .30, .70, 1.00, .50,
.20, .10, .60, .50, 1.00), ncol=5,byrow=TRUE)
#correlated factors structure (ambition <-> Achievement)
model2.5=matrix(c(
'Ambit -> Amb1', 'a', NA,
'Ambit -> Amb2' , 'b', NA,
'Ambit -> Amb3' , 'c', NA,
'Achieve -> Ach1', 'd', NA,
'Achieve -> Ach2', 'e', NA,
'Ambit <-> Achieve', 'f', NA,
'Amb1 <-> Amb1' , 'u', NA,
'Amb2 <-> Amb2' , 'v', NA,
'Amb3 <-> Amb3' , 'w', NA,
'Ach1 <-> Ach1' , 'x', NA,
'Ach2 <-> Ach2' , 'y', NA,
'Achieve <-> Achieve', NA, 1,
'Ambit <-> Ambit', NA, 1),
ncol=3, byrow=TRUE)
sem2.5= sem(model2.5,R.prob2.5,60, obs.var2.5)
summary(sem2.5,digits=3)
**** 来自http://personality-project.org/r/r.sem.html
我试图通过简单地将代码原样复制/粘贴到jupyter笔记本中并逐块运行代码来简单地重新创建结果。
在我尝试重新创建模型之前,代码都运行良好:
即:sem2.5= sem(model2.5,R.prob2.5,60, obs.var2.5)
我不断收到这个错误:
Error in data[, obs.variables]: incorrect number of dimensions
Traceback:
1. sem(model2.5, R.prob2.5, 60, obs.var2.5)
2. sem.semmod(model2.5, R.prob2.5, 60, obs.var2.5)
------------------------------------------------------------
我到底在这里想念什么?在对包依赖项和版本控制进行了很多讨论之后,我觉得我只是在这里睁一只眼闭一只眼,答案就在我眼前。
我需要做什么才能重新创建已发布的此模型?