S******y 发帖数: 1123 | 1 I have the following data from a model -
Month Spend
2008_01 100
2008_02 150
2008_03 160
2008_04 200
2008_05 300
2008_06 290
2008_07 350
2008_08 400
2008_09 450
2008_10 399
2008_11 500
2008_12 1500
The plot of data shows the irregular upward trend in 2008-12.
I would like to draw a smooth line across my data points.
Any suggestion would be greatly appreciated!!!!!! | f***a 发帖数: 329 | 2 ### adjust parameter to meet your needs, hehe :)
#data
y <- c(100,150,160,200,300,290,350,400,450,399,500,1500)
x <- 1:12
nx <- seq(1,12,by=0.1)
plot(x,y,type="b")
#poly
tt <- lm(y~poly(x,10))
lines(nx,predict(tt,newdata=data.frame(x=nx)),col=2)
#loess
lsm<-loess.smooth(x,y,span=1/2)
lines(lsm,col=2)
lsm1<-loess(y~x,span=1/4)
pred<-predict(lsm1,newdata=nx,se=TRUE)
lines(nx,pred$fit,col=4)
lines(nx,pred$fit-1.96*pred$se.fit,lty=2)
#supsmu
lsmsup<-supsmu(x,y)
lines(lsmsup,col=2)
plot(x, y)
for(i i
【在 S******y 的大作中提到】 : I have the following data from a model - : Month Spend : 2008_01 100 : 2008_02 150 : 2008_03 160 : 2008_04 200 : 2008_05 300 : 2008_06 290 : 2008_07 350 : 2008_08 400
| S******y 发帖数: 1123 | |
|