On 11-03-29 9:32 PM, Zhipeng Wang wrote:
Dear all,
I have the problem as the title shows. It is time series of measurements. I
want to estimate the value at time point when we have no actual measured
value (Only in the time range, not for prediction in future time).
Hope you could give me some suggestion or hint. Thank you so much.
If you want to interpolate the data, use splinefun. For example,
x <- 1:5
y <- rnorm(5)
f <- splinefun(x,y)
curve(f, from=1, to=5)
points(x,y)
If you want to draw a smooth curve through the data, then use one of the
model fitting functions, and then predict to compute values at new x
values. For example,
library(mgcv)
x <- 1:50 # Smoothing needs more data
y <- rnorm(50)
fit <- gam(y ~ s(x))
newx <- seq(1,50, len=1000)
newy <- predict(fit, newdata=data.frame(x=newx))
plot(x,y)
lines(newx, newy)
Duncan Murdoch
______________________________________________
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.