Hi all,
I try to interpolate a data set in the form:

time    Erg
0.000000        48.650000
1.500000        56.080000
3.000000        38.330000
4.500000        49.650000
6.000000        61.390000
7.500000        51.250000
9.000000        50.450000
10.500000       55.110000
12.000000       61.120000
18.000000       61.260000
24.000000       62.670000
36.000000       63.670000
48.000000       74.880000

I want to get smoothed splines by using the class gam

The first way I tried , was the following:

> library('mgcv')

> t=read.table('Valuedata', header=T, sep="\t")
> g=gam(Erg~s(time,k=4,fx=TRUE,bs="cr"),data=t)
> plot(g)
 

The plot shows me 3 curves in the yrange of -20 and 30 and I don't
know, which curve is the result.

The second way I tried was:

> library("gam")
> t=read.table('Valuedata', header=T, sep="\t")
> g=gam(Erg~s(time,3), data=t)
> plot(g)
Error in eval(predvars, data, env) : invalid 'envir' argument

This way I can't see the result and I so I can't see the curve.

My first question:

How can I get the function to calculate the according splines, that are
determined by gam.
I think about a function like:
f(x)=a0+a1+x+a2*x^2+a3*x^3 +smooth(x)
a polynome of rank k, that I can use in an other context. I can find the 
fitted.values, the coefficients and the smooth but I can't find the exact
description to calculate the according values.
I want to calculate the interpolations spline in the interval [0,48]
and use maybe 100 - 1000 supporting points.
Or exists a function in R, that gives me these values?

My second question:
I can't find a reason for the error message above.

I have no experience with R, but I program in other languages.


Thanks a lot to everybody who will help me - anna_m!
-- 
View this message in context: 
http://r.789695.n4.nabble.com/I-want-to-get-smoothed-splines-by-using-the-class-gam-tp3078561p3078561.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to