使用summary
:
indep <- 1:10
set.seed(42)
dep <- indep/2+5+rnorm(10)
reg = lm(dep ~ indep)
library(multcomp)
htest = glht(reg,linfct = c("indep = 0.5"))
summary(htest)
#Simultaneous Tests for General Linear Hypotheses
#
#Fit: lm(formula = dep ~ indep)
#
#Linear Hypotheses:
# Estimate Std. Error t value Pr(>|t|)
#indep == 0.5 0.53040 0.09697 0.313 0.762
#(Adjusted p values reported -- single-step method)
您可以像这样提取值:
res <- summary(htest)
res$test[-(1:2)]
# $coefficients
# indep
# 0.5303967
#
# $sigma
# indep
# 0.09696568
#
# $tstat
# indep
# 0.3134785
#
# $pvalues
# [1] 0.7619346
# attr(,"error")
# [1] 0
#
# $type
# [1] "single-step"