[R] sem with categorical data

John Fox jfox at mcmaster.ca
Wed May 20 20:03:08 CEST 2009


Dear Frank,

Did you take a look at the data you generated? The contingency tables
are extremely sparse. Try, e.g., with(dat, table(q1, q2)). (I assume,
BTW, that you're using the cut2() function in the Hmisc package.)

Beyond that, I'm not sure what the point is of your example. You're
generating three independent lognormal random variables while the model
assumed by polychoric correlation is of multinormal random variables;
of course, these *could* be independent, but generally would not.

I hope this helps,
 John

On Wed, 20 May 2009 12:55:49 -0400
 "Frank Lawrence" <frl2 at psu.edu> wrote:
> I am trying to run a confirmatory factor analysis using the SEM
> package.  My
> data are ordinal.  I have read
> http://socserv.mcmaster.ca/jfox/Misc/sem/SEM-paper.pdf.
> When I apply the hetcor function, I receive the following error:
> Error in checkmvArgs(lower = lower, upper = upper, mean = mean, corr
> = corr,
> : 
>   at least one element of 'lower' is larger than 'upper'
> 
> Example:
> set.seed(781)
> q1 <- cut2(x = rlnorm(n = 1e2, m = 2), cuts = seq(1,6))
> q2 <- cut2(x = rlnorm(n = 1e2, m = 0), cuts = seq(1,6))
> q3 <- cut2(x = rlnorm(n = 1e2, m = 1), cuts = seq(1,6))
> dat <- data.frame(q1,q2,q3)
> hetcor(data = dat, ML = T, pd = T, use = 'p')
> 
> Any help in understanding and correcting the error would be
> appreciated.
> 
> unlist(R.Version())
>                       platform                           arch 
>              "i386-pc-mingw32"                         "i386" 
>                             os                         system 
>                      "mingw32"                "i386, mingw32" 
>                         status                          major 
>                             ""                            "2" 
>                          minor                           year 
>                          "9.0"                         "2009" 
>                          month                            day 
>                           "04"                           "17" 
>                        svn rev                       language 
>                        "48333"                            "R" 
>                 version.string 
> "R version 2.9.0 (2009-04-17)"
> 
> Respectfully,
> 
> Frank Lawrence
> 
> 
> 
> 

--------------------------------
John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/



More information about the R-help mailing list