点到直线距离估计线性回归参数
文章目录
- 点到直线距离估计线性回归参数
- @[toc]
- 1 推导
- 2 模拟
文章目录
- 点到直线距离估计线性回归参数
- @[toc]
- 1 推导
- 2 模拟
1 推导
普通最小二乘法(OLS)估计线性回归方程的参数要求残差平方和最小,通过优化方法计算出各参数的估计量。其中残差
e
i
=
y
i
−
β
0
−
β
1
x
i
e_i=y_i-\beta_0-\beta_1x_i
ei=yi−β0−β1xi
在下图中即有向线段AB,该线段垂直于横轴。使用OLS方法计算得到估计结果
β
1
=
∑
i
=
1
n
(
x
i
−
x
ˉ
)
(
y
i
−
y
ˉ
)
∑
i
=
1
n
(
x
i
−
x
ˉ
)
2
,
β
0
=
y
ˉ
−
β
1
x
ˉ
\beta_1 = \dfrac{\sum_{i=1}^n(x_i-\bar{x})(y_i-\bar{y})}{\sum_{i=1}^n(x_i-\bar{x})^2},\beta_0=\bar{y}-\beta_1 \bar{x}
β1=∑i=1n(xi−xˉ)2∑i=1n(xi−xˉ)(yi−yˉ),β0=yˉ−β1xˉ
现在,我们换一种思考方式,即通过点到直线的距离最小进而估计参数。在下图中,计算所有样本点到直线
L
L
L的距离,其中
L
L
L就是预期估计的那条直线(从事后角度看)。根据点到直线距离公式,对于
∀
i
=
1
,
2
,
…
n
\forall i=1,2,\dots n
∀i=1,2,…n,
d
i
=
∣
y
i
−
β
0
−
β
1
x
i
∣
1
+
β
1
2
d_i = \dfrac{|y_i-\beta_0-\beta_1x_i|}{\sqrt{1+\beta_1^2}}
di=1+β12∣yi−β0−β1xi∣
目标函数与OLS方法类似,即
min
∑
i
=
1
n
d
i
2
=
min
∑
i
=
1
n
(
y
i
−
β
0
−
β
1
x
i
)
2
1
+
β
1
2
\min \sum_{i=1}^n d_i^2 = \min \sum_{i=1}^n \dfrac{(y_i-\beta_0-\beta_1x_i)^2}{1+\beta_1^2}
mini=1∑ndi2=mini=1∑n1+β12(yi−β0−β1xi)2
令
Q
(
β
1
,
β
2
)
Q(\beta_1,\beta_2)
Q(β1,β2)是关于参数
β
1
,
β
2
\beta_1,\beta_2
β1,β2的函数,使用高等数学知识,分别用
Q
Q
Q对
β
1
,
β
2
\beta_1,\beta_2
β1,β2偏导
∂
Q
∂
β
0
=
−
∑
i
=
1
n
2
(
y
i
−
β
0
−
β
1
x
i
)
1
+
β
1
2
=
0
\dfrac{\partial{Q}}{\partial{\beta_0}} = -\sum_{i=1}^n \dfrac{2(y_i-\beta_0-\beta_1x_i)}{1+\beta_1^2}=0
∂β0∂Q=−i=1∑n1+β122(yi−β0−β1xi)=0
与OLS方法一样,使用点到直线的距离也通过样本均值点
(
x
ˉ
,
y
ˉ
)
(\bar{x},\bar{y})
(xˉ,yˉ)
∑
i
=
1
n
(
y
i
−
β
0
−
β
1
x
i
)
=
∑
y
i
−
n
β
0
−
β
1
∑
x
i
=
0
\sum_{i=1}^n(y_i-\beta_0-\beta_1x_i)=\sum y_i-n\beta_0-\beta_1\sum x_i=0
i=1∑n(yi−β0−β1xi)=∑yi−nβ0−β1∑xi=0
于是
β
0
=
y
ˉ
−
β
1
x
ˉ
\beta_0 = \bar{y}-\beta_1\bar{x}
β0=yˉ−β1xˉ
接下来估计
β
1
\beta_1
β1,推导过程有点复杂,对
β
1
\beta_1
β1求偏导,
∂
Q
∂
β
1
=
∑
i
=
1
n
−
2
(
y
i
−
β
0
−
β
1
x
i
)
x
i
(
1
+
β
1
2
)
−
2
β
1
(
y
i
−
β
0
−
β
1
x
i
)
2
(
1
+
β
1
2
)
2
=
0
\dfrac{\partial{Q}}{\partial{\beta_1}} = \sum_{i=1}^n\dfrac{-2(y_i-\beta_0-\beta_1x_i)x_i(1+\beta_1^2)-2\beta_1(y_i-\beta_0-\beta_1x_i)^2}{(1+\beta_1^2)^2}=0
∂β1∂Q=i=1∑n(1+β12)2−2(yi−β0−β1xi)xi(1+β12)−2β1(yi−β0−β1xi)2=0
显然
(
1
+
β
1
2
)
2
≠
0
(1+\beta_1^2)^2\neq 0
(1+β12)2=0,于是
∑
i
=
1
n
[
−
2
x
i
e
i
(
1
+
β
1
2
)
−
2
β
1
e
i
2
]
=
0
\sum_{i=1}^n[-2x_ie_i(1+\beta_1^2)-2\beta_1e_i^2]=0
i=1∑n[−2xiei(1+β12)−2β1ei2]=0
这里用
e
i
e_i
ei代替
y
i
−
β
0
−
β
1
x
i
y_i-\beta_0-\beta_1x_i
yi−β0−β1xi,避免繁琐。继续展开化简
(
1
+
β
1
2
)
∑
i
=
1
n
x
i
e
i
+
β
1
∑
i
=
1
n
e
i
2
=
0
(1+\beta_1^2)\sum_{i=1}^n x_ie_i+\beta_1\sum_{i=1}^ne_i^2=0
(1+β12)i=1∑nxiei+β1i=1∑nei2=0
将
e
i
e_i
ei还原为
y
i
−
β
0
−
β
1
x
i
y_i-\beta_0-\beta_1x_i
yi−β0−β1xi得到
(
1
+
β
1
2
)
∑
i
=
1
n
x
i
(
y
i
−
β
0
−
β
1
x
i
)
+
β
1
∑
i
=
1
n
(
y
i
−
β
0
−
β
1
x
i
)
2
=
0
(1+\beta_1^2)\sum_{i=1}^n x_i(y_i-\beta_0-\beta_1x_i)+\beta_1\sum_{i=1}^n(y_i-\beta_0-\beta_1x_i)^2=0
(1+β12)i=1∑nxi(yi−β0−β1xi)+β1i=1∑n(yi−β0−β1xi)2=0
即
(
1
+
β
1
2
)
∑
i
=
1
n
(
x
i
y
i
−
β
0
x
i
−
β
1
x
i
2
)
+
β
1
∑
i
=
1
n
(
y
i
−
β
0
−
β
1
x
i
)
2
=
0
(1+\beta_1^2)\sum_{i=1}^n (x_iy_i-\beta_0x_i-\beta_1x_i^2)+\beta_1\sum_{i=1}^n(y_i-\beta_0-\beta_1x_i)^2=0
(1+β12)i=1∑n(xiyi−β0xi−β1xi2)+β1i=1∑n(yi−β0−β1xi)2=0
将
β
0
=
y
ˉ
−
β
1
x
ˉ
\beta_0 = \bar{y}-\beta_1\bar{x}
β0=yˉ−β1xˉ带入上式
(
1
+
β
1
2
)
(
∑
i
=
1
n
x
i
y
i
−
(
y
ˉ
−
β
1
x
ˉ
)
∑
i
=
1
n
x
i
−
β
1
∑
i
=
1
n
x
i
2
)
+
β
1
∑
i
=
1
n
(
y
i
−
(
y
ˉ
−
β
1
x
ˉ
)
−
β
1
x
i
)
2
=
0
(1+\beta_1^2)(\sum_{i=1}^n x_iy_i-( \bar{y}-\beta_1\bar{x})\sum_{i=1}^n x_i-\beta_1\sum_{i=1}^nx_i^2)+\beta_1\sum_{i=1}^n(y_i-(\bar{y}-\beta_1\bar{x})-\beta_1x_i)^2=0
(1+β12)(i=1∑nxiyi−(yˉ−β1xˉ)i=1∑nxi−β1i=1∑nxi2)+β1i=1∑n(yi−(yˉ−β1xˉ)−β1xi)2=0
接下来的任务就是求解
β
1
\beta_1
β1。过程有点复杂,先展开第一部分
=
(
1
+
β
1
2
)
(
∑
i
=
1
n
x
i
y
i
−
(
y
ˉ
−
β
1
x
ˉ
)
∑
i
=
1
n
x
i
−
β
1
∑
i
=
1
n
x
i
2
)
=
(
1
+
β
1
2
)
(
∑
i
=
1
n
x
i
y
i
−
y
ˉ
∑
i
=
1
n
x
i
−
β
1
x
ˉ
∑
i
=
1
n
x
i
−
β
1
∑
i
=
1
n
x
i
2
)
=
∑
i
=
1
n
x
i
y
i
−
y
ˉ
∑
i
=
1
n
x
i
−
β
1
x
ˉ
∑
i
=
1
n
x
i
−
β
1
∑
i
=
1
n
x
i
2
+
β
1
2
∑
i
=
1
n
x
i
y
i
−
β
1
2
y
ˉ
∑
i
=
1
n
x
i
−
β
1
3
x
ˉ
∑
i
=
1
n
x
i
−
β
1
3
∑
i
=
1
n
x
i
2
=
∑
i
=
1
n
x
i
y
i
−
n
x
ˉ
y
ˉ
+
n
β
1
x
ˉ
2
−
β
1
∑
i
=
1
n
x
i
2
+
β
1
2
∑
i
=
1
n
x
i
y
i
−
n
β
1
2
x
ˉ
y
ˉ
+
n
β
1
3
x
ˉ
2
−
β
1
3
∑
i
=
1
n
x
i
2
\begin{aligned} &=(1+\beta_1^2)(\sum_{i=1}^n x_iy_i-( \bar{y}-\beta_1\bar{x})\sum_{i=1}^n x_i-\beta_1\sum_{i=1}^nx_i^2)\\ &=(1+\beta_1^2)(\sum_{i=1}^n x_iy_i-\bar{y}\sum_{i=1}^n x_i-\beta_1\bar{x}\sum_{i=1}^n x_i-\beta_1\sum_{i=1}^nx_i^2)\\ &=\sum_{i=1}^n x_iy_i-\bar{y}\sum_{i=1}^n x_i-\beta_1\bar{x}\sum_{i=1}^n x_i-\beta_1\sum_{i=1}^nx_i^2+\beta_1^2\sum_{i=1}^n x_iy_i-\beta_1^2\bar{y}\sum_{i=1}^n x_i-\beta_1^3\bar{x}\sum_{i=1}^n x_i-\beta_1^3\sum_{i=1}^nx_i^2\\ &=\sum_{i=1}^n x_iy_i-n\bar{x}\bar{y}+n\beta_1\bar{x}^2-\beta_1\sum_{i=1}^nx_i^2 +\beta_1^2\sum_{i=1}^n x_iy_i-n\beta_1^2\bar{x}\bar{y}+n\beta_1^3\bar{x}^2-\beta_1^3\sum_{i=1}^nx_i^2 \end{aligned}
=(1+β12)(i=1∑nxiyi−(yˉ−β1xˉ)i=1∑nxi−β1i=1∑nxi2)=(1+β12)(i=1∑nxiyi−yˉi=1∑nxi−β1xˉi=1∑nxi−β1i=1∑nxi2)=i=1∑nxiyi−yˉi=1∑nxi−β1xˉi=1∑nxi−β1i=1∑nxi2+β12i=1∑nxiyi−β12yˉi=1∑nxi−β13xˉi=1∑nxi−β13i=1∑nxi2=i=1∑nxiyi−nxˉyˉ+nβ1xˉ2−β1i=1∑nxi2+β12i=1∑nxiyi−nβ12xˉyˉ+nβ13xˉ2−β13i=1∑nxi2
展开第二部分
=
β
1
∑
i
=
1
n
(
y
i
−
(
y
ˉ
−
β
1
x
ˉ
)
−
β
1
x
i
)
2
=
β
1
∑
i
=
1
n
(
(
y
i
−
y
ˉ
)
−
β
1
(
x
i
−
x
ˉ
)
)
2
=
β
1
∑
i
=
1
n
(
(
y
i
−
y
ˉ
)
2
+
β
1
2
(
x
i
−
x
ˉ
)
2
−
2
β
1
(
x
i
−
x
ˉ
)
(
y
i
−
y
ˉ
)
)
=
β
1
(
∑
i
=
1
n
(
y
i
−
y
ˉ
)
2
+
β
1
2
∑
i
=
1
n
(
x
i
−
x
ˉ
)
2
−
2
β
1
∑
i
=
1
n
(
x
i
−
x
ˉ
)
(
y
i
−
y
ˉ
)
)
=
β
1
∑
i
=
1
n
(
y
i
−
y
ˉ
)
2
+
β
1
3
∑
i
=
1
n
(
x
i
−
x
ˉ
)
2
−
2
β
1
2
∑
i
=
1
n
(
x
i
−
x
ˉ
)
(
y
i
−
y
ˉ
)
=
β
1
(
∑
i
=
1
n
y
i
2
−
n
y
ˉ
2
)
+
β
1
3
(
∑
i
=
1
n
x
i
2
−
n
x
ˉ
2
)
−
2
β
1
2
(
∑
i
=
1
n
x
i
y
i
−
n
x
ˉ
y
ˉ
)
=
β
1
∑
i
=
1
n
y
i
2
−
n
β
1
y
ˉ
2
+
β
1
3
∑
i
=
1
n
x
i
2
−
n
β
1
3
x
ˉ
2
−
2
β
1
2
∑
i
=
1
n
x
i
y
i
+
2
n
β
1
2
x
ˉ
y
ˉ
\begin{aligned} &=\beta_1\sum_{i=1}^n(y_i-(\bar{y}-\beta_1\bar{x})-\beta_1x_i)^2\\ &=\beta_1\sum_{i=1}^n((y_i-\bar{y})-\beta_1(x_i-\bar{x}))^2\\ &=\beta_1\sum_{i=1}^n((y_i-\bar{y})^2+\beta_1^2(x_i-\bar{x})^2-2\beta_1(x_i-\bar{x})(y_i-\bar{y}))\\ &=\beta_1 ( \sum_{i=1}^n(y_i-\bar{y})^2+\beta_1^2\sum_{i=1}^n(x_i-\bar{x})^2-2\beta_1\sum_{i=1}^n(x_i-\bar{x})(y_i-\bar{y}))\\ & =\beta_1 \sum_{i=1}^n(y_i-\bar{y})^2+\beta_1^3\sum_{i=1}^n(x_i-\bar{x})^2-2\beta_1^2\sum_{i=1}^n(x_i-\bar{x})(y_i-\bar{y})\\ & =\beta_1 (\sum_{i=1}^ny_i^2-n\bar{y}^2)+\beta_1^3(\sum_{i=1}^nx_i^2-n\bar{x}^2)-2\beta_1^2(\sum_{i=1}^n x_iy_i-n\bar{x}\bar{y})\\ & =\beta_1 \sum_{i=1}^ny_i^2-n\beta_1\bar{y}^2+\beta_1^3\sum_{i=1}^nx_i^2-n\beta_1^3\bar{x}^2-2\beta_1^2\sum_{i=1}^n x_iy_i+2n\beta_1^2\bar{x}\bar{y} \end{aligned}
=β1i=1∑n(yi−(yˉ−β1xˉ)−β1xi)2=β1i=1∑n((yi−yˉ)−β1(xi−xˉ))2=β1i=1∑n((yi−yˉ)2+β12(xi−xˉ)2−2β1(xi−xˉ)(yi−yˉ))=β1(i=1∑n(yi−yˉ)2+β12i=1∑n(xi−xˉ)2−2β1i=1∑n(xi−xˉ)(yi−yˉ))=β1i=1∑n(yi−yˉ)2+β13i=1∑n(xi−xˉ)2−2β12i=1∑n(xi−xˉ)(yi−yˉ)=β1(i=1∑nyi2−nyˉ2)+β13(i=1∑nxi2−nxˉ2)−2β12(i=1∑nxiyi−nxˉyˉ)=β1i=1∑nyi2−nβ1yˉ2+β13i=1∑nxi2−nβ13xˉ2−2β12i=1∑nxiyi+2nβ12xˉyˉ
于是
(
1
+
β
1
2
)
(
∑
i
=
1
n
x
i
y
i
−
(
y
ˉ
−
β
1
x
ˉ
)
∑
i
=
1
n
x
i
−
β
1
∑
i
=
1
n
x
i
2
)
+
β
1
∑
i
=
1
n
(
y
i
−
(
y
ˉ
−
β
1
x
ˉ
)
−
β
1
x
i
)
2
=
∑
i
=
1
n
x
i
y
i
−
n
x
ˉ
y
ˉ
+
n
β
1
x
ˉ
2
−
β
1
∑
i
=
1
n
x
i
2
+
β
1
2
∑
i
=
1
n
x
i
y
i
−
n
β
1
2
x
ˉ
y
ˉ
+
n
β
1
3
x
ˉ
2
−
β
1
3
∑
i
=
1
n
x
i
2
+
β
1
∑
i
=
1
n
y
i
2
−
n
β
1
y
ˉ
2
+
β
1
3
∑
i
=
1
n
x
i
2
−
n
β
1
3
x
ˉ
2
−
2
β
1
2
∑
i
=
1
n
x
i
y
i
+
2
n
β
1
2
x
ˉ
y
ˉ
\begin{aligned} &(1+\beta_1^2)(\sum_{i=1}^n x_iy_i-( \bar{y}-\beta_1\bar{x})\sum_{i=1}^n x_i-\beta_1\sum_{i=1}^nx_i^2)+\beta_1\sum_{i=1}^n(y_i-(\bar{y}-\beta_1\bar{x})-\beta_1x_i)^2 \\ =& \sum_{i=1}^n x_iy_i-n\bar{x}\bar{y}+n\beta_1\bar{x}^2-\beta_1\sum_{i=1}^nx_i^2 +\beta_1^2\sum_{i=1}^n x_iy_i-n\beta_1^2\bar{x}\bar{y}+n\beta_1^3\bar{x}^2-\beta_1^3\sum_{i=1}^nx_i^2 \\ +& \beta_1 \sum_{i=1}^ny_i^2-n\beta_1\bar{y}^2+\beta_1^3\sum_{i=1}^nx_i^2-n\beta_1^3\bar{x}^2-2\beta_1^2\sum_{i=1}^n x_iy_i+2n\beta_1^2\bar{x}\bar{y}\\ \end{aligned}
=+(1+β12)(i=1∑nxiyi−(yˉ−β1xˉ)i=1∑nxi−β1i=1∑nxi2)+β1i=1∑n(yi−(yˉ−β1xˉ)−β1xi)2i=1∑nxiyi−nxˉyˉ+nβ1xˉ2−β1i=1∑nxi2+β12i=1∑nxiyi−nβ12xˉyˉ+nβ13xˉ2−β13i=1∑nxi2β1i=1∑nyi2−nβ1yˉ2+β13i=1∑nxi2−nβ13xˉ2−2β12i=1∑nxiyi+2nβ12xˉyˉ
合并同类项,
β
1
\beta_1
β1的三次项抵消,得到
n
β
1
2
x
ˉ
y
ˉ
−
β
1
2
∑
i
=
1
n
x
i
y
i
+
n
β
1
x
ˉ
2
−
n
β
1
y
ˉ
2
−
β
1
∑
i
=
1
n
x
i
2
+
β
1
∑
i
=
1
n
y
i
2
+
∑
i
=
1
n
x
i
y
i
−
n
x
ˉ
y
ˉ
=
β
1
2
(
n
x
ˉ
y
ˉ
−
∑
i
=
1
n
x
i
y
i
)
+
β
1
(
n
x
ˉ
2
−
n
y
ˉ
2
)
−
β
1
(
∑
i
=
1
n
x
i
2
−
∑
i
=
1
n
y
i
2
)
+
∑
i
=
1
n
x
i
y
i
−
n
x
ˉ
y
ˉ
=
−
β
1
2
(
∑
i
=
1
n
x
i
y
i
−
n
x
ˉ
y
ˉ
)
−
β
1
(
(
∑
i
=
1
n
x
i
2
−
n
x
ˉ
2
)
−
(
∑
i
=
1
n
y
i
2
−
n
y
ˉ
2
)
)
+
∑
i
=
1
n
x
i
y
i
−
n
x
ˉ
y
ˉ
=
−
s
x
y
β
1
2
−
β
1
(
s
x
2
−
s
y
2
)
+
s
x
y
=
0
\begin{aligned} & n\beta_1^2\bar{x}\bar{y}-\beta_1^2\sum_{i=1}^n x_iy_i+n\beta_1\bar{x}^2-n\beta_1\bar{y}^2-\beta_1\sum_{i=1}^nx_i^2+\beta_1 \sum_{i=1}^ny_i^2+\sum_{i=1}^n x_iy_i-n\bar{x}\bar{y}\\ =&\beta_1^2(n\bar{x}\bar{y}-\sum_{i=1}^n x_iy_i)+ \beta_1(n\bar{x}^2-n\bar{y}^2)-\beta_1(\sum_{i=1}^nx_i^2- \sum_{i=1}^ny_i^2)+\sum_{i=1}^n x_iy_i-n\bar{x}\bar{y}\\ =&-\beta_1^2(\sum_{i=1}^n x_iy_i-n\bar{x}\bar{y})- \beta_1((\sum_{i=1}^nx_i^2-n\bar{x}^2)-(\sum_{i=1}^ny_i^2-n\bar{y}^2))+\sum_{i=1}^n x_iy_i-n\bar{x}\bar{y}\\ =&-s_{xy}\beta_1^2- \beta_1(s_x^2-s_y^2)+s_{xy} =0\\ \end{aligned}
===nβ12xˉyˉ−β12i=1∑nxiyi+nβ1xˉ2−nβ1yˉ2−β1i=1∑nxi2+β1i=1∑nyi2+i=1∑nxiyi−nxˉyˉβ12(nxˉyˉ−i=1∑nxiyi)+β1(nxˉ2−nyˉ2)−β1(i=1∑nxi2−i=1∑nyi2)+i=1∑nxiyi−nxˉyˉ−β12(i=1∑nxiyi−nxˉyˉ)−β1((i=1∑nxi2−nxˉ2)−(i=1∑nyi2−nyˉ2))+i=1∑nxiyi−nxˉyˉ−sxyβ12−β1(sx2−sy2)+sxy=0
最后一步方程两边同除以
n
−
1
n-1
n−1得到样本协方差
s
x
y
s_{xy}
sxy和方差
s
x
2
,
s
y
2
s_x^2,s_y^2
sx2,sy2,其中
{
s
x
y
=
∑
(
x
i
−
x
ˉ
)
(
y
−
y
ˉ
)
=
∑
x
i
y
i
−
n
x
ˉ
y
ˉ
s
x
2
=
∑
(
x
i
−
x
ˉ
)
2
=
∑
x
i
2
−
n
x
ˉ
2
s
y
2
=
∑
(
y
i
−
y
ˉ
)
2
=
∑
y
i
2
−
n
y
ˉ
2
\left\{\begin{array}{l} s_{xy} = \sum(x_i-\bar{x})(y-\bar{y})=\sum x_iy_i-n\bar{x}\bar{y}\\ s_x^2 = \sum(x_i-\bar{x})^2= \sum x_i^2-n\bar{x}^2\\ s_y^2 = \sum(y_i-\bar{y})^2= \sum y_i^2-n\bar{y}^2\\ \end{array}\right.
⎩
⎨
⎧sxy=∑(xi−xˉ)(y−yˉ)=∑xiyi−nxˉyˉsx2=∑(xi−xˉ)2=∑xi2−nxˉ2sy2=∑(yi−yˉ)2=∑yi2−nyˉ2
最后整理得到关于参数
β
1
\beta_1
β1的一元二次方程,
−
s
x
y
β
1
2
+
(
s
y
2
−
s
x
2
)
β
1
+
s
x
y
=
0
-s_{xy}\beta_1^2+(s_y^2-s_x^2)\beta_1+s_{xy}=0
−sxyβ12+(sy2−sx2)β1+sxy=0
若
s
x
y
≠
0
s_{xy}\neq 0
sxy=0,即变量
x
,
y
x,y
x,y存在相关性,利用求根公式得到
β
1
1
=
(
s
y
2
−
s
x
2
)
+
(
s
y
2
−
s
x
2
)
2
+
4
s
x
y
2
2
s
x
y
β
1
2
=
(
s
y
2
−
s
x
2
)
−
(
s
y
2
−
s
x
2
)
2
+
4
s
x
y
2
2
s
x
y
\begin{aligned} &\beta_1^1 = \dfrac{(s_y^2-s_x^2)+\sqrt{(s_y^2-s_x^2)^2+4s_{xy}^2}}{2s_{xy}}\\ &\beta_1^2 = \dfrac{(s_y^2-s_x^2)-\sqrt{(s_y^2-s_x^2)^2+4s_{xy}^2}}{2s_{xy}} \end{aligned}
β11=2sxy(sy2−sx2)+(sy2−sx2)2+4sxy2β12=2sxy(sy2−sx2)−(sy2−sx2)2+4sxy2
其中判定式
Δ
≥
0
\Delta\ge0
Δ≥0,存在实数根。因为
(
s
y
2
−
s
x
2
)
≤
(
s
y
2
−
s
x
2
)
2
+
4
s
x
y
2
(s_y^2-s_x^2)\le\sqrt{(s_y^2-s_x^2)^2+4s_{xy}^2}
(sy2−sx2)≤(sy2−sx2)2+4sxy2恒成立,对于
β
1
2
\beta_1^2
β12,分子非正数,若斜率为正,则
s
x
y
<
0
s_{xy}<0
sxy<0,然而
s
x
y
s_{xy}
sxy表示变量
x
,
y
x,y
x,y的相关性,符号与
β
1
\beta_1
β1符号理论上保持一致,故舍去
β
1
\beta_1
β1。
推导仅供参考。反正写了好多草稿纸😂~~
2 模拟
下面使用R语言对上述方法进行模拟
beta1_new = numeric()
beta0_new = numeric()
x = rnorm(100,0,1)
for(i in 1:10000){
y = -2*x+1+rnorm(100,0,1)
sx = var(x)
sy = var(y)
sxy = cov(x,y)
beta1_new[i] = (sy-sx + sqrt((sx-sy)^2+4*sxy^2))/(2*sxy)
beta0_new[i] = mean(y)-beta1_new[i]*mean(x)
cat(i,"\n")
}
par(mfrow = c(1,2))
hist(beta0_new,main = paste("期望为:",mean(beta0_new)))
hist(beta1_new,main = paste("期望为:",mean(beta1_new)))
很遗憾,经过1万次模拟抽样,估计结构是有偏的,至于分布是否服从正态分布或 t t t分布需要进一步推导和证明😂。