Dear R users,

I have repeated measurements on individuals. I want to estimate the
time-varying effect of a factor variable X (taking three levels), e.g. a
model in the spirit of Hastie and Tibshirani (1993). 

I am considering using the package "mgvc" which implements generalized
additive models, especially the function gamm, which estimates
generalized additive mixed models, and thus, can deal with the
correlated repeated measures within individuals.

However, I am confused as to how to specify the time-varying coefficient
part of the formula. According to the mgvc documentation (p. 35):
"by variables are the means for constructing 'varying-coefficient
models' (geographic regression models) and for letting smooths
'interact' with factors or parametric terms."

Suppose that "y" is the response variable, "id" identifies individuals,
"x" is the three-level factor variable and "time" indexes the chronology
of responses.

Is this model estimating the time-varying coefficient of x? If it is
not, how should I specify the model?

mod <- gamm( y ~ factor(x) + s(time, by=factor(x)), data=mydata,
random=list(patient=~ 1), correlation = corAR1())

Best,
MP


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to