[英]linearHypothesis equivalent for ols command (rms package) in R
I am trying to use "linearHypothesis" function from "car" package to test coefficients of a model estimated with "ols" from "rms" package. 我试图使用“car”包中的“linearHypothesis”函数来测试从“rms”包中用“ols”估计的模型的系数。 The function works with "lrm" objects but not with "ols" objects.
该函数适用于“lrm”对象,但不适用于“ols”对象。 Have you got any alternatives?
你有其他选择吗? I know that using "lm" would sort the issue but I want to use "ols" since it is easier getting clustered standard errors there.
我知道使用“lm”会对问题进行排序,但我想使用“ols”,因为它更容易在那里获得集群标准错误。
You can use glht
from the multcomp
package. 您可以使用
multcomp
包中的glht
。
library(rms)
library(multcomp)
d <- datadist(swiss); options(datadist="d")
fit <- ols(Fertility ~ ., data = swiss)
summary(fit)
test <- glht(fit, linfct = "Agriculture = 0")
summary(test)
# Fit: ols(formula = Fertility ~ ., data = swiss, x = TRUE)
#
# Linear Hypotheses:
# Estimate Std. Error z value Pr(>|z|)
# Agriculture == 0 -0.1721 0.0703 -2.448 0.0144 *
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.