How to save glm result without data or only with coeffients for prediction?

后端 未结 4 420
后悔当初
后悔当初 2021-02-05 23:12

When I use the following R code,

model_glm=glm(V1~. , data=xx,family=\"binomial\");
save(file=\"modelfile\",model_glm);

The size of modelfile w

4条回答
  •  醉梦人生
    2021-02-05 23:26

    I had this issue where I was running the GLM as part of an R in production and the size of the GLM greatly slowed me down. I found I needed to kill off more than just the $data. Here is my post on it, with an example below.

    > object.size(sg)
    96499472 bytes
    > sg$residuals <- NULL
    > sg$weights <- NULL
    > sg$fitted.values <- NULL
    > sg$prior.weights <- NULL
    > sg$na.action<- NULL
    > sg$linear.predictors <- NULL
    > sg$fitted.values <- NULL
    > sg$effects <-NULL
    > sg$data <- NULL
    > object.size(sg)
    3483976 bytes
    > sg$qr$qr <- NULL
    > object.size(sg)
    79736 bytes
    

提交回复
热议问题