[R] How to choose a proper smoothing spline in GAM of mgcv package?
David Winsemius
dwinsemius at comcast.net
Tue Oct 13 04:46:18 CEST 2009
On Oct 12, 2009, at 10:10 PM, Yan Li wrote:
> Hi, there,
>
> I have 5 datasets. I would like to choose a basis spline with same
> knots in
> GAM function in order to obtain same basis function for 5 datasets.
> Moreover, the basis spline is used to for an interaction of two
> covarites.
It is possible to specify the knots for cr splines in the gam function
(... not GAM). You have not described the sampling process that
resulted in these 5 datasets, but the naive approach would be to cbind
them and estimate for the super-group as a whole. After finding knots
for a pooled dataset you could perhaps refit individually with the
knots being fixed at the group values, assuming this makes sense for
you sampling design.
>
> I used "cr" in one covariate, but it can only smooth w.r.t 1
> covariate. Can
> anyone give me some suggestion about how to choose a proper
> smoothing spline
> (bs='?') and knots for two covariates?
Multiple terms in the model require vectors for the argument to sp or
else inclusion within each smoothing term. See the docs and examples in:
library(mgcv)
?gam
Have you yet looked at:
?te
--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
More information about the R-help
mailing list