Errors in script twinAceOrd.R
Attachment | Size |
---|---|
twinAceOrd.R.txt | 7.36 KB |
I am trying to learn how to fit a univariate ACE model when the variable of interest is ordinal. For this I've started with the script called Univariate Twin Ordinal-Matrix/twinAceOrd.R that I found under the TC 2012 - OpenMx website. When I run the code i get the following four error messages:
1st,
> # Generate Descriptive Statistics
> #colMeans(mzDataOrd,na.rm=TRUE)
> #colMeans(dzDataOrd,na.rm=TRUE)
> cov(mzDataOrd,use="complete")
Error: is.numeric(x) || is.logical(x) is not TRUE
> cov(dzDataOrd,use="complete")
Error: is.numeric(x) || is.logical(x) is not TRUE
2nd,
> ACEpathMatrices <- c("a","c",path"e","iSD","iSD %*% a","iSD %*% c","iSD %*% e")
Error: unexpected string constant in "ACEpathMatrices <- c("a","c",path"e""
3rd,
> ACEpathLabels <- c("path_a","path_c","path_e","isd","spath_a","spath_c","spath_e")
> formatOutputMatrices(AceFit,ACEpathMatrices,ACEpathLabels,Vars,4)
[1] "Matrix ACE.a"
path_a1
bmi 0.8646
[1] "Matrix ACE.c"
path_c1
bmi 0.0000
[1] "Matrix ACE.e"
path_e1
bmi -0.5025
[1] "Matrix ACE.iSD"
Error in print(formatOutputMatrix(evalQuote(matricesList[[k]], fittedModel), :
error in evaluating the argument 'x' in selecting a method for function 'print': Error in eval(expr, envir, enclos) : object 'ACE.iSD' not found
4th,
> round(rbind(AceFit@output$estimate,AeFit@output$estimate,CeFit@output$estimate,eFit@output$estimate),4)
a11 c11 e11 t1Z t2Z t3Z t4Z
[1,] 0.8646 0.0000 -0.5025 -1.2212 0.8049 0.7102 0.5686
[2,] 0.8646 -0.5025 -1.2212 0.8049 0.7102 0.5687 0.8646
[3,] -0.7677 -0.6408 -1.2177 0.8078 0.7090 0.5719 -0.7677
[4,] -0.7677 -0.6408 -1.2177 0.8078 0.7090 0.5719 -0.7677
Warning message:
In rbind(AceFit@output$estimate, AeFit@output$estimate, CeFit@output$estimate, :
number of columns of result is not a multiple of vector length (arg 2)
I managed to fix the problem and get rid of the 2nd error message, but haven't really understood what the other errors are about.
I would be grateful for any kind of help. I am attching the script that I am using, where I haven't saved any changes.
/Natalja
get a new copy?
cov(mzDataOrd,use="complete")
Error: is.numeric(x) || is.logical(x) is not TRUE
There are some columns in mzDataOrd which are neither numeric not logical and which cov therefore can't handle - probably strings. use str(mxDataOrd) to see what type each variable is.
ACEpathMatrices <- c("a","c",path"e","iSD","iSD %*% a","iSD %*% c","iSD %*% e")
Error: unexpected string constant in "ACEpathMatrices <- c("a","c",path"e""
this is supposed to be a collection of strings (things in quotes)... look at , path"e"
Probably should say
ACEpathMatrices <- c("a", "c", "e", "iSD", "iSD %*% a", "iSD %*% c", "iSD %*% e")
i.e., someone pasted in "path" by accident?
3rd,
> ACEpathLabels <- c("path_a","path_c","path_e","isd","spath_a","spath_c","spath_e")
> formatOutputMatrices(AceFit,ACEpathMatrices,ACEpathLabels,Vars,4)
[1] "Matrix ACE.iSD"
... object 'ACE.iSD' not found
There is nothing in the model called ACE.iSD... check what its name should be.
4th,
round(rbind(
AceFit@output$estimate,
AeFit@output$estimate,
CeFit@output$estimate,
eFit@output$estimate), 4)
Warning message:
In rbind(AceFit@output$estimate, AeFit@output$estimate, CeFit@output$estimate, :
number of columns of result is not a multiple of vector length (arg 2)
Look at each of those parts by themselves. they should all be the same length...
This script feels like someone has edited it badly at some point? Perhaps get an original copy?
Log in or register to post comments
In reply to get a new copy? by tbates
use polycor::hetcor() for polychoric covariance
install.packages("polycor")
library("polycor")
hetcor(mzDataOrd)
Log in or register to post comments