% Weighted Least Squares and Generalized Least Squares for STA302 % \documentclass[serif]{beamer} % Serif for Computer Modern math font. \documentclass[serif, handout]{beamer} % Handout mode to ignore pause statements \hypersetup{colorlinks,linkcolor=,urlcolor=red} \usefonttheme{serif} % Looks like Computer Modern for non-math text -- nice! \setbeamertemplate{navigation symbols}{} % Suppress navigation symbols \usetheme{Berlin} % Displays sections on prime %\usetheme{Frankfurt} % Displays section titles on prime: Fairly thin but still swallows some material at bottom of crowded slides %\usetheme{Berkeley} % \usetheme{AnnArbor} % Yellow and blue, good for large number of sections \usepackage[english]{babel} \usepackage{amsmath} % for binom \usepackage{comment} \usepackage{alltt} % For colouring in verbatim environment % \usepackage{graphicx} % To include pdf files! % \definecolor{links}{HTML}{2A1B81} % \definecolor{links}{red} \setbeamertemplate{footline}[frame number] \mode % \mode{\setbeamercolor{background canvas}{bg=black!5}} % Comment this out for handout \title{Centered Explanatory Variables\footnote{See last slide for copyright information.}} \subtitle{STA302 Fall 2020} \date{} % To suppress date \begin{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \titlepage \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Overview} \tableofcontents \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{The Centered Model} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Center the explanatory variables } \framesubtitle{By subtracting off the sample mean} \pause \begin{itemize} \item Replace $x_{ij}$ with $x_{ij}-\overline{x}_j$\pause, expressing each explanatory variable as a deviation from its mean. \pause \item Can be useful at times. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Simple Regression} %\framesubtitle{} \begin{center} \includegraphics[width=3in]{centershift1} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Simple Regression} %\framesubtitle{} \begin{center} \includegraphics[width=3in]{centershift2} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{It looks like} %\framesubtitle{} \begin{columns} \column{0.5\textwidth} \begin{center} \includegraphics[width=2.5in]{centershift3} \end{center} \pause \column{0.5\textwidth} \begin{itemize} \item Estimated slopes will be unaffected. \item Estimated intercepts \emph{will} be affected. \pause \item $\widehat{y}_i$ should be unaffected. \pause \item $\widehat{\epsilon}_i$ should be unaffected. \pause \item If so, prediction intervals and $R^2$ should be unaffected. \pause \item And tests for slopes should be unaffected. \end{itemize} \end{columns} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Interpretation} %\framesubtitle{} \begin{columns} \column{0.5\textwidth} \begin{center} \includegraphics[width=2.5in]{CenteredScatter} \end{center} \column{0.5\textwidth} \begin{itemize} \item Having the $y$ axis go through the data can make the intercept more meaningful. \pause \item Suppose $x$ is age, and $y$ is weight loss in an exercise program. \pause \item Question: Is any weight loss to be expected for a person of average age? \pause \item $H_0: \beta_0 = 0$ \pause is tested automatically. \pause \item Testing $H_0: \beta_0 + \beta_1\overline{x}= 0$ requires more effort. \end{itemize} \end{columns} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The Model for Simple Regression} %\framesubtitle{} \begin{eqnarray*} y_i & = & \beta_0 + \beta_1 x_i + \epsilon_i \\ \pause & = & \beta_0 + \beta_1 x_i {\color{red} - \beta_1\overline{x} + \beta_1\overline{x}} + \epsilon_i \\ \pause & = & (\beta_0 + {\color{red}\beta_1\overline{x}}) + \beta_1 (x_i - {\color{red}\overline{x}}) + \epsilon_i \\ \pause & = & ~~~~ \, \alpha_0 ~~~~~~+ \alpha_1 (x_i-\overline{x}) + \epsilon_i \end{eqnarray*} \vspace{3mm} The intercept is affected by centering, but the slope is not. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Center all the predictor variables} \pause %\framesubtitle{} %\framesubtitle{} \begin{eqnarray*} y_i & = & \beta_0 + \beta_1 x_{i,1} + \cdots + \beta_k x_{i,k} + \epsilon_i \\ \pause & = & \beta_0 + \beta_1 \overline{x}_1 + \cdots + \beta_{k} \overline{x}_k \\ & & + \beta_1 (x_{i,1}-\overline{x}_1) + \cdots + \beta_{k} (x_{i,k}-\overline{x}_{k}) + \epsilon_i \\ \pause & = & \alpha_0 + \alpha_1 (x_{i,1}-\overline{x}_1) + \cdots + \alpha_{k} (x_{i,k}-\overline{x}_{k}) + \epsilon_i \end{eqnarray*} \pause with \begin{itemize} \item[] $\alpha_0 = \beta_0 + \beta_1 \overline{x}_1 + \cdots + \beta_{k} \overline{x}_k$. \pause \item[] $\alpha_j=\beta_j$ for $j = 1, \ldots, k$ \pause \end{itemize} \vspace{3mm} \begin{itemize} \item The intercept is affected by centering, but the slopes are not. \pause \item You don't have to center all the $x$ variables. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Dummy Variable Regression} \framesubtitle{Just center the covariate(s)} \pause \begin{eqnarray*} y_i & = & \beta_0 + \beta_1 x_i + \beta_2 d_{i,1} + \beta_3 d_{i,2} + \epsilon_i \\ \pause & = & \beta_0 + \beta_1 x_i {\color{red} - \beta_1\overline{x} + \beta_1\overline{x}} + \beta_2 d_{i,1} + \beta_3 d_{i,2} + \epsilon_i \\ \pause & = & (\beta_0 + {\color{red}\beta_1\overline{x}}) + \beta_1 (x_i - {\color{red}\overline{x}}) + \beta_2 d_{i,1} + \beta_3 d_{i,2} + \epsilon_i \\ \pause & = & ~~~~ \, \alpha_0 ~~~~~~+ \alpha_1 (x_i-\overline{x}) + \alpha_2 d_{i,1} + \alpha_3 d_{i,2} + \epsilon_i \\ \pause \end{eqnarray*} \vspace{3mm} Slopes are not affected by centering. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Parallel Regression Lines} %\framesubtitle{} \begin{center} %{\footnotesize \begin{tabular}{|c|c|c|c|} \hline Drug & $d_1$ & $d_2$ & $E(y|\mathbf{x}) = \alpha_0+\alpha_1(x-\overline{x}) + \alpha_2d_1+\alpha_3d_2$\\ \hline A & 1 & 0 & $(\alpha_0+\alpha_2) +\alpha_1(x-\overline{x})$ \\ \hline B & 0 & 1 & $(\alpha_0+\alpha_3) +\alpha_1(x-\overline{x})$ \\ \hline Placebo & 0 & 0 & ~~~~~$\alpha_0$~~~~ $+\alpha_1(x-\overline{x})$ \\ \hline \end{tabular} \pause %} % End size \end{center} \vspace{3mm} Could describe the estimated intercepts as ``adjusted means," or ``corrected means." \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Interactions} %\framesubtitle{} \begin{center} \includegraphics[width=3in]{Cross3} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Interactions} %\framesubtitle{} \begin{center} \includegraphics[width=3in]{Cross3b} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Interactions} {\Large \begin{center} \begin{tabular}{|c|c|c|c|} \hline Group & $d_1$ & $d_2$ & $E(y|\mathbf{x})$ \\ \hline 1 & 1 & 0 & $(\beta_0+\beta_2) + (\beta_1+\beta_4) (x-\overline{x})$ \\ \hline 2 & 0 & 1 & $(\beta_0+\beta_3) + (\beta_1+\beta_5) (x-\overline{x})$ \\ \hline 3 & 0 & 0 & $~~~~~\beta_0 ~~~~+ ~~~~~\beta_1 ~~~~(x-\overline{x})$ \\ \hline \end{tabular} \end{center} \pause } % End size \begin{itemize} \item What happens at $x = \overline{x}$? \pause \item If you are interested in estimating or testing for differences at some other point, it might be easiest to subtract that value from $x$ instead. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \section{Estimation and Testing} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Estimation and Testing} \pause %\framesubtitle{} \begin{itemize} \item Have \begin{itemize} \item[] $\alpha_0 = \beta_0 + \beta_1 \overline{x}_1 + \cdots + \beta_{k} \overline{x}_k$. \item[] $\alpha_j=\beta_j$ for $j = 1, \ldots, k$ \end{itemize} \pause \item Will have \begin{itemize} \item[] $\widehat{\alpha}_0 = \widehat{\beta}_0 + \widehat{\beta}_1 \overline{x}_1 + \cdots + \widehat{\beta}_{k} \overline{x}_k$. \item[] $\widehat{\alpha}_j=\widehat{\beta}_j$ for $j = 1, \ldots, k$ \pause \end{itemize} \item $\widehat{\mathbf{y}}$ will be unaffected. \pause \item $\widehat{\boldsymbol{\epsilon}}$ will be unaffected. \pause \item Prediction intervals and $R^2$ will be unaffected. \pause \item Tests for slopes will be unaffected. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Re-parameterization} \pause %\framesubtitle{} \begin{itemize} \item The mapping \begin{itemize} \item[] $\alpha_0 = \beta_0 + \beta_1 \overline{x}_1 + \cdots + \beta_{k} \overline{x}_k$. \item[] $\alpha_j=\beta_j$ for $j = 1, \ldots, k$ \end{itemize} is a one-to-one re-parameterization. \pause \item Furthermore, it's linear. \pause \item Write as matrix multiplication. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Matrix Multiplication} \framesubtitle{To get $\alpha_0 = \beta_0 + \beta_1 \overline{x}_1 + \cdots + \beta_{k} \overline{x}_k$ and $\alpha_j=\beta_j$ for $j = 1, \ldots, k$} \begin{displaymath} \left(\begin{array}{ccccc} 1 & \overline{x}_1 & \overline{x}_2 & \cdots & \overline{x}_k \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{array} \right) \left(\begin{array}{c} \beta_0 \\ \beta_1 \\ \beta_2 \\ \vdots \\ \beta_k \end{array} \right) = \left(\begin{array}{c} \beta_0 + \beta_1 \overline{x}_1 + \cdots + \beta_{k} \overline{x}_k \\ \beta_1 \\ \beta_2 \\ \vdots \\ \beta_k \end{array} \right) \end{displaymath} \pause This matrix $\uparrow$ definitely has an inverse. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Inverse} %\framesubtitle{} \begin{columns} \column{1.2\textwidth} {\scriptsize \begin{displaymath} \left(\begin{array}{ccccc} 1 & -\overline{x}_1 & -\overline{x}_2 & \cdots & -\overline{x}_k \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{array} \right) \left(\begin{array}{ccccc} 1 & \overline{x}_1 & \overline{x}_2 & \cdots & \overline{x}_k \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{array} \right) = \left(\begin{array}{ccccc} 1 & 0 & 0 & \cdots & 0 \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{array} \right) \end{displaymath} \pause } % End size \end{columns} % Unfortunate visual formatting. Array did not fit on the slide. \hspace{15mm} $\mathbf{A}$ \hspace{35mm} $\mathbf{A}^{-1}$ \hspace{11mm} = \hspace{12mm} $\mathbf{I}$ \pause \vspace{-3mm} \begin{eqnarray*} \mathbf{y} & = & \mathbf{X} \boldsymbol{\beta} + \boldsymbol{\epsilon} \\ \pause & = & \mathbf{X} \mathbf{AA}^{-1}\boldsymbol{\beta} + \boldsymbol{\epsilon} \\ \pause & = & (\mathbf{X} \mathbf{A})(\mathbf{A}^{-1}\boldsymbol{\beta}) + \boldsymbol{\epsilon} \\ \pause & = & ~~~\mathbf{W} ~~~~~ \boldsymbol{\alpha} ~~~ \, + \boldsymbol{\epsilon}\pause, \end{eqnarray*} Where $\mathbf{W}$ is the centered $\mathbf{X}$ matrix. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Does the matrix $\mathbf{A}$ really center the $\mathbf{X}$ matrix?} \framesubtitle{Just look at row $i$ of $\mathbf{XA}$} \pause \begin{eqnarray*} &&\left( \begin{array}{ccccc} 1 & x_{i1} & x_{i2} & \cdots & x_{ik} \end{array}\right) \left(\begin{array}{ccccc} 1 & -\overline{x}_1 & -\overline{x}_2 & \cdots & -\overline{x}_k \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{array} \right) \\ \pause && \rule{0mm}{10mm} = % Write in by hand and talk through. \left(\begin{array}{ccccc} 1 & x_{i1}-\overline{x}_1 & x_{i2}-\overline{x}_2 & \cdots & x_{ik}-\overline{x}_k \end{array}\right) \end{eqnarray*} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{One-to-one linear transformation} %\framesubtitle{} The point is that centering the explanatory variables is a one-to-one linear transformation of $\mathbf{X}$ matrix: $\mathbf{W} = \mathbf{AX}$. \pause \begin{displaymath} \mathbf{A} = \left(\begin{array}{ccccc} 1 & -\overline{x}_1 & -\overline{x}_2 & \cdots & -\overline{x}_k \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{array} \right) \end{displaymath} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Centering Just Some of the Variables} %\framesubtitle{} \begin{displaymath} \left( \begin{array}{ccccc} 1 & x_{i1} & x_{i2} & \cdots & x_{ik} \end{array}\right) \left(\begin{array}{ccccc} 1 & -\overline{x}_1 & -\overline{x}_2 & \cdots & -\overline{x}_k \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{array} \right) \end{displaymath} \pause \begin{itemize} \item To leave variable $j$ uncentered, replace $\overline{x}_j$ with zero. \pause \item Rows are still linearly independent. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{We have been here before} \framesubtitle{See Assignment 9, Problem 4} \pause \begin{eqnarray*} & & \mathbf{y} = \mathbf{X} \boldsymbol{\beta} + \boldsymbol{\epsilon} \\ & \iff & \mathbf{y} = \mathbf{XA A}^{-1} \boldsymbol{\beta} + \boldsymbol{\epsilon} \\ & \iff & \mathbf{y} = \mathbf{W} \boldsymbol{\alpha} + \boldsymbol{\epsilon} \pause \end{eqnarray*} \begin{eqnarray*} \widehat{\boldsymbol{\alpha}} & = & (\mathbf{W}^\prime \mathbf{W})^{-1} \mathbf{W}^\prime \mathbf{y} \\ \pause & = & \left((\mathbf{XA})^\prime \mathbf{XA}\right)^{-1} (\mathbf{XA})^\prime \mathbf{y} \\ \pause & = & \left( \mathbf{A}^\prime \mathbf{X}^\prime \mathbf{XA}\right)^{-1} \mathbf{A}^\prime \mathbf{X}^\prime \mathbf{y} \\ \pause & = & \mathbf{A}^{-1} (\mathbf{X}^\prime \mathbf{X})^{-1} \mathbf{A}^{\prime-1} \mathbf{A}^\prime \mathbf{X}^\prime \mathbf{y} \\ \pause & = & \mathbf{A}^{-1} (\mathbf{X}^\prime \mathbf{X})^{-1} \mathbf{X}^\prime \mathbf{y} \\ \pause & = & \mathbf{A}^{-1} \widehat{\boldsymbol{\beta}} \end{eqnarray*} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{$\widehat{\boldsymbol{\alpha}} = \mathbf{A}^{-1} \widehat{\boldsymbol{\beta}}$} \framesubtitle{Same form as $\boldsymbol{\alpha} = \mathbf{A}^{-1} \boldsymbol{\beta}$: Invariance} \pause {\small \begin{displaymath} \hspace{-8mm} \left(\begin{array}{c} \widehat{\alpha}_0 \\ \widehat{\alpha}_1 \\ \widehat{\alpha}_2 \\ \vdots \\ \widehat{\alpha}_k \end{array} \right) = \left(\begin{array}{ccccc} 1 & \overline{x}_1 & \overline{x}_2 & \cdots & \overline{x}_k \\ 0 & 1 & 0 & \cdots & 0 \\ 0 & 0 & 1 & \cdots & 0 \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & 0 & \cdots & 1 \end{array} \right) \left(\begin{array}{c} \widehat{\beta}_0 \\ \widehat{\beta}_1 \\ \widehat{\beta}_2 \\ \vdots \\ \widehat{\beta}_k \end{array} \right) \pause = \left(\begin{array}{c} \widehat{\beta}_0 + \widehat{\beta}_1 \overline{x}_1 + \cdots + \widehat{\beta}_{k} \overline{x}_k \\ \widehat{\beta}_1 \\ \widehat{\beta}_2 \\ \vdots \\ \widehat{\beta}_k \end{array} \right) \end{displaymath} } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Predicted $\mathbf{y}$ for $\mathbf{y} = \mathbf{W} \boldsymbol{\alpha} + \boldsymbol{\epsilon}$} %\framesubtitle{} {\LARGE \begin{eqnarray*} \mathbf{W} \widehat{\boldsymbol{\alpha}} \pause &=& (\mathbf{XA})(\mathbf{A}^{-1} \widehat{\boldsymbol{\beta}}) \\ \pause &=& \mathbf{X} \widehat{\boldsymbol{\beta}} \\ \pause &=& \widehat{\mathbf{y}} \end{eqnarray*} } % End size \begin{itemize} \item So $\widehat{\mathbf{y}}$ is unchanged by centering. \pause \item This means $\widehat{\boldsymbol{\epsilon}}$, \emph{SSE}, \emph{MSE} and $R^2$ are also unchanged. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Prediction Intervals are unchanged} \framesubtitle{$\mathbf{x}_0^\prime \widehat{\boldsymbol{\beta}} \pm t_{\alpha/2} \, \sqrt{\mbox{\small\emph{MSE}} \, (1 + \mathbf{x}_0^\prime (\mathbf{X}^\prime \mathbf{X})^{-1}\mathbf{x}_0)}$} \pause The key is that you need to give it a vector of centered $x$ variables\pause: $\mathbf{x}_0^{*\prime} = \mathbf{x}_0^\prime\mathbf{A} \pause \iff \mathbf{x}_0^* = \mathbf{A}^\prime \mathbf{x}_0$. \pause \begin{eqnarray*} && \mathbf{x}_0^{*\prime} \widehat{\boldsymbol{\alpha}} \pm t_{\alpha/2} \, \sqrt{\mbox{\small\emph{MSE}} \, (1 + \mathbf{x}_0^{*\prime} (\mathbf{W}^\prime \mathbf{W})^{-1}\mathbf{x}_0^*)} \\ \pause & = & (\mathbf{x}_0^\prime\mathbf{A})(\mathbf{A}^{-1} \widehat{\boldsymbol{\beta}}) \pause \pm t_{\alpha/2} \, \sqrt{\mbox{\small\emph{MSE}} \, (1 + \mathbf{x}_0^\prime\mathbf{A} (\mathbf{W}^\prime \mathbf{W})^{-1}\mathbf{A}^\prime \mathbf{x}_0)} \\ \pause & = & \mathbf{x}_0^\prime \widehat{\boldsymbol{\beta}} \pause \pm t_{\alpha/2} \, \sqrt{\mbox{\small\emph{MSE}} \, (1 + \mathbf{x}_0^\prime\mathbf{A} \left((\mathbf{XA})^\prime \mathbf{XA}\right)^{-1} \mathbf{A}^\prime \mathbf{x}_0)} \\ \pause & = & \mathbf{x}_0^\prime \widehat{\boldsymbol{\beta}} \pm t_{\alpha/2} \, \sqrt{\mbox{\small\emph{MSE}} \, (1 + \mathbf{x}_0^\prime\mathbf{A} \left( \mathbf{A}^\prime \mathbf{X}^\prime \mathbf{XA}\right)^{-1} \mathbf{A}^\prime \mathbf{x}_0)} \\ \pause & = & \mathbf{x}_0^\prime \widehat{\boldsymbol{\beta}} \pm t_{\alpha/2} \, \sqrt{\mbox{\small\emph{MSE}} \, (1 + \mathbf{x}_0^\prime\mathbf{A} \mathbf{A}^{-1} (\mathbf{X}^\prime \mathbf{X})^{-1} \mathbf{A}^{\prime-1} \mathbf{A}^\prime \mathbf{x}_0)} \\ \pause & = & \mathbf{x}_0^\prime \widehat{\boldsymbol{\beta}} \pm t_{\alpha/2} \, \sqrt{\mbox{\small\emph{MSE}} \, (1 + \mathbf{x}_0^\prime (\mathbf{X}^\prime \mathbf{X})^{-1}\mathbf{x}_0)} \end{eqnarray*} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Hypothesis tests: $H_0: \mathbf{C}\boldsymbol{\beta} = \mathbf{t}$} \framesubtitle{Using $F^* = \frac{(\mathbf{C}\widehat{\boldsymbol{\beta}} -\mathbf{t})^\prime (\mathbf{C}(\mathbf{X}^\prime \mathbf{X})^{-1}\mathbf{C}^\prime)^{-1} (\mathbf{C}\widehat{\boldsymbol{\beta}} - \mathbf{t})} {q \, \mbox{\footnotesize\emph{MSE}}}$} \pause {\small \begin{eqnarray*} \mathbf{C}\boldsymbol{\beta} = \mathbf{t} & \iff & (\mathbf{CA})(\mathbf{A}^{-1}\boldsymbol{\beta}) = \mathbf{t} \\ \pause & \iff & (\mathbf{CA}) \boldsymbol{\alpha} = \mathbf{t} \\ \end{eqnarray*} \pause \vspace{-6mm} Look at the numerator of $F^*$ for the centered data. \pause \begin{eqnarray*} && (\mathbf{CA}\widehat{\boldsymbol{\alpha}} -\mathbf{t})^\prime (\mathbf{CA} (\mathbf{W}^\prime\mathbf{W})^{-1} (\mathbf{CA})^\prime)^{-1} (\mathbf{CA}\widehat{\boldsymbol{\alpha}} - \mathbf{t}) \\ \pause &=& (\mathbf{CA}\mathbf{A}^{-1} \widehat{\boldsymbol{\beta}} -\mathbf{t})^\prime (\mathbf{CA} { \color{red}(\mathbf{W}^\prime\mathbf{W})^{-1} } \mathbf{A}^\prime \mathbf{C}^\prime)^{-1} (\mathbf{CA}\mathbf{A}^{-1} \widehat{\boldsymbol{\beta}} - \mathbf{t}) \\ \pause &=& (\mathbf{C}\widehat{\boldsymbol{\beta}} -\mathbf{t})^\prime (\mathbf{CA} { \color{red}\mathbf{A}^{-1} (\mathbf{X}^\prime \mathbf{X})^{-1} \mathbf{A}^{\prime-1} } \mathbf{A}^\prime \mathbf{C}^\prime)^{-1} (\mathbf{C} \widehat{\boldsymbol{\beta}} - \mathbf{t}) \\ \pause &=& (\mathbf{C}\widehat{\boldsymbol{\beta}} -\mathbf{t})^\prime (\mathbf{C}(\mathbf{X}^\prime \mathbf{X})^{-1}\mathbf{C}^\prime)^{-1} (\mathbf{C}\widehat{\boldsymbol{\beta}} - \mathbf{t}) \end{eqnarray*} \pause \vspace{-5mm} \begin{itemize} \item This is the numerator for the uncentered data, so the test statistics are equal. \pause \item If the hypothesis does not involve $\alpha_0$, you don't need to transform $\mathbf{C}$. \end{itemize} } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Summary} \framesubtitle{A simple story, in spite of all the technical details} \pause \begin{itemize} \item Centering some or all of the explanatory variables can be helpful. \pause \item Only the intercept is affected. \pause \item There is no effect on predicted $y$, residuals, $R^2$, or prediction intervals. \pause \item There is no effect on tests and confidence intervals, unless the intercept is involved. \end{itemize} \end{frame} % I guess I could ask about CI in homework or quiz. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Copyright Information} This slide show was prepared by \href{http://www.utstat.toronto.edu/~brunner}{Jerry Brunner}, Department of Statistics, University of Toronto. It is licensed under a \href{http://creativecommons.org/licenses/by-sa/3.0/deed.en_US} {Creative Commons Attribution - ShareAlike 3.0 Unported License}. Use any part of it as you like and share the result freely. The \LaTeX~source code is available from the course website: \href{http://www.utstat.toronto.edu/~brunner/oldclass/302f20} {\small\texttt{http://www.utstat.toronto.edu/$^\sim$brunner/oldclass/302f20}} \end{frame} \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # Generating Centershift1.pdf and Centershift2.pdf -- apparent motion? rm(list=ls()) set.seed(9999) n = 12; mu = 75; sig=6 x1 = round(rnorm(n,mu,sig)); x2 = round(rnorm(n,mu,sig)); x3 = round(rnorm(n,mu,sig)) eps1 = round(rnorm(n,0,sig)); eps2 = round(rnorm(n,0,sig)); eps3 = round(rnorm(n,0,sig)) y1 = round(-mu + 2*x1 + eps1) y2 = round(x2 + eps2); y2[x2