[R-SIG-Mac] Latent class analysis issue

Ken Beath kjbeath at kagi.com
Fri Mar 21 23:30:52 CET 2008

On 22/03/2008, at 4:18 AM, Byron Ellis wrote:

> R-help would probably be a better place for answers to your question
> (this isn't a Mac specific problem), but at a guess the number of
> variables you've specified isn't the same as the number in your
> example. Though, I've never used e1071's LCA function (didn't even
> know they existed until just now) so I'm not positive.

Agreed this would be better in r-help, but we've got this far, so may  
as well continue.

The lca function isn't particularly good. It is a bit specific about  
data, it requires a matrix, which is probably what is happening here.  
There are also some other failings, such as not allowing for the  
models to be fitted for a selection of random starting values, so is  
likely to get the wrong answer when fitting more than 2 or 3 classes.  
It also requires an observation for every subject rather than  
specifying frequencies. Yes, I should send my comments to the  

A better package is poLCA, but also doesn't allow frequencies to be  
specified. I would set the nrep parameter to at least 10, but 20 is  
better. Has a nice user manual.

I have a package in submission randomLCA which is mainly for LC  
incorporating random effects but fits LC as well. For the moment this  
can be downloaded at http://www.kjbeath.com.au/randomlca/ and  
installed as a Local Source Package. Comments welcome.


> On Fri, Mar 21, 2008 at 10:00 AM, David Kaplan
> <dkaplan at education.wisc.edu> wrote:
>> Hi all,
>> I'm running the LCA procedure within the E1071 package.  I'm  
>> receiving
>> the following message that I don't understand
>>> lcaread <- read.csv("~/Documents/Teaching/EP 773/EP 773 Examples/LCA
>> Example/lca.reading.csv", header=TRUE)
>>> attach(lcaread)
>>> readclass <- lca(lcaread, 3)
>> Error in pas[j, ] <- drop(exp(rep(1, nvar) %*% log(mp))) :
>>  number of items to replace is not a multiple of replacement length
>>> print(readclass)
>> Error in print(readclass) : object "readclass" not found
>>> summary(readclass)
>> Error in summary(readclass) : object "readclass" not found
>> Thanks in advance,
>> David
>> --
>> ===============================================================
>> David Kaplan, Ph.D.
>> Professor
>> Department of Educational Psychology
>> University of Wisconsin - Madison
>> Educational Sciences, Room, 1061
>> 1025 W. Johnson Street
>> Madison, WI 53706
>> email: dkaplan at education dot wisc dot edu
>> homepage:
>> http://www.education.wisc.edu/edpsych/facstaff/kaplan/kaplan.htm
>> Phone: 608-262-0836
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> -- 
> Byron Ellis (byron.ellis at gmail.com)
> "Oook" -- The Librarian
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

More information about the R-SIG-Mac mailing list