[R] finding the best cubic spline fitting

David Winsemius dwinsemius at comcast.net
Tue May 25 05:02:34 CEST 2010


On May 24, 2010, at 6:39 PM, Usman Munir wrote:

> Hi,
>
> I am trying to fit cubic spline to a data on mortality rate by age  
> and year
> (1900-2008). The data is noisy and hence I would like to smooth  
> using spline
> and also extrapolate beyond 2008. Data from 1900 to 1948 are very  
> unreliable
> while data from 1948 to 2008 are reliable. I would like to have a  
> higher
> weight for data between 1948 to 2008. I am not sure how to do this.  
> When I
> smooth data from 1948 to 2008 I get sensible results for residual  
> plots.
>
> fitgam=gam(mortality~te(age,year, bs="cs"))
> summary(fitgam)
> gam.check(fitgam
>
> However, if I smooth all the data 1900 to 1948 I get wierd residual  
> plots.

There were, after all, two World Wars and the Influenza Pandemic of  
1918 in those years.

> I
> have tried putting in knots i.e.
> fitgam=gam(logit_temp~te(age,year, bs="cs"), knot=list(years =
> c 
> (1910,1920,1948,1958,1968,1978,1988,1998,2002,2005,2008 
> )),data=mat_temp)
>
> But this doesn't work either. Any suggestions will be appreciated!
>
> Thanks,
> Usman

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list