KKThird@Yahoo.Com
2004-Jun-23 21:32 UTC
[R] nlme questions (e.g., specifying group membership, changing options)
I'm trying to better understand the nlme package and have a few questions.
1.)
Other than using various coding strategies (e.g., dummy coding, effect coding),
is there a way to identify group membership (i.e., treatment) directly? For
example, the following code will fit a two group logistic growth curve (where
'Score' is repeatedly measured over 'Time' for each of the
individuals (ID)):
nlme(Score ~ (ALPHA + Group)/(1+exp(-(GAMMA + Group)*(Time - (BETA+Group)))),
data=LE,
fixed=ALPHA + BETA + GAMMA ~ 1,
random=ALPHA + BETA + GAMMA ~ 1,
groups=~ID,
start = c(ALPHA = 1, BETA = 3.25, GAMMA = 2.5))
Rather than specifying the effect of Group in such a manner, is there a simpler
way to identify group membership in order to test the effect of group
differences on the parameters of the model? I thought (removing the dummy codes
and) specifying group membership by: 'groups=~ID/Groups' might work, but
an error is returned. I also thought specifying group membership by
:'fixed=ALPHA + BETA + GAMMA ~ 1' might work, but an error is also
returned.
2.)
When will, that is under what circumstances, will there be something different
than '~1' on the right hand side of the 'fixed' and
'random' specification lines?
3.)
Given that I figure out a way to specify group membership/treatment, how are
starting values for both groups specified? Can the covariance structure also be
given starting values?
Sorry for what might turn out to be simply questions. But, as of yet I've
not been able to understand exactly what is going on. Thanks for any help you
might be able to provide.
Have a good one,
Ken
---------------------------------
[[alternative HTML version deleted]]
Spencer Graves
2004-Jun-24 14:53 UTC
[R] nlme questions (e.g., specifying group membership, changing options)
Are your categorical variables factors or ordered factors? If
yes, lm and many other functions including, I believe, nlme, will
automatically create the required dummy variables using contrasts
specified by options()$contrasts. Consider the following:
> options("contrasts")
$contrasts
unordered ordered
"contr.treatment" "contr.poly"
> lm(y~x, DF)
Call:
lm(formula = y ~ x, data = DF)
Coefficients:
(Intercept) xb xc
1.5 2.0 4.0
> contr.treatment(3)
2 3
1 0 0
2 1 0
3 0 1
> options(contrasts=c(unordered="contr.helmert",
ordered="contr.poly"))
> lm(y~x, DF)
Call:
lm(formula = y ~ x, data = DF)
Coefficients:
(Intercept) x1 x2
3.5 1.0 1.0
> contr.helmert(3)
[,1] [,2]
1 -1 -1
2 1 -1
3 0 2
>
Have you studied Pinheiro and Bates (2000) Mixed-Effects Models in
S and S-Plus (Springer)? I found answers to questions like yours in
that book.
hope this helps. spencer graves
KKThird at Yahoo.Com wrote:
>I'm trying to better understand the nlme package and have a few
questions.
>
>
>
>1.)
>
>Other than using various coding strategies (e.g., dummy coding, effect
coding), is there a way to identify group membership (i.e., treatment) directly?
For example, the following code will fit a two group logistic growth curve
(where 'Score' is repeatedly measured over 'Time' for each of
the individuals (ID)):
>
>
>
>nlme(Score ~ (ALPHA + Group)/(1+exp(-(GAMMA + Group)*(Time -
(BETA+Group)))),
>
> data=LE,
>
> fixed=ALPHA + BETA + GAMMA ~ 1,
>
> random=ALPHA + BETA + GAMMA ~ 1,
>
> groups=~ID,
>
> start = c(ALPHA = 1, BETA = 3.25, GAMMA = 2.5))
>
>
>
>Rather than specifying the effect of Group in such a manner, is there a
simpler way to identify group membership in order to test the effect of group
differences on the parameters of the model? I thought (removing the dummy codes
and) specifying group membership by: 'groups=~ID/Groups' might work, but
an error is returned. I also thought specifying group membership by
:'fixed=ALPHA + BETA + GAMMA ~ 1' might work, but an error is also
returned.
>
>
>
>2.)
>
>When will, that is under what circumstances, will there be something
different than '~1' on the right hand side of the 'fixed' and
'random' specification lines?
>
>
>
>3.)
>
>Given that I figure out a way to specify group membership/treatment, how are
starting values for both groups specified? Can the covariance structure also be
given starting values?
>
>
>
>Sorry for what might turn out to be simply questions. But, as of yet
I've not been able to understand exactly what is going on. Thanks for any
help you might be able to provide.
>
>Have a good one,
>
>Ken
>
>
>
>---------------------------------
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
>
>