Logistic Regression中只有一个列的固定系数

huangapple go评论67阅读模式
英文:

Logistic Regression with a fixed coefficient for only one column

问题

我有一个包含预测列 A、B、C 和二进制响应 D 的设计矩阵

但是,我希望预测变量 A 的系数为1,并且只想确定 B 和 C 的权重。与 a0+a1*x1+a2*x2+a3*x3~y 不同,我想要 a0+x1+a2*x2+a3*x3~y。

如何使用 glm 实现这个目标?

我最初考虑了操纵逻辑回归公式 - 删除 A 预测变量并从响应中减去它,但是...

英文:

I have a design matrix with predictor columns A, B, C and a binary response D

However, I want predictor to have a given coefficient of 1, and only want to determine the weights for B and C. Instead of a0+a1*x1+a2*x2+a3*x3~y I want a0+x1+a2*x2+a3*x3~y

How could I do that with glm?

I first thought about manipulating the formula for logistic regression - remove the A predictor and substract it from the response, but

答案1

得分: 1

这是使用 offset 完成的:

> ?offset
偏移量是要添加到线性预测器中的术语,例如在广义线性模型中,其已知系数为1,而不是估计系数。

示例:

> dat <- iris[iris$Species!="setosa",]
> fit <- glm(Species ~ Sepal.Length + Sepal.Width + Petal.Length + offset(Petal.Width), dat, family=binomial)

在glm中,可以使用 offset 参数实现相同的效果:

fit2 <- glm(Species ~ Sepal.Length + Sepal.Width + Petal.Length, offset=Petal.Width, data=dat, family=binomial)

fitfit2 中的系数是相同的。

英文:

This is done with offset:

> ?offset
An offset is a term to be added to a linear predictor, such as in
a generalised linear model, with known coefficient 1 rather than
an estimated coefficient.

Example:

> dat <- iris[iris$Species!="setosa",]
> fit <- glm(Species ~ Sepal.Length + Sepal.Width + Petal.Length + offset(Petal.Width), dat, family=binomial)

The same is achieved with the offset parameter in glm:

fit2 <- glm(Species ~ Sepal.Length + Sepal.Width + Petal.Length, offset=Petal.Width, data=dat, family=binomial)

The coeffcients in fit and fit2 are identical.

huangapple
  • 本文由 发表于 2023年7月6日 20:08:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76628670.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定