Attachment | Size |
---|---|
polychoricFunction.R [6] | 4.05 KB |
So I put together this function to estimate polychoric correlations by ML. It may improve on the polychor() by i) accepting a dataframe with more than two variables; ii) avoiding the threshold-estimates-in-the-wrong-order problem (see http://r.789695.n4.nabble.com/polychor-error-td806416.html).
Question is, how should I dispose of this function? Obviously it needs a bit more tidying up - error checking on input, testing, documentation etc. but it could be quite handy. Comments welcome.
> polychoricMatrix(data[1:2])
Running model
$polychorics
t1neur1 t1mddd4l
t1neur1 1.0000000 0.2766488
t1mddd4l 0.2766488 1.0000000
$thresholds
t1neur1 t1mddd4l
Threshold1 -1.90078018 0.5352623
Threshold2 -0.60288738 0.5352623
Threshold3 -0.05787172 0.5352623
Threshold4 0.35325948 0.5352623
Threshold5 0.76300674 0.5352623
Threshold6 0.97337736 0.5352623
Threshold7 1.25752996 0.5352623
Threshold8 1.52144325 0.5352623
Threshold9 1.63884649 0.5352623
Threshold10 1.85627069 0.5352623
Threshold11 2.08894746 0.5352623
Threshold12 2.41675886 0.5352623
$polychoricStandardErrors
[,1] [,2]
[1,] NA 0.06604162
[2,] 0.06604162 NA
$Minus2LogLikelihood
[1] 2015.439