fit glm with known coefficients and unknown intercept

安稳与你 提交于 2019-12-11 02:59:06

问题


I am trying to fit a logistic regression model using glm, where I am only interested in the intercept - but I still want the model to be fitted with known coefficients. Example:

or

beta <- c(24.5,3.6,2.87,7.32)

So I want to use

model <- glm(y~x_1+x_2+x_3+x_4, family=binomial(link="logit"), data=dt)

and in some way incorporate the known betas, so the glm function only fits the alpha. How can I do that?


回答1:


With offsets, which add a known term to the linear predictor (RHS of the formula, on the logit scale) of a GLM.

beta <- c(24.5, 3.6, 2.87, 7.32)
dt <- transform(dt,
         pred=beta[1]*x_1+beta[2]*x_2+beta[3]*x_3+beta[4]*x_4)
model <- glm(y~1+offset(pred), family=binomial(link="logit"), data=dt)


来源:https://stackoverflow.com/questions/31571299/fit-glm-with-known-coefficients-and-unknown-intercept

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!