predict() with arbitrary coefficients in r

前端 未结 3 764
庸人自扰
庸人自扰 2020-12-10 07:51

I\'ve got some coefficients for a logit model set by a non-r user. I\'d like to import those coefficients into r and generate some goodness of fit estimates on the same data

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-10 08:20

    If you follow the code through predict.glm which passes the object to predict.lm, it appears that the node of the model list that needs to be altered is indeed fit$coefficients. However, altering the summary()-object will have no effect. The [['coefficients']] in the glm and lm objects are not matrices with columns: 'Estimate', 'Std. Error', 't value', 'Pr(>|t|)' such as produced by summary, but rather just a vector of coefficients.

     fit$coefficients <- y
     newpred <- predict(fit)
    

    You might make a copy and work on it if you will need any further use of fit.

提交回复
热议问题