我在R中遇到了一个问题并且不太确定它发生了什么。当我对相同的变量运行回归和t.test
时,我发现t.test
正在减少~100个参与者(t检验的DF为283.93,回归的DF为382),这让我与众不同p值。但是,如果我为整个样本分别计算平均值,它们与在t检验中显示的相同。
任何人都可以解释可能发生的事情吗?下面是回归和t检验的代码和输出。请注意,DV是1到7变量,IV是1/0虚拟变量。
回归输出
Call:
lm(formula = confident ~ get.surgery, data = d)
Residuals:
Min 1Q Median 3Q Max
-4.2989 -0.7767 0.2233 0.7011 1.7011
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.29893 0.07714 68.692 < 2e-16 ***
get.surgery 0.47777 0.14895 3.208 0.00145 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 1.293 on 382 degrees of freedom
Multiple R-squared: 0.02623, Adjusted R-squared: 0.02368
F-statistic: 10.29 on 1 and 382 DF, p-value: 0.001451
和t检验
t.test(confident ~ get.surgery, data = d)
Welch Two Sample t-test
data: confident by get.surgery
t = -3.6106, df = 233.93, p-value = 0.0003737
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.7384624 -0.2170709
sample estimates:
mean in group 0 mean in group 1
5.298932 5.776699
答案 0 :(得分:1)
我认为这可能是一个汇集的差异问题。尝试使用
进行t.test var.equal = TRUE
(默认为FALSE),看看是否有帮助。