【推导结果】如何得到 回归均方误差 & 估计系数的标准误

对线性回归模型系数标准差标准误的理解

1.生成数据

yxe
3.610.63
3.42-1.38
7.631.01
7.44-1.01
11.651.38
11.46-0.63

在这里插入图片描述

2.回归

y = β 0 + β 1 x + ϵ y = \beta_{0}+\beta_{1}x+\epsilon y=β0+β1x+ϵ

y i = β 0 + β 1 x i + e i y_{i}=\beta_{0}+\beta_{1} x_{i}+e_{i} yi=β0+β1xi+ei

reg y x

      Source |       SS           df       MS      Number of obs   =         6
-------------+----------------------------------   F(1, 4)         =     34.60
       Model |   57.422285         1   57.422285   Prob > F        =    0.0042
    Residual |  6.63771505         4  1.65942876   R-squared       =    0.8964
-------------+----------------------------------   Adj R-squared   =    0.8705
       Total |  64.0600001         5      12.812   Root MSE        =    1.2882

------------------------------------------------------------------------------
           y | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
-------------+----------------------------------------------------------------
           x |   1.811429   .3079359     5.88   0.004     .9564615    2.666396
       _cons |       1.16   1.199238     0.97   0.388    -2.169618    4.489618
------------------------------------------------------------------------------

3.计算回归的标准误差

(1)SSE\SSR\SST

S S E SSE SSE: Sum of Squares Error,
S S E = ∑ i = 1 n ( y i ^ − y i ) 2 = ∑ i = 1 n ( e i − e ˉ ) 2 SSE= \sum_{i=1}^{n}(\hat{y_{i}}-y_{i})^2 = \sum_{i=1}^{n}(e_{i}-\bar{e})^2 SSE=i=1n(yi^yi)2=i=1n(eieˉ)2
在本示例中, S S E = ( 3.6 − 2.97 ) 2 + ( 3.4 − 4.78 ) 2 + ( 7.6 − 6.95 ) 2 + ( 7.4 − 8.41 ) 2 + ( 11.6 − 10.22 ) 2 + ( 11.4 − 12.03 ) 2 = 6.637713 SSE=(3.6-2.97)^2+(3.4-4.78)^2+(7.6-6.95)^2+(7.4-8.41)^2+(11.6-10.22)^2+(11.4-12.03)^2 = 6.637713 SSE=(3.62.97)2+(3.44.78)2+(7.66.95)2+(7.48.41)2+(11.610.22)2+(11.412.03)2=6.637713

S S R SSR SSR: Sum of Squares of the Regression
S S R = ∑ i = 1 n ( y i ^ − y ˉ ) 2 SSR= \sum_{i=1}^{n}(\hat{y_{i}}-\bar{y})^2 SSR=i=1n(yi^yˉ)2
S S T SST SST: Total Sum of Squares
S S T = ∑ i = 1 n ( y i − y ˉ ) 2 SST= \sum_{i=1}^{n}(y_{i}-\bar{y})^2 SST=i=1n(yiyˉ)2

(2)MSE

回归的标准误差为:
s 2 = M S E = S S E n − K = ∑ i = 1 n ( e i − e ˉ ) 2 n − K s^{2}=MSE=\frac{SSE}{n-K}=\frac{\sum_{i=1}^{n}(e_{i}-\bar{e})^2}{n-K} s2=MSE=nKSSE=nKi=1n(eieˉ)2

s = M S E s=\sqrt{MSE} s=MSE

s 2 = 6.637713 6 − 2 = 1.6594282 ;         s = 1.288188 s^2 = \frac{6.637713}{6 - 2}=1.6594282; \ \ \ \ \ \ \ s=1.288188 s2=626.637713=1.6594282;       s=1.288188

(3)SE

S β ^ = s 2 ∑ i = 1 n ( x i − x ˉ ) S_{\hat{\beta}} = \sqrt{\frac{s^2}{{\sum_{i=1}^{n}(x_{i}-\bar{x})}}} Sβ^=i=1n(xixˉ)s2

