poLCA problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

poLCA problem

Scott Colwell
Good morning everyone,

I am running into errors with poLCA as follows:

Error in round(mf) : non-numeric argument to mathematical function.

Here is what I have. Both variables are coded as 1, 2, 3

df <- as.data.frame(data)

items <- c("x1", "x2")  <- there are more variables but shortened for this
purpose

df2 <- df[items]

i <- cbind(x1, x2)~1

poLCA (i, df2, nclass=2, maxiter=100, nrep=10, verbose =TRUE)

It is after the poLCA that I get the error. Any thoughts on what is causing
this?

Thanks,

Scott

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: poLCA problem

Rasmus Liland-3
Dear Scott,

I think the issue here is you need to
form a correct formula poLCA::poLCA can
accept.

The help page ?poLCA::election has this
example:

        # Latent class models with one (loglinear independence) to three classes
        data(election)
        f <- cbind(MORALG,CARESG,KNOWG,LEADG,DISHONG,INTELG,
                   MORALB,CARESB,KNOWB,LEADB,DISHONB,INTELB)~1
        nes1 <- poLCA(f,election,nclass=1)  # log-likelihood: -18647.31
        nes2 <- poLCA(f,election,nclass=2)  # log-likelihood: -17344.92
        nes3 <- poLCA(f,election,nclass=3)  # log-likelihood: -16714.66

Perhaps if you export df first using
data() and try to use cbind(x1, x2)~1 as
the formula ...

        data(df2)
        f <- cbind(x1, x2)~1
        poLCA(f, df2, nclass=2, maxiter=100, nrep=10, verbose =TRUE)

Best,
Rasmus

______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

signature.asc (849 bytes) Download Attachment