一个愚蠢的例子。
x1 <- as.factor(c(rep("dog", 3), rep("cat", 3), rep("mouse", 3)))
x2 <- as.factor(rep(c("happy", "sad", "angry"), 3))
x3 <- rnorm(9, 0, 1) + runif(9, 3, 5)
y <- rnorm(9, 10, 2)
Call:
lm(formula = y ~ x1 + x2 + x3)
Residuals:
1 2 3 4 5 6 7 8 9
-1.57949 1.51090 0.06859 1.59378 -2.50472 0.91094 -0.01429 0.99383 -0.97953
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 19.69066 6.98359 2.820 0.0668 .
x1dog -5.89792 3.40777 -1.731 0.1819
x1mouse -2.05016 3.32847 -0.616 0.5815
x2happy 1.57757 1.99707 0.790 0.4872
x2sad -0.02729 2.09737 -0.013 0.9904
x3 -1.83281 1.19873 -1.529 0.2237
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 2.336 on 3 degrees of freedom
Multiple R-squared: 0.6874, Adjusted R-squared: 0.1664
F-statistic: 1.319 on 5 and 3 DF, p-value: 0.4362
假设我想知道“快乐狗”对 y 的边际效应。我会添加x1dogand x2happy,然后说类似“与愤怒的猫相比,快乐的狗对 y 的边际效应为 -4.32”。
我的问题是,我会对这个估计给出什么标准误差?我认为我不应该只添加两个相应的 SE。方法是什么?
谢谢!