如何在没有数据或仅具有系数的情况下保存glm结果? [英] How to save glm result without data or only with coeffients for prediction?
问题描述
当我使用以下R代码时,
When I use the following R code,
model_glm=glm(V1~. , data=xx,family="binomial");
save(file="modelfile",model_glm);
modelfile的大小将与数据一样大,在我的情况下为1gig.如何删除model_glm结果中的数据部分,因此只能保存一个小文件.
The size of modelfile will be as much as the data, which will be 1gig in my case. How can I remove the data part in the result of model_glm, so I can only save a small file.
推荐答案
在对glm
的调用中设置model = FALSE
可以防止返回model.frame
.同时设置y = FALSE
将防止返回响应向量. x = FALSE
是默认设置,可防止返回model.matrix
.
Setting model = FALSE
in your call to glm
should prevent the model.frame
from being returned. Also setting y = FALSE
will prevent the response vector from being returned. x = FALSE
is the default setting and prevents the model.matrix
from being returned.
这种组合可以缩小glm对象的大小.
This combination should shrink the size of your glm object.
当然,您也可以使用coef(model_glm)
提取系数,或者使用标准误差提取
Of course, you can also extract the coefficients with coef(model_glm)
or, with standard errors,
summary(model_glm)$coef
这篇关于如何在没有数据或仅具有系数的情况下保存glm结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!