

























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























































































We will begin with the basics of linear regression, defining the variables of interest in regression analysis accompanied by some examples, and introducing the main objectives in regression analysis. Slide 3: Regression analysis is one of the simplest ways we have in statistics to investigate the relationship between two or more variables in a non-deterministic way. I will introduce the variables of interest in regression after reviewing a few examples. Regression modeling has wide applicability to fields like healthcare policy, finance marketing, elections, movie rating, bike share, you name it. In this course, I will cover two main modeling approaches, including standard linear regression and generalized linear regression. We'll begin today with the simplest regression analysis, which is simple linear regression. Slide 4: Throughout the course, we will regularly come back to a set of data examples to help demonstrate in practice the theories taught in the course. Our first example is a data set from a company selling medical supplies to hospitals, which is considering the effectiveness of new advertising program. Specifically, in this data example we will assess whether there is a relationship between sales and their expenditure on advertising. Slide 5: We have data for 25 offices and for each office we begin our analysis with the two variables of interest; one is sales, measured in thousands. And the other one is advertising expenditure, measured in hundreds. If you look at the first row of these
data, you have a value of 963 in sales, which means, for that specific office, the amount of sales is $963,000. For advertising expenditure, the amount of the expenditure is $37,427. Slide 6: The second example is related to economic theory. Here, we are interested to evaluate and test the principle of purchasing power parity, which states that over long periods of time, exchange rate changes will tend to offset the difference in inflation rates between two countries. In a perfect world, meaning an efficient international economy, exchange rates would give each currency the same purchasing power in its economy. What we're trying to identify here is the relationship between the changes in currency rates and inflation rates across multiple countries. Slide 7: For this example, we have data across 41 countries, including developed and developing countries. We will study the relationship between inflation difference and exchange rate change. Slide 8: In the third example, we will study data related to the presidential elections in 2000. State results, tallied on election night, gave 246 electoral votes to the republican candidate, George W. Bush, and 255 to democratic candidate, Al Gore, with three states too close to call in the election night. Among those three states was Florida, which really mattered in the final count. As such, in Florida, there was a recount of votes for weeks after the election date. After this recount, the court decision was that George W. Bush won Florida by a margin of 537 votes, just a very, very small number of additional votes. In this analysis, we will study whether there is a specific aspect in this election that could have overturned the decision on which candidate could have won the presidential election in 2000. Particularly, in one specific county, Palm Beach County, the count for the independent candidate, Buchanan, was much higher than expected. In this data example, we will assess the relationship between the votes of the independent candidate and the republican candidate and identify whether Palm Beach County was indeed an outlier. Slide 9: I will go back now to overview the basics of regression. When we speak of regression data, what do we mean? In regression analysis, we have one variable that we're
it with, for example, different types of medication. What is fixed here, is the type of medication. What varies, is the change in the LDL level. In a second example, we're interested in our relationship between driving habits and fuel efficiency. Again, here, the variable of interest is fuel efficiency, which could be different from one car brand to another. It also could be different with the driving habits of the driver, like average driving speed. In this example, the response variable is the fuel efficiency measured by miles per gallon, where the predicting variable is the average driving speed. In a third example, we are interested in a relationship between college GPAs and SAT scores. The SAT score is the score of a test that students take at the end of the high school. Many colleges in the US, if not all, are admitting students based on their SAT scores. The SAT score is the predicting variable, because it predicts the admission and it may predict how students perform in a college, measured by the GPA, or the college grade point average. Slide 12: But what is the underlying use of the regression modeling? Basically, by using a regression model, we try to explain and hence predict the total variability of Y (the response or dependent variable) by using X (the predicting or explanatory variable). Some variability is explained by 𝑥, and some due to random error. Slide 13: There are three objectives in regression. One is Prediction. We want to see how the response variable behaves in different settings. For example, for a different location, if we think about a geographic prediction, or in time, if we think about temporal prediction. Another objective is Modeling, specifically modeling the relationship
between the response variable and the explanatory or predicting variables. A third objective is testing hypotheses of association relationships. Why restrict to linear models? Well, they are simple to understand and they're simple mathematically. But most importantly, they work well for a wide range of circumstances (though definitely not for all). It's a good idea, when carrying out statistical modeling in general, to remember the words of the famous statistician, George Box. "All models are wrong, but some are useful." We do not believe that the linear model represents a true representation of reality. Rather, we think that, perhaps, it provides a useful representation of reality. Another useful piece of advice comes from another very famous statistician, John Tukey. "Embrace your data, not your models." While simple regression is a simple model, it has wide applicability, and it can be generalized to more complex models. Slide 14-15: Here I will review the general model that we will be using throughout this course. A simple deterministic relationship between two factors, herein X and Y, is a linear relationship. We can generalize that to a relationship between two factors, in a non- deterministic way, as the first model, which is the simple linear regression. We can extend that to a model where we include more than one predicting variable, which is called multiple linear regression. This model is going to be covered in a different unit of this course. Further, we can extend the linear regression model to polynomial regression, capturing more complex relationships between the predicting variable and the response. For example, third regression models the relationship between Y and a quadratic relationship with X.
Within the simple linear regression topic, we're going to begin with the modeling framework, particularly the data structure, the model formulation, and assumption. We'll also learn about the estimation approach of the simple linear regression. I will also illustrate the estimation approach using a data example. Slide 3: In simple linear regression, the objective is to fit a non-deterministic linear model between the predicting variable x and the response variable Y, which is equivalent to estimating the parameters β 0 and β 1 , where β 0 is the intercept parameter, and β 1 is the slope parameter. I will provide the interpretation of these parameters later in this lesson. In this model formulation, epsilon is the deviance of the data from the linear model. Slide 4: The goal is to find the line β 0 + β 1 x that describes the linear relationship, that is, to find β 0 and β 1 , such that the line fits the data. How can we do that? If we plot the x values against the response data y using a scatter plot, we would like to identify a line that fits the scattered data points. But we can fit many such lines. The question is, how to find the best line? What means “best line”? More specifically, based on what criterion shall we identify a best line? Slide 5-6:
To understand the approach for fitting the regression line, we will first need to overview the model. First, we start with identifying the data structure. For simple linear regression, we have pairs of data, where each pair consists of a value for the response variable, and a value for the predicting variable. We have n such pairs. The model formulation relates x and y, in this case, in a linear fashion. Another important aspect in the modeling framework is stating the model assumptions. For simple linear regression, the assumptions consist of: ● linearity/mean zero assumption, which means that the expectation of the deviances is zero. ● constant variance assumption, which means that the variance (represented in statistics by the Greek letter sigma squared) of the error terms or deviances is constant for the given population. ● Independence assumption which means that the deviances are independent random variables. Later we'll also assume that error terms are normally distributed. Let's go back to the assumptions, and digest each one at a time. The linearity/mean zero assumption means that the expected value of the errors is zero. That is, it cannot be true that for certain subgroups in the population, the model is consistently too low, while for others, it's consistently too high. A violation of this assumption will lead to difficulties in estimating β 0 , and means that your model does not include a necessary systematic component. Constant variance assumption means that it cannot be true that the model is more accurate for some parts of the data, and less accurate for other parts of the data. A violation of this assumption means that the estimates are not as efficient as they could be in estimating the true parameters and better estimates can be derived, it also results in poorly-calibrated prediction intervals. The assumption of independence means that the deviances, or in fact the response variables are independently drawn from the data-generating process. That is, it cannot
Slide 8: One approach is to minimize the sum of squared residuals or errors with respect to β 0 and β 1. Specifically, we minimize the sum of the squared differences between data and the model as provided on the slide. This translated into finding the line such that the total squared deviances from the line is minimized. Slide 9: This is further translates into an optimization problem with respect to β 0 and β 1. The solution to this optimization or minimization problem gives the estimators for β 0 and β 1 , given by β 0 hat and by β 1 hat. We put a "hat" ("^") on top of those estimators to differentiate between the estimated parameters and the true but unknown parameters that are being estimated. So β 0 hat is different than β 0 , and β 1 hat is different than β 1. I will note here that In standard regression models, the least squared errors criterion is used, but other criteria can be used as well. The estimated regression line would be different, depending on the criterion used. For example, we could replace the squared errors to consider the absolute value of the errors instead which would result into the so-called median or robust regression. Again in this course, we would only consider the standard linear regression where the criterion is the sum of the squared errors. Slide 10:
Let's take a closer look at the derivation of those estimators. Again, what we're interested is to minimize the so-called sum of least squares or the sum of squared errors with respect to β 0 and β 1. We will perform this optimization problem by taking the first-order derivatives of the objective function and equate those to zero. We now have a system of two equations and two unknowns. Solving these equations will give us β 0 hat, and β 1 hat. Slide 11: On the slide, I am describing some notation that will be useful throughout this module as well as Module 2. Here we have three sums of squares called Sxx, Sxy and Syy as provided on the slide. For those more math inclined, an easy exercise is to prove the second equalities in each case!
In this slide and the next two other slides, I will introduce statistical properties of the estimator of the variance parameter. The sampling distribution of the estimator of the variance is chi-square, with n - 2 degrees of freedom (more on this in a moment). The sampling distribution is only under the assumption of normality of the error terms hence this is where we need the assumption of normality. Note that assumption of normality was not used in the estimation of the model parameters. It only is needed for the statistical properties of the estimated parameters. We use the epsilon_i hat as proxies for the deviances or the error terms. We don't have the deviances because we don't have β 0 and β 1. But if we replace β 0 and β 1 with β 0 hat and β 1 hat, we get the deviances with a hat, and now we are estimating sigma square, based on those residuals. The estimator of the variance of the error terms is now the sample variance. Slide 14: In order to understand the statistical properties of the variance estimator of the error terms in regression, I will review here the sample variance estimation approach for normal data. We start with Z’s that are normally distributed data with mu (the mean) and sigma square (the variance). We often use the notation S square, representing the sum of the Zi minus their average, squared, divided by n -1. This is called the sample variance estimator. From basic statistics, the sampling distribution of S square is the chi-square with n - degrees of freedom.
Why n -1 degrees of freedom? We lose a degree of freedom because we replace the true parameter mu with z bar. Now let's go back to the estimator of sigma square under simple linear regression. Our estimator looks just like the sample variance estimator, except that we use n – 2 degrees of freedom. Why is that? Slide 15: This is because we've replaced the deviances or the error terms with the residuals. For this reason, we lose two degrees of freedom since we replaced the two parameters β 0 and β 1 with their estimators to obtain the residuals. In this case, we are using two degrees of freedom, each one degree of freedom for each parameter. This is why under the normality assumption, the sampling distribution of the variance estimator is chi- square with n - 2 degrees of freedom. To summarize, the variance estimator has a chi-square distribution with n-2 degrees of freedom. This is called the sampling distribution of the variance estimator. To remind you again, the variance estimator is also called the mean squared error or in short MSE. Slide 16: Let’s now go back to the estimated regression parameters. In simple linear regression, we're interested in the behavior of β 1. We can expect β 1 to be positive, negative, or close to zero. If we have a positive value for β 1 , then that's consistent with a direct relationship between the predicting variable x and the response variable y. For example, higher values of height are associated with higher values of weight in
● quantify the amount of increase in the sales for each additional sales in dollars invested in advertising expenditure; ● predict the sales for a specific value of an advertising expenditure, for example $30,000; ● estimate the error variance; and ● predict sales for a very large amount of advertising expenditure, for example $100,000.
The first step in using the R statistical software is to read the data from a file into R. One common function used in R to read data is the command read.table(), in which we will need to specify the data file, the separator of the data values in the file, and whether the columns in the data file have names or not. We also want to extract specific variables from these data. In this case sales is in the first column, and advertising expenditure in the second column. Fitting a linear regression model is very simple in R. We can use the function lm(). We will need to specify the response variable, in this case sales, on the left, and the predicting variable, which is the advertising expenditure, on the right, separated by a tilde (~).
What I'm showing next the summary of the model. It's a portion of that summary from which we can obtain the estimated coefficients, the estimated regression coefficients β 0 hat and β 1 hat, and the estimated variance. From this output the estimated intercept is -157.33. The estimated slope is 2.7721 and the estimated standard deviation, not the variance, is 101.4. You can see those values highlighted in the output. MSE which is the estimate of the variance, sigma^2 is 101.4^2. Slide 21: Let's go back to the questions we wanted to address. The estimated regression coefficients from the output are -157.3,2.77. Based on those estimates we can now write the regression equation: sales = estimated intercept + estimated slope * advertising expenditure To interpret the coefficients, we have to keep in mind the fact that sales and advertising expenditure are measured in different units. Sales data are measured in thousands, and advertising expenditure data are measured in hundreds. Thus, we interpret that the sales increased by $2,770 with each additional $100 in expenditure for advertisement. Or, we can also interpret that the sales increase with $27.7 with each dollar invested in advertising expenditure. If we want to quantify how much more we would derive in sales with an additional $1,000 in advertising expenditure, again, we have to convert $1,000 in advertisement expenditure into the units used for expenditure data, which is equivalent to 10 units, or 10 hundreds; to address question C, we plug in the expenditure value as 10 units in the prediction of sales, specifically, 10 times the estimated value for the slope gives 27. units of sales, which is equivalent to $27,700 increase in sales. Thus, the increase in sales with every additional thousand dollars in expenditure is $27,700. Pay particular attention to the units of both the response and the predicting variables for a correct interpretation of the model. Slide 22: If we were interested to predict the sales for an advertisement expenditure of $30,000, again we have to convert $30,000 into original units, corresponding to 300 units. We plug this in the estimated regression line, and we obtain $673,000 in sales. What is the estimate of the error variance? Remember what we get from the output is not the variance, it's the estimated standard deviation of the error
We’ll now move from estimation to statistical inference. In this lesson we'll learn about statistical properties of the estimated coefficients and how to use statistical properties in making inferences such as confidence intervals and hypothesis testing. I will also illustrate statistical inference on the model parameters using a data example. Slide 3: We will begin with deriving the statistical properties of the estimator for β 1 .The expectation of β 1 hat is equal to β 1 which is the true parameter, and the variance of this coefficient of this estimator is sigma square divided by S_XX. I will show you a brief derivation of the expectation of β 1 hat and we can use the same sequence of derivations for the variance of β 1 hat. Let's go back to the formula of the estimator for β 1. We could write that as the sum of a constant times the random variable Yi where that constant is ci. What that means is that β 1 hat is a linear combination of random variables. We know from basic statistics that the expectation of a linear combination of random variables is equal to the linear combination of the expectations. Now we replace the expectation of the random variable of the response variable Yi with the linear relationship in X. Further, we divide that into two sums and now the first sum is equal to zero, because the sum of the constants c_i’s is zero, and the sum of the constants time Xi is equal to one.
Thus the expectation of the estimator for the slope parameter is exactly β 1 .This property, the fact that the expectation of the estimator is exactly the true parameter that we're estimating, is called unbiasedness. What that means is that β 1 hat is an unbiased estimator for β 1. Thus although β 1 is unknown, we have that in expectation the slope estimator is equal to the true parameter. This is an important statistical property of an estimator. Slide 4: Let's dive more in the statistical properties of this estimator. I will remind you that β 1 hat is a linear combination of the response variables, Yi. Under the normality assumption, β 1 hat is thus a linear combination of normally distributed random variables, and thus β 1 hat is also normally distributed. Along with the expectation from the previous slide as well as a similar derivation for the variance of the estimator, now we get the distribution for β 1 hat, which is a normal distribution with mean β 1 and variance sigma squared divided by Sxx. Slide 5: However, the sampling distribution of β 1 hat is not useful because sigma squared or the variance of the error terms is unknown. In order to get a full specification of this distribution, we must replace sigma squared with an estimator. We can use the estimator we discussed in the previous lesson, the mean squared error, or the sum of squared residuals divided by N - 2. Because this estimator has a chi-square distribution with N - 2 degrees of freedom, the sampling distribution of β 1 hat becomes a t distribution with N - 2 degrees of freedom.