[R] multilevel binary and ordered regression models
Xu Jun
junxu.r at gmail.com
Sun Jun 9 16:44:19 CEST 2013
Rune,
Thanks a lot for pointing me to your ordinal package. It is wonderful,
and I tried a random intercept model and it worked well except that
probably there is something wrong with my data (size is big), I got
some warning messages indicating that "In sqrt(diag(vc)[1:npar]) :
NaNs produced." Therefore, some of the coefficients do not have
standard errors. I also have a follow-up question: if I want to
estimate a slope as outcome model, how am I supposed to specify the
model. I tried following the few tutorials you posted on CRAN, but was
not able to figure it out:
Here is my model:
level 1: y*_ij = beta_0j + beta_1j*x1_ij + beta_2j*x2_ij +
beta_3j*x3_ij + epsilon_ij
where y* is a latent continuous variable and y is an observed binary
dependent variable.
y is an observed ordinal variable, say ranging from 1-4, and has been
coded as a factor variable.
x's are predictors at level 1
beta's are regression coefficients at level 1
epsilon's are error terms in level 1 equations
level 2 Eq1: beta_0j = gamma_00 + gamma_01*w1_j + gamma_02*w2_j + mu_0j
Level 2 Eq2: beta_1j = gamma_10 + gamma_11*w1_j + gamma_02*w2_j + mu_1j
My guess would be:
# try 1
clmm(y~ x1 + x2 + x3 + w1 + w2 + w1:x1 + w2:x2 + (1 + x1 | group), #
like the syntax in lmer or glmer
data=alllev, link="logit",
na.action=na.omit,
Hess=T)
# or try 2
clmm(y~ x1 + x2 + x3 + w1 + w2 + w1:x1 + w2:x2 + (1 | group) + (1 | group:x1),
data=alllev, link="logit",
na.action=na.omit,
Hess=T)
but none worked. After I issued the first try, I got the following message:
Error: Matrices must have same number of columns in rbind2(..1, r)
In addition: Warning messages:
1: In cntnew:male :
numerical expression has 177770 elements: only the first used
and after the second try, simply it says that I got to following the
(1|factor) format. I would appreciate that if you could point me to
the right direction. Also, I know I am dealing with a relatively large
data set, but is there any way to speed up the estimation a bit.
Thanks a lot!
Jun
On Fri, Jun 7, 2013 at 1:04 AM, Rune Haubo <rune.haubo at gmail.com> wrote:
> On 6 June 2013 00:13, Xu Jun <junxu.r at gmail.com> wrote:
>> Dear r-helpers,
>>
>> I have two questions on multilevel binary and ordered regression models,
>> respectively:
>>
>> 1. Is there any r function (like lmer or glmer) to run multilevel ordered
>> regression models?
>
> Yes, package ordinal will fit such models.
>
> Cheers,
> Rune
More information about the R-help
mailing list