找出两组之间是否存在差异:Logistic回归与t检验

时间:2017-11-30 14:12:54

标签: r statistics regression logistic-regression hypothesis-test

为了找出两组之间是否存在任何平均差异,我们使用如下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

0 个答案:

没有答案