[R] more questions on gam/gamm(mgcv)...

Simon Wood s.wood at bath.ac.uk
Sun Aug 22 12:44:26 CEST 2010


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



More information about the R-help mailing list