[R] poLCA package inquiry
KDT
dkadengye at gmail.com
Tue May 29 16:13:18 CEST 2012
Dear R-users!
I am using the poLCA package to find latent classes in a dataset with binary
outcomes. Several hundreds of persons can engage hundreds of items. Assume
100 items being engaged by 500 persons, the resulting dataframe is as shown
below (5 persons).
item1 item2 item3 item4 item5 . . . . . . . item97 item98 item99
item100
1 0 1 0 1 . . . . . . .
1 1 0 1
1 0 1 0 0 . . . . . . .
1 0 0 1
0 1 0 0 0 . . . . . . .
0 1 1 0
1 0 1 0 1 . . . . . . .
1 1 0 1
0 0 1 1 1 . . . . . . .
0 0 0 1
If the number of items (columns) are less than 63, everything works well.
But for items (columns) is above 63, I get an Error message saying "*Error
in model.matrix.default(formula, mframe) : model frame and formula mismatch
in model.matrix()*" . I can not figure out why this happens. Could someone
explain me why this happens or how to overcome it?
Assume the dataframe is called DATA, the macro I am arunning is as follows:
DATA.int=DATA+1 # poLCA can only analyze 1,2,...
f<-as.formula(paste("cbind(", paste(colnames(DATA.int), collapse = ","),
")~1")) #all items are dependent variables
fit<-list() #collect fits
Kmax=5 #maximum nr of classes
bic=rep(0,Kmax) #vector of BIC values
ll=rep(0,Kmax) #vector of loglikelihood values
for (j in 1:Kmax){ #fits for #classes=1,2,...,Kmax
cat(j,"\n") #print current analysis number
fit[[j]]<-poLCA(f,DATA.int,nclass=j,nrep=20,verbose=FALSE) #20 random
starts
bic[j]<-fit[[j]]$bic #collect BICs
ll[j] <- fit[[j]]$llik #collect logliks
}
Thanks in Advance
Kadengye Trevor
--
View this message in context: http://r.789695.n4.nabble.com/poLCA-package-inquiry-tp4631698.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list