Prince Modi Prince Modi - 2 months ago 15
R Question

Store/Save Predictive Model in R

I would like to store the output of the following code. I tried list, data frame and vector but was not able to store it.

Model<-lda( y ~ Trend+Class+F1+F4+ATR+macd_signal+macd1+F5 ,data=x)


> Model

Call:
lda(y ~ Trend + Class + F1 + F4 + ATR + macd_signal + macd1 +
F5, data = x)

Prior probabilities of groups:

LOSS PROFIT
0.4981818 0.5018182

Group means:

TrendBull ClassUP F1 F4 ATR macd_signal macd1 F5
LOSS 0.5450122 0.3990268 1480.451 1481.672 11.64657 -0.0005850151 0.01542818 1478.567
PROFIT 0.5000000 0.4082126 1487.280 1486.707 12.25799 -0.0304256947 -0.03845741 1489.620

Coefficients of linear discriminants:

LD1
TrendBull -0.033267160

ClassUP 0.151291378

F1 -0.003215276

F4 -0.042431558

ATR 0.082615338

macd_signal 0.090182055

macd1 2.637216918

F5 0.045956343

> class(Model)

[1] "lda"

> typeof(Model)

[1] "list"


Any ideas on how to store it?

Answer

One thing you can do is save the model output in its own file. An R object can be saved as an rds file. For example:

saveRDS(model, file = "your path/filename.rds")

You can then load the object into your R environment:

mod <- readRDS("your path/filename.rds")
Comments