0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

重回帰分析 補足メモ

Last updated at Posted at 2024-11-09

不偏分散

$X \in R^{n\times (p+1)}$は列フルランクより$rank(X)=p+1$.
正方行列のトレースは, 固有値の和に等しい.
$H$は冪等行列より, 固有値は $0$ または $1$.
$H$は対称行列より, 対角化可能.

以上の性質を用いると,
$rank(H) = p+1$ より, $H$の非ゼロ固有値の数は $p+1$個.
つまり, $H$ は $p+1$ 個の固有値 $1$ と $n-(p+1)$ 個の固有値 $0$ を対角成分にもつ対角行列として対角化できる. 
したがって, $tr(H) = p+1$.

\begin{align}
    ||\boldsymbol{y} - X\hat{\boldsymbol{\beta}}||^2 &= 
    ||I - X(X^TX)^{-1}X^T\boldsymbol{y}||^2 \\
    &= ||(I - H)\boldsymbol{y}||^2 \\
    &= \boldsymbol{y}^T(I - H)^T(I - H)\boldsymbol{y} \\
    &= \boldsymbol{y}^T(I - H)\boldsymbol{y} \\
    &= (X\boldsymbol{\beta} + \boldsymbol{\varepsilon})^T(I - H)(X\boldsymbol{\beta} + \boldsymbol{\varepsilon}) \\
    &= \boldsymbol{\beta}^TXX^T\boldsymbol{\beta} + \boldsymbol{\beta}X^T\boldsymbol{\varepsilon} - \boldsymbol{\beta}^TX^THX\boldsymbol{\beta} - \boldsymbol{\beta}^TX^TH\boldsymbol{\varepsilon}
    + \boldsymbol{\varepsilon}^T\boldsymbol{X}\boldsymbol{\beta} + \boldsymbol{\varepsilon}^T\boldsymbol{\varepsilon} - \boldsymbol{\varepsilon}^THX\boldsymbol{\beta} \\
    &= \boldsymbol{\beta}^TX^T\boldsymbol{\varepsilon} - \boldsymbol{\beta}^TX^TH\boldsymbol{\varepsilon} + \boldsymbol{\varepsilon}^T\boldsymbol{X}\boldsymbol{\beta} 
    + \boldsymbol{\varepsilon}^T\boldsymbol{\varepsilon} - \boldsymbol{\varepsilon}^THX\boldsymbol{\beta} - \boldsymbol{\varepsilon}^TH\boldsymbol{\varepsilon} \\
\end{align}

$E[\boldsymbol{\varepsilon}] = \boldsymbol{0}$, $E[\boldsymbol{\varepsilon}\boldsymbol{\varepsilon}^T] = \sigma^2I_{n}$より,

\begin{align*}
    E[||\boldsymbol{y} - X\hat{\boldsymbol{\beta}}||^2] &= E[\boldsymbol{\varepsilon}^T\boldsymbol{\varepsilon} - \boldsymbol{\varepsilon}^TH\boldsymbol{\varepsilon}] \\
    &= tr(E[\boldsymbol{\varepsilon}\boldsymbol{\varepsilon}^T]) - tr(HE[\boldsymbol{\varepsilon}\boldsymbol{\varepsilon}^T]) \\
    &= n\sigma^2 - \sigma^2tr(H) \\
    &= n\sigma^2 - \sigma^2tr(I_{p+1}) \\
    &= (n - p - 1)\sigma^2
\end{align*}

したがって,

\begin{align}
    E[\hat{\sigma}^2] &= \frac{1}{n - p - 1}E[||\boldsymbol{y} - X\hat{\boldsymbol{\beta}}||^2] \\
    &= \sigma^2
\end{align}

係数の検定(1個)

$H_0 : \beta_i = 0$, $H_1 : \beta_i \neq 0$ として

\frac{\beta_i-\hat{\beta_i}}{\sqrt{ \sigma^2(X^TX)_{ii}^{-1} }} 
 \sim N(0,1) 

であるが, 分散が未知の場合には不偏分散 $\hat{\sigma}^2$ を用いて

\frac{\beta_i - \hat{\beta_i}}{\sqrt{ \hat{\sigma}^2(X^TX)_{ii}^{-1} }} \sim t(n-p-1)

となる.

係数の検定(複数)

分散分析の考え方を用いてF検定を行う. $H_0$, $H_1$ における残差平方和をそれぞれ$Rss(0)$, $Rss(1)$とする.
(例1)
$H_0 : \beta_1 = \beta_2 = \cdots = \beta_p = 0$
$H_1 : H_0$ でない

$H_0:y_i = \beta_0 + \varepsilon_i$
$H_1:y_i = \beta_0 + \beta_1x_{i1} + \cdots + \beta_px_{ip} + \varepsilon_i$

平方和 自由度 平均平方 F値
$Rss(0)-Rss(1)$ $p$ $(Rss(0)-Rss(1))/p$ $F$
$Rss(1)$ $n-p-1$ $Rss(1)/(n-p-1)$
$Rss(0)$ $n-1$

(例2)
$H_0 : \beta_1 = \beta_2, \beta_{p-1} = \beta_p$
$H_1 : H_0$ でない

$H_0:y_i = \beta_0 + \beta_1x_{i1} + \beta_1x_{i2} + \beta_3x_{i3} + \beta_4x_{i4} + \cdots + \beta_{p-2}x_{i(p-2)} + \beta_{p-1}x_{i(p-1)} + \beta_{p-1}x_{ip} + \varepsilon_i$
$H_1:y_i = \beta_0 + \beta_1x_{i1} + \cdots + \beta_px_{ip} + \varepsilon_i$

平方和 自由度 平均平方 F値
$Rss(0)-Rss(1)$ $2$ $(Rss(0)-Rss(1))/2$ $F$
$Rss(1)$ $n-p-1$ $Rss(1)/(n-p-1)$
$Rss(0)$ $n-p+1$
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?