% Applied Stat I: Introduction with Regression as an example and takeoff point % Notes and comments at the end % \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}{} % Supress navigation symbols \usetheme{Berlin} % Displays sections on top \usepackage[english]{babel} % \definecolor{links}{HTML}{2A1B81} % \definecolor{links}{red} \setbeamertemplate{footline}[frame number] \mode % \mode{\setbeamercolor{background canvas}{bg=black!5}} \title{Some Comments on Linear Regression\footnote{See last slide for copyright information.}} \subtitle{STA442/2101 Fall 2018} \date{} % To suppress date \begin{document} \begin{frame} \titlepage \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Fixed Effects Linear Regression} %\framesubtitle{} {\LARGE \begin{displaymath} \mathbf{y} = \mathbf{X} \boldsymbol{\beta} + \boldsymbol{\epsilon} \end{displaymath} \pause } % End size \begin{itemize} \item $\mathbf{X}$ is an $n \times p$ matrix of known constants. \item $\boldsymbol{\beta}$ is a $p \times 1$ vector of unknown constants. \item $\boldsymbol{\epsilon} \sim N(\mathbf{0},\sigma^2 \mathbf{I}_n)$ , where $\sigma^2 > 0$ is an unknown constant. \item[] \pause \item $\widehat{\boldsymbol{\beta}} = (\mathbf{X}^\top \mathbf{X})^{-1} \mathbf{X}^\top \mathbf{y} $ \item $\widehat{\mathbf{y}}=\mathbf{X}\widehat{\boldsymbol{\beta}} $ \item $\mathbf{e}= (\mathbf{y}-\widehat{\mathbf{y}})$ \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Comparing scalar and matrix form} %\framesubtitle{} Scalar form is $y_i = \beta_0 + \beta_1 x_{i,1} + \cdots + \beta_{p-1}x_{i,p-1} + \epsilon_i $ \pause \begin{equation*} \begin{array}{cccccccc} % 6 columns \mathbf{y} & = & \mathbf{X} & \boldsymbol{\beta} & + & \boldsymbol{\epsilon} \\ \pause &&&&& \\ % Another space \left( \begin{array}{c} y_1 \\ y_2 \\ y_3 \\ \vdots \\ y_n \end{array} \right) &=& \left(\begin{array}{cccc} 1 & 14.2 & \cdots & 1 \\ 1 & 11.9 & \cdots & 0 \\ 1 & ~3.7 & \cdots & 0 \\ \vdots & \vdots & \vdots & \vdots \\ 1 & ~6.2 & \cdots & 1 \end{array}\right) & \left( \begin{array}{c} \beta_0 \\ \beta_1 \\ \vdots \\ \beta_{p-1} \end{array} \right) &+& \left( \begin{array}{c} \epsilon_1 \\ \epsilon_2 \\ \epsilon_3 \\ \vdots \\ \epsilon_n \end{array} \right) \end{array} \end{equation*} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Vocabulary} %\framesubtitle{} \begin{itemize} \item Explanatory variables are $x$ \pause \item Response variable is $y$. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{``Control" means hold constant} %\framesubtitle{} \begin{itemize} \item Regression model with four explanatory variables. \pause \item Hold $x_1$, $x_2$ and $x_4$ constant at some fixed values. \pause \begin{eqnarray*} E(Y|\boldsymbol{X}=\boldsymbol{x}) & = & \beta_0 + \beta_1x_1 + \beta_2x_2 +\beta_3x_3 + \beta_4x_4 \\ \pause & = & (\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_4x_4) + \beta_3x_3 \\ \pause \end{eqnarray*} \item The equation of a straight line with slope $\beta_3$. \pause \item Values of $x_1$, $x_2$ and $x_4$ affect only the intercept. \pause \item So $\beta_3$ is the rate at which $E(Y|\mathbf{x})$ changes as a function of $x_3$ with all other variables held constant at fixed levels. \pause \item \emph{According to the model}. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{More vocabulary} \framesubtitle{$E(Y|\boldsymbol{X}=\boldsymbol{x}) = (\beta_0 + \beta_1x_1 + \beta_2x_2 + \beta_4x_4) + \beta_3x_3$} \pause \begin{itemize} \item If $\beta_3>0$, describe the relationship between $x_3$ and (expected) $y$ as ``positive," \pause controlling for the other variables. \pause If $\beta_3<0$, negative. \pause \item Useful ways of saying ``controlling for" or ``holding constant" include \pause \begin{itemize} \item Allowing for \item Correcting for \item Taking into account \end{itemize} \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Categorical Explanatory Variables} \pause \framesubtitle{Unordered categories} \begin{itemize} \item $X=1$ means Drug, $X=0$ means Placebo. \pause \item Population mean is $E(Y|X=x) = \beta_0 + \beta_1 x$. \pause \item For patients getting the drug, mean response is \pause $E(Y|X=1) = \beta_0 + \beta_1$ \pause \item For patients getting the placebo, mean response is \pause $E(Y|X=0) = \beta_0$ \pause \item And $\beta_1$ is the difference between means, the average treatment effect. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Correlation-causation} \framesubtitle{More on how to talk (and think) about the results} \pause {\footnotesize \begin{itemize} \item Suppose the two conditions were standard treatment versus new treatment. \pause \item $x=0$ means standard treatment, $x=1$ means new treatment. \pause \item We could collect data on people who were treated for the disease, observe whether they got the standard treatment or the new treatment, and also observe $y$ to see how they did. \pause \item Suppose $H_0: \mu_1=\mu_2$ is rejected, and patents receiving the new treatment did better on average. \pause \item Is the new treatment better? \pause \item Maybe, \pause but it's also possible that those receiving the new treatment were more motivated, or more educated, or healthier in the first place (so they have energy to pursue non-standard options). \pause \item Controlling for those possibilities is a good idea, but will you think of everything? \pause \item The standard saying is ``Correlation does not imply causation." \pause \item Correlation means association between variables. \pause \item Causation means influence, not absolute determination. \end{itemize} } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{More examples} %\framesubtitle{} \begin{itemize} \item Wearing a hat and baldness. \pause \item Exercise and arthritis pain. \pause \item The Mozart effect. \pause \item Alchohol consumption and health. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Confounding variable} \pause %\framesubtitle{} \begin{itemize} \item Is related to both the explanatory variable and response variable \pause \item Causing an apparent relationship. \pause \item $A$ and $B$ are related only because they are both related to $C$. \pause \item Exercise and health. \pause You'd better control for age. \pause \item Controlling for age may not be enough. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The solution: Random assignment} \framesubtitle{Again, $x=0$ means standard treatment and $x=1$ means new treatment} \pause \begin{itemize} \item What if patients were randomly assigned to treatment? \pause \item In an \emph{experimental study}, subjects are randomly assignent to treatment conditions --- values of a categorical explanatory variable --- and values of the response variable are observed. \pause \item In an \emph{observational study}, values of the explanatory and response variables are just observed. \pause \item In a well-designed experimental study, confounding variables are ruled out. \pause \item $B \rightarrow A$ is ruled out too. \pause \item Thank you, Mr. Fisher. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Talking about the results of a purely observational study} \pause %\framesubtitle{} Avoid language that implies causality or influence. \pause {\footnotesize \begin{itemize} \item Don't say ``Music lessons led to better academic performance." \pause \item Say ``Students who had private music lessons tended to have better academic performance." \pause \item A good follow-up might be ``Music lessons may stimulate cognitive development, but it's also possible that students who had private music lessons were different in other ways, such as average income or parents' education." \pause \item Don't say ``Solving puzzles on a regular basis tended to provide protection against the development of dementia." \pause \item Say ``Participants who solved puzzles on a regular basis tended to develop dementia later in life than those who did not solve puzzles on a regular basis." \pause \item It is okay to follow up with ``Solving puzzles may provide mental simulation that slows the onset of dementia." \pause \item But then say \pause ``Or, it is possible that early stages of dementia that are difficult to detect may lead to decreased interest in solving puzzles." \end{itemize} } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Three ways to think about a regression model for observational data} \framesubtitle{$y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \epsilon$} \begin{itemize} \item Literally a model for how $y$ is \emph{produced} from the $x$ values. \pause In this case it's a causal model. \pause \item A convenient way to say that $y$ might be related to the $x$ values, by specifying a rough model of the conditional distribution of $y$ given $x_1, \ldots, x_{p-1}$. \pause \item Pure prediction. \pause In this case all the correlation-causation business is irrelevant\pause, but it's not Science. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{More than Two Categories} \pause Suppose a study has 3 treatment conditions. For example Group 1 gets Drug 1, Group 2 gets Drug 2, and Group 3 gets a placebo, so that the Explanatory Variable is Group (taking values 1,2,3) and there is some Response Variable $Y$ (maybe response to drug again). \pause \vspace{10mm} Why is $E[Y|X=x] = \beta_0 + \beta_1x$ (with $x$ = Group) a silly model? \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Indicator Dummy Variables} \framesubtitle{With intercept} \pause \begin{itemize} \item $x_1 = 1$ if Drug A, zero otherwise \item $x_2 = 1$ if Drug B, zero otherwise \pause \item $E[Y|\boldsymbol{X}=\boldsymbol{x}] = \beta_0 + \beta_1x_1 + \beta_2 x_2$. \pause \item Fill in the table. \pause \end{itemize} {\begin{center} \begin{tabular}{|c|c|c|l|} \hline Drug & $x_1$ & $x_2$ & $E(Y|\mathbf{x}) = \beta_0 + \beta_1x_1 + \beta_2 x_2$ \\ \hline $A$ & & & $\mu_1$ = \\ \hline $B$ & & & $\mu_2$ = \\ \hline Placebo & & & $\mu_3$ = \\ \hline \end{tabular} \end{center}} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Answer} \begin{itemize} \item $x_1 = 1$ if Drug A, zero otherwise \item $x_2 = 1$ if Drug B, zero otherwise \item $E[Y|\boldsymbol{X}=\boldsymbol{x}] = \beta_0 + \beta_1x_1 + \beta_2 x_2$. \pause \end{itemize} {\begin{center} \begin{tabular}{|c|c|c|l|} \hline Drug & $x_1$ & $x_2$ & $E(Y|\mathbf{x}) = \beta_0 + \beta_1x_1 + \beta_2 x_2$ \\ \hline $A$ & 1 & 0 & $\mu_1$ = $\beta_0 + \beta_1$ \\ \hline $B$ & 0 & 1 & $\mu_2$ = $\beta_0 + \beta_2$ \\ \hline Placebo & 0 & 0 & $\mu_3$ = $\beta_0$ \\ \hline \end{tabular} \end{center}} \pause Regression coefficients are contrasts with the category that has no indicator -- the \emph{reference category}. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Indicator dummy variable coding with intercept} \pause %\framesubtitle{} \begin{itemize} \item With an intercept in the model, need $p-1$ indicators to represent a categorical explanatory variable with $p$ categories. \pause \item If you use $p$ dummy variables and an intercept, trouble. \pause \item Regression coefficients are contrasts with the category that has no indicator. \pause \item Call this the \emph{reference category}. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{$x_1 = 1$ if Drug A, zero o.w., $x_2 = 1$ if Drug B, zero o.w.} \pause %\framesubtitle{3-d Scatterplot} Recall $\sum_{i=1}^n (y_i-m)^2$ is minimized at $m = \overline{y}$ \pause \begin{center} \includegraphics[width=3in]{ABCscatter} \end{center} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{What null hypotheses would you test?} \pause {\begin{center} \begin{tabular}{|c|c|c|l|} \hline Drug & $x_1$ & $x_2$ & $E(Y|\mathbf{x}) = \beta_0 + \beta_1x_1 + \beta_2 x_2$ \\ \hline $A$ & 1 & 0 & $\mu_1$ = $\beta_0 + \beta_1$ \\ \hline $B$ & 0 & 1 & $\mu_2$ = $\beta_0 + \beta_2$ \\ \hline Placebo & 0 & 0 & $\mu_3$ = $\beta_0$ \\ \hline \end{tabular} \end{center}} \pause \begin{itemize} \item Is the effect of Drug $A$ different from the placebo? \pause $H_0: \beta_1=0$ \pause \item Is Drug $A$ better than the placebo? \pause $H_0: \beta_1=0$ \pause \item Did Drug $B$ work? \pause $H_0: \beta_2=0$ \pause \item Did experimental treatment have an effect? \pause $H_0: \beta_1=\beta_2=0$ \pause \item Is there a difference between the effects of Drug $A$ and Drug $B$? \pause $H_0: \beta_1=\beta_2$ \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Now add a quantitative explanatory variable (covariate)} \framesubtitle{Covariates often come first in the regression equation} \pause \begin{itemize} \item $x_1 = 1$ if Drug A, zero otherwise \item $x_2 = 1$ if Drug B, zero otherwise \item $x_3$ = Age \pause \item $E[Y|\boldsymbol{X}=\boldsymbol{x}] = \beta_0 + \beta_1x_1 + \beta_2 x_2 + \beta_3 x_3$. \pause \end{itemize} {\begin{center} \begin{tabular}{|c|c|c|l|} \hline Drug & $x_1$ & $x_2$ & $E(Y|\mathbf{x}) = \beta_0+\beta_1x_1+\beta_2x_2+\beta_3x_3$\\ \hline A & 1 & 0 & $\mu_1$ = $(\beta_0+\beta_1)+\beta_3x_3$ \\ \hline B & 0 & 1 & $\mu_2$ = $(\beta_0+\beta_2)+\beta_3x_3$ \\ \hline Placebo & 0 & 0 & $\mu_3$ = ~~~~~$\beta_0$~~~~~$+\beta_3x_3$ \\ \hline \end{tabular} \end{center}} \pause Parallel regression lines. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{More comments} %\framesubtitle{} {\begin{center} \begin{tabular}{|c|c|c|l|} \hline Drug & $x_1$ & $x_2$ & $E(Y|\mathbf{x}) = \beta_0+\beta_1x_1+\beta_2x_2+\beta_3x_3$\\ \hline A & 1 & 0 & $\mu_1$ = $(\beta_0+\beta_1)+\beta_3x_3$ \\ \hline B & 0 & 1 & $\mu_2$ = $(\beta_0+\beta_2)+\beta_3x_3$ \\ \hline Placebo & 0 & 0 & $\mu_3$ = ~~~~~$\beta_0$~~~~~$+\beta_3x_3$ \\ \hline \end{tabular} \end{center}} \pause \begin{itemize} \item If more than one covariate, parallel regression planes. \pause \item Non-parallel (interaction) is testable. \pause \item ``Controlling" interpretation holds. \pause \item In an experimental study, quantitative covariates are usually just observed. \pause \item Could age be related to drug? \pause \item Good covariates reduce MSE, make testing of categorical variables more sensitive. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Hypothesis Testing} \framesubtitle{Standard tests when errors are normal} \pause \begin{itemize} \item Overall $F$-test for all the explanatory variables at once \pause $H_0: \beta_1 = \beta_2 = \cdots = \beta_{p-1} = 0$ \pause \item $t$-tests for each regression coefficient: Controlling for all the others, does that explanatory variable matter? \pause $H_0: \beta_j=0$ \pause \item Test a collection of explanatory variables controlling for another collection \pause $H_0: \beta_2 = \beta_3 = \beta_5 = 0$ \pause \item Example: Controlling for mother's education and father's education, are (any of) total family income, assessed value of home and total market value of all vehicles owned by the family related to High School GPA? \pause \item Most general: Testing whether sets of linear combinations of regression coefficients differ from specified constants. \pause $H_0: \mathbf{L}\boldsymbol{\beta} = \mathbf{h}$. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Full versus Restricted Model} % Changing vocabulary: Reduced -> restricted \framesubtitle{Restricted by $H_0$} \pause \begin{itemize} \item You have 2 sets of variables, $A$ and $B$. Want to test $B$ controlling for $A$. \pause \item Fit a model with both $A$ and $B$: Call it the \emph{Full Model}. \pause \item Fit a model with just $A$: Call it the \emph{Restricted Model}. \\ \pause $R^2_F \geq R^2_R$. \pause \item The $F$-test is a likelihood ratio test (exact). \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{When you add the $r$ more explanatory variables in set $B$, $R^2$ can only go up} \pause %\framesubtitle{} By how much? Basis of the $F$ test. \pause {\LARGE \begin{eqnarray*} F & = & \frac{(R^2_F-R^2_R)/r}{(1-R^2_F)/(n-p)} \\ \pause &&\\ & = & \frac{(SSR_F-SSR_R)/r}{MSE_F} \pause ~ \stackrel{H_0}{\sim} ~ F(r,n-p) \end{eqnarray*} } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{General Linear Test of $H_0: \mathbf{L}\boldsymbol{\beta} = \mathbf{h}$} \framesubtitle{$\mathbf{L}$ is $r \times p$, rows linearly independent} \pause {\LARGE \begin{eqnarray*} F &=& \frac{(\mathbf{L}\widehat{\boldsymbol{\beta}}-\mathbf{h})^\top (\mathbf{L}(\mathbf{X}^\top \mathbf{X})^{-1}\mathbf{L}^\top)^{-1} (\mathbf{L}\widehat{\boldsymbol{\beta}}-\mathbf{h})} {r \, MSE_F} \\ &&\\ & \stackrel{H_0}{\sim} & F(r,n-p) \end{eqnarray*} \pause } % End size Equal to full-restricted formula. \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Are the $x$ values really constants?} \framesubtitle{$Y_i = \beta_0 + \beta_1 x_{i,1} + \cdots + \beta_{p-1} x_{i,p-1} + \epsilon_i$} \begin{itemize} \item In the general linear regression model, the $\mathbf{X}$ matrix is supposed to be full of fixed constants. \pause \item This is convenient mathematically. \pause Think of $E(\widehat{\boldsymbol{\beta}})$. \pause \item But in any non-experimental study, if you selected another sample, you'd get different $\mathbf{X}$ values, because of random sampling. \pause \item So $\mathbf{X}$ should be at least partly random variables, not fixed. \pause \item View the usual model as \emph{conditional} on $\mathbf{X}=\mathbf{x}$. \pause \item All the usual probabilities and expected values are \emph{conditional} probabilities and \emph{conditional} expected values. \pause \item But this would seem to mean that the \emph{conclusions} are also conditional on $\mathbf{X}=\mathbf{x}$. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{$\widehat{\boldsymbol{\beta}}$ is (conditionally) unbiased} %\framesubtitle{} {\Large \begin{displaymath} E(\widehat{\boldsymbol{\beta}}|\mathbf{X}=\mathbf{x}) = \boldsymbol{\beta} \pause \mbox{ for \emph{any} fixed }\mathbf{x}. \end{displaymath} } % End size \vspace{5mm} \pause It's \emph{unconditionally} unbiased too. \vspace{5mm} {\Large \begin{displaymath} E\{\widehat{\boldsymbol{\beta}}\} = E\{E\{\widehat{\boldsymbol{\beta}}|\mathbf{X}\}\} = E\{\boldsymbol{\beta}\} \pause = \boldsymbol{\beta} \end{displaymath} } % End size \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Perhaps Clearer} %\framesubtitle{} \begin{eqnarray*} E\{\widehat{\boldsymbol{\beta}}\} &=& E\{E\{\widehat{\boldsymbol{\beta}}|\mathbf{X}\}\} \\ \pause &=& \int \cdots \int E\{\widehat{\boldsymbol{\beta}}|\mathbf{X}=\mathbf{x}\} \, f(\mathbf{x}) \, d\mathbf{x} \\ \pause &=& \int \cdots \int \boldsymbol{\beta} \, f(\mathbf{x}) \, d\mathbf{x} \\ \pause &=& \boldsymbol{\beta} \int \cdots \int f(\mathbf{x})\, d\mathbf{x} \\ \pause &=& \boldsymbol{\beta} \cdot 1 = \boldsymbol{\beta}. \end{eqnarray*} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{Conditional size $\alpha$ test, Critical region $A$} \pause %\framesubtitle{} {\LARGE \begin{displaymath} Pr\{F \in A | \mathbf{X}=\mathbf{x} \} = \alpha \end{displaymath} \pause } % End size % \vspace{3mm} \begin{eqnarray*} Pr\{F \in A \} &=& \int \cdots \int Pr\{F \in A | \mathbf{X}=\mathbf{x} \} f(\mathbf{x})\, d\mathbf{x} \\ \pause &=& \int \cdots \int \alpha f(\mathbf{x})\, d\mathbf{x} \\ \pause &=& \alpha \int \cdots \int f(\mathbf{x})\, d\mathbf{x} \\ \pause &=& \alpha \end{eqnarray*} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{The moral of the story} \pause %\framesubtitle{} \begin{itemize} \item Don't worry. \pause \item Even though $X$ variables are often random, we can apply the usual fixed-$x$ model without fear. \pause \item Estimators are still unbiased. \pause \item Tests have the right Type I error probability. \pause \item Similar arguments apply to confidence intervals and prediction intervals. \pause \item And it's all distribution-free with respect to $X$. \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \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/appliedf18} {\footnotesize \texttt{http://www.utstat.toronto.edu/$^\sim$brunner/oldclass/appliedf18}} \end{frame} \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \begin{frame} \frametitle{} %\framesubtitle{} \begin{itemize} \item \item \item \end{itemize} \end{frame} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% # For scatterplot slides HS_GPA <- round(rnorm(100,80,7)); sort(HS_GPA) HS_GPA[HS_GPA>100] <- 100 Univ_GPA <- round(5 + .9 * HS_GPA + rnorm(100,0,5)); sort(Univ_GPA) cbind(HS_GPA,Univ_GPA) b <- coefficients(lm(Univ_GPA~HS_GPA)); b; b[1] x1 <- 60; x2 <- 97 y1 <- b[1] + b[2] * x1 y2 <- b[1] + b[2] * x2 plot(HS_GPA,Univ_GPA) lines(c(x1,x2),c(y1,y2)) % 3-d x1 = c(0,0,1,1); x2 = c(0,1,0,1) plot(x1,x2,pch=' ',xlab=expression(x[1]),ylab=expression(x[2])) text(1,0,'A'); text(0,1,'B'); text(0,0,'C')