[R] Using spline parameters to generate data
Spencer Graves
spencer.graves at pdf.com
Fri Aug 15 02:46:28 CEST 2003
Have you considered adding noise to "predict(spline.model)$y"? If this
won't solve your problem, then I think I don't understand what you want
to do.
spencer graves
chumpmonkey3 at hushmail.com wrote:
> # I need to generate some data. I'm modeling some time series that follow
> a
> # negative exponential decay (mostly). I have 20 samples that can easily
> be fit with cubic splines.
> # What I want to do is generate many thousands of similar samples using
> the parameters from the splines
>
> # For instance one data sample looks not unlike this:
> foo.curve <- 1 * exp(-0.01 * 1:500) + 0.5
> ts.plot(foo.curve, lwd = 2)
>
> # Another sample looks not unlike this:
> foo.curve2 <- 0.9 * exp(-0.02 * 1:500) + 0.5
> ts.plot(foo.curve2, lwd = 2)
>
>
>
> # They can be fit with splines easily like so:
>
> ts.plot(foo.curve, lwd = 2)
> spline.model <- smooth.spline(foo.curve)
>
> fits4foo <- predict(spline.model)$y
> spline4foo <- spline(1:500, fits4foo)
> lines(spline4foo$x, spline4foo$y, col = "red", lwd = 2, lty = "dashed")
>
> # I originally generated the data I needed by using a nls model and
> # adding some noise to the mean of the coefficents from those fits.
> # However, I've been told to try and do this using splines for arcane
> reasons.
>
> # So, if you had 20 splines like spline.model above and wanted to generate
> some similar data what would you do?
> # Thanks in advance.
>
>
>
>
>
>
>
>
>
> Promote security and make money with the Hushmail Affiliate Program:
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
More information about the R-help
mailing list