An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20081208/4087d665/attachment.pl>
save LOESS regression line values in R
3 messages · Dragos Zaharescu, Owen Jones, Kingsford Jones
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-ecology/attachments/20081208/2edca23f/attachment.pl>
Hi Dragos, It's not entirely clear what you'd like to do, but assuming you're using stats::loess to create the fit, you can use the predict function to generate predictions and then dput (or dump, save, write.table ...) to save the output. For example, cars.lo <- loess(dist ~ speed, cars) str(pred <- predict(cars.lo, data.frame(speed = seq(5, 30, 1)), se = TRUE)) List of 4 $ fit : num [1:26] 7.81 10.04 12.57 15.37 18.43 ... $ se.fit : num [1:26] 7.57 5.94 4.98 4.52 4.32 ... $ residual.scale: num 15.3 $ df : num 44.6 # predict.loess has returned a list and the 'fit' element contains the fitted values. # dput can write these out to a text file: dput(pred$fit, file = 'predfile.txt') # And to retrieve, use dget ret.pred <- dget(file = 'predfile.txt') If you'd rather save a workspace with the object, see ?save. To write out a data frame see ?write.table. hope it helps, Kingsford Jones
On Mon, Dec 8, 2008 at 8:16 AM, Dragos Zaharescu <zaha_dragos at yahoo.com> wrote:
Dear list members,
Can anyone give a hint on how to calculate and save predicted (fit) values for the LOESS regression line in R ?
This is for further analysis on climate change data.
Much appreciated.
Dragos Zaharescu @ KingstonU, London
[[alternative HTML version deleted]]
_______________________________________________ R-sig-ecology mailing list R-sig-ecology at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-ecology