Dear Simon, Thank you very much! A colleague of mine directed me towards the extract.lmeDesign function of the RLRsim package, but that only gets me the basis functions in function of the model I specified. Your solution is what I was looking for.
Kind regards Joris Just for completeness : This does something different, it takes the design out of the lme part of a gamm object. This gives a mixed model representation of the spline using the basis function in one way or another (scaling is different, I'm still trying to grasp how). It's not really what I looked for, but it might be useful for somebody else. library(RLRsim) X <- extract.lmeDesign(test$lme)$X # fixed effects I believe Z <- extract.lmeDesign(test$lme)$Z # random effects I believe op <- par(mfrow=c(2,5),mar=c(4,4,1,1)) plot(x1,X[,1],ylab="Basis function",xlab="X",type="l",lwd=2) plot(x1,X[,2],ylab="Basis function",xlab="X",type="l",lwd=2) plot(x1,Z[,8],ylab="Basis function",xlab="X",type="l",lwd=2) plot(x1,Z[,7],ylab="Basis function",xlab="X",type="l",lwd=2) plot(x1,Z[,6],ylab="Basis function",xlab="X",type="l",lwd=2) plot(x1,Z[,5],ylab="Basis function",xlab="X",type="l",lwd=2) plot(x1,Z[,4],ylab="Basis function",xlab="X",type="l",lwd=2) plot(x1,Z[,3],ylab="Basis function",xlab="X",type="l",lwd=2) plot(x1,Z[,2],ylab="Basis function",xlab="X",type="l",lwd=2) plot(x1,Z[,1],ylab="Basis function",xlab="X",type="l",lwd=2) par(op) On Wed, May 19, 2010 at 8:38 PM, Simon Wood <s.w...@bath.ac.uk> wrote: > > > On Wednesday 19 May 2010 15:08, Joris Meys wrote: > > Dear all, > > > > for demonstration purposes I want to display the basis functions used by > a > > thin plate regression spline in a gamm model. I've been searching the > help > > files, but I can't really figure out how to get the plots of the basis > > functions. Anybody an idea? > > > > Some toy code : > > > > require(mgcv) > > require(nlme) > > > > x1 <- 1:1000 > > x2 <- runif(1000,10,500) > > > > fx1 <- -4*sin(x1/50) > > fx2 <- -10*(x2)^(1/4) > > y <- 60+ fx1 + fx2 + rnorm(1000,0,5) > > > > test <- gamm(y~s(x1)+s(x2)) > > > > plot(test$gam) > > > > ## plots basis functions in space of identifiability constraints, set > ## absorb.cons=FALSE for original basis functions > um <- smoothCon(s(x1),data=data.frame(x1=sort(x1)), > knots=NULL,absorb.cons=TRUE) > X <- um[[1]]$X > plot(sort(x1),X[,1],ylim=range(X),type="l") > for (i in 2:ncol(X)) lines(sort(x1),X[,i],col=i) > > best, > Simon > > > > > > > > This gives me the conditional estimates, but not the basis functions for > > the different splines. I'd like to have the basis functions for s(x1) and > > s(x2). > > > > Cheers > > Joris > > -- > > Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK > > +44 1225 386603 > > www.maths.bath.ac.uk/~sw283<http://www.maths.bath.ac.uk/%7Esw283> > -- Joris Meys Statistical Consultant Ghent University Faculty of Bioscience Engineering Department of Applied mathematics, biometrics and process control Coupure Links 653 B-9000 Gent tel : +32 9 264 59 87 joris.m...@ugent.be ------------------------------- Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php [[alternative HTML version deleted]] ______________________________________________ R-help@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.