[R] Smooth Spline

lpone at xs4all.nl lpone at xs4all.nl
Thu Jun 5 07:59:57 CEST 2008


maybe not the optimal but it works:

> Hi,
>
> I have three original curves as follows,
> n<-seq(20,200,by=10)
>
> t<-c(0.1138, 0.1639, 0.2051, 0.2473, 0.2890, 0.3304, 0.3827, 0.4075,
> 0.4618, 0.4944,
> 0.5209, 0.5562, 0.5935, 0.6197, 0.6523, 0.6771, 0.6984, 0.7209, 0.7453)
>
> es<-c(0.3682, 0.4268, 0.5585, 0.6095, 0.7023, 0.7534, 0.8225, 0.8471,
> 0.8964, 0.9098, 0.9371, 0.9514, 0.9685, 0.9747, 0.9812, 0.9859, 0.9905,
> 0.9923, 0.9940)
>
> coves<-c(0.3793, 0.4935, 0.5472, 0.6366, 0.6882, 0.7578, 0.8058, 0.8457,
> 0.8783, 0.9019, 0.9212, 0.9417, 0.9558, 0.9662, 0.9732, 0.9802, 0.9828,
> 0.9881, 0.9896)
>
> matplot(n,cbind(coves,es,t),type ='l',
> col=c("red","blue","black"),xlab='n',ylab='power')
>
> I want power curves to be smooth (avoid sawtooth curve), I try the
> follows,
> ##Spline
> library(modreg)
> st<- smooth.spline(t)
> ses<- smooth.spline(es)
> scoves<- smooth.spline(coves)

matplot(n,cbind(st$y,ses$y,scoves$y),type ='l',
col=c("red","blue","black"),xlab='n',ylab='power')

Ludo
>
> plot(scoves,col='red', type='l')
> lines(ses, col='blue',type='l')
> lines(st,col='black',type='l')
>
> The shapes are what I want, but I want x-axis consistent to the correspond
> to n. Does anyone know the solution?
>
> Thanks,
>
> Kate
> 	[[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.
>



More information about the R-help mailing list