R中多元回归系数的GLHT
GLHT for multiple regression coefficients in R
我有 运行 个 GLM 二项式模型
fit <- glm(highlow ~ V1 + V2 + V3 + V4 + V5 + V6 + V7 + V8 + V9 + V10,
family="binomial")
为了检验 V1 = V2 的原假设,我使用了以下代码。
glht.mod <- glht(fit, linfct = c("V1 - V2 = 0"))
summary(glht.mod)
我的问题是我可以检验是否 V1 = V2 = V3(所有三个系数都相等的零假设 - 请注意,这与在单独的迭代中检验 V1 = V2 和 V2 = V3 是否相同)?
如果有任何帮助,我可以使用以下代码在 SAS 中实现此目的
proc logistic;
model highlow = V1 V2 V3 V4 V5 V6 V7 V8 V9 V10;
test1: V1 = V2;
test2: V1 = V2 = V3;
run;
您的问题的可能解决方案:
set.seed(1)
n <- 1000
highlow <- factor(runif(n)>0.5)
X <- matrix(rnorm(n*10),nrow=n)
df <- data.frame(highlow, X)
names(df) <- c("highlow", paste("V",1:10,sep=""))
fit <- glm(highlow ~ V1 + V2 + V3 + V4 + V5 + V6 + V7 + V8 + V9 + V10,
family="binomial", data=df)
library(car)
linearHypothesis(fit, c("V1-V2", "V2-V3"), c(0,0))
################
Linear hypothesis test
Hypothesis:
V1 - V2 = 0
V2 - V3 = 0
Model 1: restricted model
Model 2: highlow ~ V1 + V2 + V3 + V4 + V5 + V6 + V7 + V8 + V9 + V10
Res.Df Df Chisq Pr(>Chisq)
1 991
2 989 2 0.2761 0.871
我有 运行 个 GLM 二项式模型
fit <- glm(highlow ~ V1 + V2 + V3 + V4 + V5 + V6 + V7 + V8 + V9 + V10,
family="binomial")
为了检验 V1 = V2 的原假设,我使用了以下代码。
glht.mod <- glht(fit, linfct = c("V1 - V2 = 0"))
summary(glht.mod)
我的问题是我可以检验是否 V1 = V2 = V3(所有三个系数都相等的零假设 - 请注意,这与在单独的迭代中检验 V1 = V2 和 V2 = V3 是否相同)?
如果有任何帮助,我可以使用以下代码在 SAS 中实现此目的
proc logistic;
model highlow = V1 V2 V3 V4 V5 V6 V7 V8 V9 V10;
test1: V1 = V2;
test2: V1 = V2 = V3;
run;
您的问题的可能解决方案:
set.seed(1)
n <- 1000
highlow <- factor(runif(n)>0.5)
X <- matrix(rnorm(n*10),nrow=n)
df <- data.frame(highlow, X)
names(df) <- c("highlow", paste("V",1:10,sep=""))
fit <- glm(highlow ~ V1 + V2 + V3 + V4 + V5 + V6 + V7 + V8 + V9 + V10,
family="binomial", data=df)
library(car)
linearHypothesis(fit, c("V1-V2", "V2-V3"), c(0,0))
################
Linear hypothesis test
Hypothesis:
V1 - V2 = 0
V2 - V3 = 0
Model 1: restricted model
Model 2: highlow ~ V1 + V2 + V3 + V4 + V5 + V6 + V7 + V8 + V9 + V10
Res.Df Df Chisq Pr(>Chisq)
1 991
2 989 2 0.2761 0.871