There's no function for extracting this directly, as almost anything
that you want to do with the smoother matrix can be done in a much more
efficient way without computing it explicitly, but here's an example of
how to compute it explicitly in the unweighted additive case...
library(mgcv)
set.seed(0) ## simulate some data...
dat <- gamSim(1,n=400,dist="normal",scale=2)
b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)
X <- model.matrix(b)
## compute X'(X'X+S)^{-1}X'...
A <- X%*%vcov(b,dispersion=1)%*%t(X)
dA <- influence(b) ## much more efficient if you only need diag(A)
range(dA-diag(A))
On 23/02/12 11:02, Man Zhang wrote:> Dear All,
>
> I would like to extract the smoothing matrix of the fitted GAM, \hat{y} =
Sy. I can't seem to find the function or am I missing something?
>
> Thanks, any help is greatly appreciated
> Man Zhang
>
> [[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.
--
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603 http://people.bath.ac.uk/sw283