1

为了确定两组之间的均值是否存在差异,我们使用如下 t 检验。我使用 mtcars 数据集。

df<-mtcars %>% dplyr::select(hp, vs)
t.test(hp~vs, data=df)
    Welch Two Sample t-test

data:  hp by vs
t = 6.2908, df = 23.561, p-value = 1.82e-06
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
  66.06161 130.66854
sample estimates:
mean in group 0 mean in group 1 
      189.72222        91.35714 

我的问题是如果我使用逻辑回归怎么办?p值不同。为了实现相同的目标,如果我使用逻辑回归与 t.test 有什么区别吗?有人可以澄清一下吗?

summary(glm(vs~hp, data=df, family='binomial'))
Call:
glm(formula = vs ~ hp, family = "binomial", data = df)

Deviance Residuals: 
     Min        1Q    Median        3Q       Max  
-2.12148  -0.20302  -0.01598   0.51173   1.20083  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)   
(Intercept)  8.37802    3.21593   2.605  0.00918 **
hp          -0.06856    0.02740  -2.502  0.01234 * 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 43.860  on 31  degrees of freedom
Residual deviance: 16.838  on 30  degrees of freedom
AIC: 20.838

Number of Fisher Scoring iterations: 7
4

0 回答 0