S β ^ = 1 n − 2 ∑ i = 1 n e 2 ^ ∑ i = 1 n ( x i − x ˉ ) S_{\hat{\beta}} = \sqrt{\frac{\frac{1}{n-2}\sum_{i=1}^{n} \hat{e^{2}}}{{\sum_{i=1}^{n}(x_{i}-\bar{x})}}} Sβ^=i=1n(xixˉ)n21i=1ne2^

S β ^ = 1 4 × 6.637713 ( 1 − 3.5 ) 2 + ( 2 − 3.5 ) 2 + ( 3 − 3.5 ) 2 + ( 4 − 3.5 ) 2 + ( 5 − 3.5 ) 2 + ( 6 − 3.5 ) 2 S_{\hat{\beta}} = \sqrt{\frac{\frac{1}{4} \times 6.637713}{(1-3.5)^2+(2-3.5)^2+(3-3.5)^2+(4-3.5)^2+(5-3.5)^2+(6-3.5)^2}} Sβ^=(13.5)2+(23.5)2+(33.5)2+(43.5)2+(53.5)2+(63.5)241×6.637713

SE为何会很大?

  • 样本少,分母可能大
  • 极端值多
  • X没有足够的variation

Appendix

1. simulation code
clear 
set obs 6
gen y = 3.6 in 1 
replace y = 3.4 in 2 
replace y = 7.6 in 3
replace y = 7.4 in 4
replace y = 11.6 in 5
replace y = 11.4 in 6
gen x = _n

reg y x
predict xb

gen e = y - xb
format %9.2f xb 
format %9.2f e 
egen addtext_mean = rowmean(y xb)
forv i = 1/6{
	su add in `i',d
	global y`i' = r(mean)
	su e in `i',d
	global e`i' = r(mean)
}

tw (scatter y x, mlab(y) mlabp(1)) /// 
   (lfit y x) /// 
   (scatter xb x, mlab(xb) mlabp(1)) /// 
   (rspike y xb x) ,legend(off) /// 
   text($y1 0.9 "0.63",size(vsmall) color(red)) /// 
   text($y2 1.9 "-1.38",size(vsmall) color(red)) /// 
   text($y3 2.9 "1.01",size(vsmall) color(red)) /// 
   text($y4 3.9 "-1.01",size(vsmall) color(red)) /// 
   text($y5 4.9 "1.38",size(vsmall) color(red)) /// 
   text($y6 5.9 "-0.63",size(vsmall) color(red)) 
2.序列相关 同方差 or 异方差

对于①参数线性②不存在“严格多重共线性”③随机抽样④严格外生性⑤“球形扰动项”(条件同方差+不存在自相关)五个假定均能够满足时

OLS估计量为BLUE,最优无偏线性估计量

此时,x的协方差矩阵为:
V a r ( β 1 ^ ∣ x ) = V a r ( β 1 + ∑ ( x i − x ˉ ) e i ∑ ( x i − x ˉ ) ∣ x ) Var(\hat{\beta_{1}}|x)=Var({\beta_{1}+\frac{\sum(x_{i}-\bar{x})e_{i}}{\sum(x_{i}-\bar{x})}}|x) Var(β1^x)=Var(β1+(xixˉ)(xixˉ)eix)

V a r ( β 1 ^ ∣ x ) = V a r ( ∑ ( x i − x ˉ ) e i ∣ x ) [ ∑ ( x i − x ˉ ) 2 ] 2 Var(\hat{\beta_{1}}|x)=\frac{Var(\sum(x_{i}-\bar{x})e_{i}|x)}{[\sum(x_{i}-\bar{x})^2]^2} Var(β1^x)=[(xixˉ)2]2Var((xixˉ)eix)

  • 倘若序列无关,那么和的方差即等价于方差的和,假设 V a r ( e i ∣ x ) = σ 2 Var(e_i|x)=\sigma^2 Var(eix)=σ2

KaTeX parse error: Unknown column alignment: * at position 71: … \begin{array}{*̲*lr**} …

  • 序列相关:

σ 2 ^ = ∑ e i 2 n − k − 1 \hat{\sigma^2}=\frac{\sum e_{i}^2}{n-k-1} σ2^=nk1ei2

3.calculate SE in matlab
sqrt(inv(X'*X)*1.6594282)
  • 19
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mengke25

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值