我正在尝试学习潜在成分分析,同时也在学习 R。我正在使用poLCA 包,并且在访问属性时遇到了一些麻烦。我可以很好地运行示例代码:
ds = read.csv("http://www.math.smith.edu/r/data/help.csv")
ds = within(ds, (cesdcut = ifelse(cesd>20, 1, 0)))
library(poLCA)
res2 = poLCA(cbind(homeless=homeless+1,
cesdcut=cesdcut+1, satreat=satreat+1,
linkstatus=linkstatus+1) ~ 1,
maxiter=50000, nclass=3,
nrep=10, data=ds)
但为了使它更有用,我想访问由 poLCA 类创建的对象中的属性,如下所示:
attr(res2, 'Nobs')
attr(res2, 'maxiter')
但它们都显示为“空”。我希望 Nobs 为 453(由函数确定),maxiter 为 50000(由我的输入值决定)。
我确定我只是天真,但我可以使用任何可用的帮助。非常感谢!