Hi R-users, I'm using R 2.11.1, mgcv 1.6-2 to fit a generalized additive mixed model. I'm new to this package...and just got more and more problems... 1. Can I include correlation and/or random effect into gam( ) also? or only gamm( ) could be used? 2. I want to estimate the smoothing function s(x) under each level of treatment. i.e. different s(x) in each level of treatment. shall I use s(x, by=treatment)? When I checked the basis expansion I found they are all the same...but shouldn't be the same right? 3. fit=gam(.......) basis=fit$smooth par=basis[[1]]$xp Here, is "par" the vector of knots...? Where can I find the fitted coef of smoothing function..?? Thank you all and any hint/help will be appreciated... -- Best, Xia [[alternative HTML version deleted]]
> Hi R-users, > > I'm using R 2.11.1, mgcv 1.6-2 to fit a generalized additive mixed model. > I'm new to this package...and just got more and more problems... > > 1. Can I include correlation and/or random effect into gam( ) also? or > only > gamm( ) could be used?Only in gamm()> 2. I want to estimate the smoothing function s(x) under each level of > treatment. i.e. different s(x) in each level of treatment. shall I use > s(x, > by=treatment)? When I checked the basis expansion I found they are all the > same...but shouldn't be the same right?Do you mean the estimated smooths are the same?> 3. fit=gam(.......) > basis=fit$smooth > par=basis[[1]]$xp > > Here, is "par" the vector of knots...? Where can I find the fitted coef > of smoothing function..??coef(fit)> > Thank you all and any hint/help will be appreciated... > > > -- > Best, > Xia > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >
On Wednesday 04 August 2010 20:05, Xia Li wrote:> Hi R-users, > > I'm using R 2.11.1, mgcv 1.6-2 to fit a generalized additive mixed model. > I'm new to this package...and just got more and more problems... > > 1. Can I include correlation and/or random effect into gam( ) also? or only > gamm( ) could be used?-- you can use simple random effects with gam, but not correlation structures. see ?random.effects in the mgcv help> > 2. I want to estimate the smoothing function s(x) under each level of > treatment. i.e. different s(x) in each level of treatment. shall I use s(x, > by=treatment)? When I checked the basis expansion I found they are all the > same...but shouldn't be the same right?--- this is right. If you checked the bases in the way you have done below, then they should be all the same. This is deliberate (and documented). Basically the same basis is used for each level of the factor, but the model matrix columns corresponding to the smooth for any particular level have all their rows set to zero, *except* those rows corresponding to the factor level to which the smooth applies.> 3. fit=gam(.......) > basis=fit$smooth > par=basis[[1]]$xp > > Here, is "par" the vector of knots...? Where can I find the fitted coef > of smoothing function..??in coef(fit), you can identify which coefs are which by label.> Thank you all and any hint/help will be appreciated...--> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK > +44 1225 386603 www.maths.bath.ac.uk/~sw283