Dear group,

I have been experimenting with gamm4 to derive GAMMs of some repeated measures data.

The models looks very nice and seem to give more flexibility than my LMMs.

Ultimately I want to compare models not by the quality of their fit (also the reality of comparing LMM and GAMM fits seems complex?), but in the quality of their predictions in new data sets, and in simulated new data by MCMC.

With LMMs I predict using the fixed effects only using:
mm <- model.matrix(terms(lmer),newdata)
newdata$predicted <- mm %*% fixef(lmer)

This is fine since we are predicting in new individuals, with new independent random effects.

I cannot get this predict method to work with gamm4.

> mm <- model.matrix(terms(gamm4$mer), newdata)
Error in model.frame.default(object, data, xlev = xlev) :
  variable lengths differ (found for 'X')

I think this is because the GAM process creates new variables in order to transform predictor variables.
It is also complex, because I believe the transforms are stored as random effects, so I would need to extract these random effects, but not the "individual level" random effects.

Does anyone now how I can

a)      Extract just the tranform effect terms from the gamm4 model?

b)      make predictions into new data using gamm4?

c)       Extract the model specification of the GAMM so I could impliment it as a standalone algorithm?

d)      General advice?

Thanks,

Justin
-------------------------------------------------------------------
King's College London
Department of Primary Care and Public Health Sciences
Division of Health and Social Care Research
7th Floor Capital House
42 Weston Street
London SE1 3QD

Tel: 020 7848 6638
Fax: 020 7848 6620


	[[alternative HTML version deleted]]

