[R] Use generalised additive model to plot curve
e-letter
inpost at gmail.com
Tue Dec 14 23:36:54 CET 2010
Readers,
I have been reading 'the r book' by Crawley and think that the
generalised additive model is appropriate for this problem. The
package 'gam' was installed using the command (as root)
install.package("gam")
...
library(gam)
> library(gam)
Loading required package: splines
Loading required package: akima
> library(mgcv)
This is mgcv 1.3-25
Attaching package: 'mgcv'
The following object(s) are masked from package:gam :
gam,
gam.control,
gam.fit,
plot.gam,
predict.gam,
s,
summary.gam
> x<-c(30,50,80,90,100)
> y<-c(160,180,250,450,300)
> model<-gam(y~s(x))
Error in smooth.construct.tp.smooth.spec(object, data, knots) :
A term has fewer unique covariate combinations than specified
maximum degrees of freedom
The objective is to plot y against x, finally to produce a graph with
a smooth curve (and then remove the data points). What is my mistake
please?
yours,
r251
gnu/linux mandriva2008
More information about the R-help
mailing list