Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to save a fitted R model for later use

Tags:

r

Sorry for this novice question: if I fit a lm() model or loess() model, and save the model somewhere in a file or in database, for later using by third party with predict() method, do I have to save the entire model object? Since returned model object contains orginal raw data, this returned object can be huge.

like image 617
ahala Avatar asked May 28 '10 14:05

ahala


1 Answers

If you include the argument model = FALSE (it's true by default) when fitting the model, the model frame that was used will be excluded from the resulting object. You can get an estimate of the memory that is being used to store the model object giving:

object.size(my_model)
like image 137
George Dontas Avatar answered Nov 15 '22 21:11

George Dontas