












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!













Introduction
A homeowner recorded the amount of electricity in kilowatt-hours (KWH) consumed in his house on each of 21 days. He also recorded the numbers of hours his air conditioner (AC) was turned on and the numbers of times his electric clothes dryer (DRYER) was operated. His objective was to relate the KWH consumption to the AC and DRYER usage. In particular, he wanted to know how many KWH’s the AC used per hour and the number of KWH’s used in each run of the DRYER. Statistical regression analysis can serve this purpose.
Following are the data in tabular form:
KWH AC (hours)
DRYER (runs) 35 1.5 1 63 4.5 2 66 5.0 2 17 2.0 0 94 8.5 3 79 6.0 3 93 13.5 1 66 8.0 1 94 12.5 1 82 7.5 2 78 6.5 3 65 8.0 1 77 7.5 2 75 8.0 2 62 7.5 1 85 12.0 1 43 6.0 0 57 2.5 3 33 5.0 0 65 7.5 1 33 6.0 0
Figure 1 shows a plot of KWH versus AC.
In regression terminology, KWH is called the dependent variable and AC and DRYER are called the independent variables. The names “dependent” and “independent” come from the notion that the amount of KWH consumption depends on the amount of AC hours and DRYER usage. Usually, dependent variables are denoted “ y -variables” and independent variables are denoted “ x -variables.” The prime objective of linear regression analysis is to obtain an equation of the form
KWH = b 0 (^) + b AC 1 + b DRYER 2
that quantifies the dependency of KWH on AC and DRYER.
Simple Linear Regression Regression with a Single Independent Variable: KWH v AC
To get started, we shall investigate the dependency of KWH on AC, alone. Later, we shall explore the dependency of KWH on AC and DRYER simultaneously.
Figure 1 shows that KWH increases as AC increase, as you would expect. In this application the rate of increase is more important than the simple fact that there is an increase. We already knew that the air conditioner consumes electricity, and therefore that KWH will increase with AC. What we want to know is how much electricity the AC is using per hour; that is, the rate of consumption.
consumed per day by all other electrical devices in the house.
Some things to think about:
The process of obtaining the equation of the line and making inference about the coefficients is called Linear Regression Analysis. At the heart of linear regression analysis is a statistical model.
Simple Linear Regression Model
The expression “Simple Linear Regression” refers to regression applications in which there is only one independent and one dependent variable. A simple linear regression model is given by the equation
normally distributed.
The model equation (1) states that a value of y is equal to a linear function of x plus a random
electricity consumption example, y =KWH and x =AC would yield a simple linear regression
devices in the house per day. These parameters are population quantities and cannot be known exactly, but can be estimated from the data. The quantity ε is a random quantity that accounts for random deviation from expected KWH consumption. For example, suppose the AC is turned on
for x = eight hours on a particular day. What is the value of y = KWH consumption? The expected consumption, that is, the mean consumption in the conceptual sub-population of all
KWH consumption for the particular day in question is the mean for that population plus the random quantity ε to account for deviation from the mean for that particular day. That is to say,
The mean, i.e. expected, KWH consumption for a day with known AC usage cannot be
distributed independently with mean 0 and variance σ 2 , then the sub-population of KWH values
A subscript can be inserted on x and y when it is necessary to write the model equation in reference to a particular observation. Generically, the subscript “ j ” could be used to indicate the “ j th” observation, and the model equation would be
Fitting the Simple Linear Regression Model
In applications, the model is fitted to data using the method of least squares, giving the “prediction” equation
inserting a value of x into the prediction equation. The prediction equation is also useful to
value of x.
The caret above the parameters is called “hat” and is used to distinguish the actual parameters
“sigma-squared hat.” All these parameter estimates can be computed from five summary statistics shown in Table 1, where n is the total number of data points.
Accounting for Variation in Simple Linear Regression
Another aspect of regression analysis is accounting for the variation in the dependent variable as it relates to variation in the independent variable. A fundamental equation is
y − y =( y − y ˆ)+( y ˆ− y ). (7)
Equation (7) states that a deviation of a value of the dependent variable from the overall mean, y − y , is equal to the sum of a deviation of the dependent variable from the predicted value, ( y − y ˆ), plus the deviation of the predicted value from the overall mean, y ˆ^ − y. It can be shown
Thus, the deviation ( y ˆ − y )depends directly on the independent variable x. But the
deviation ( y − y ˆ)can be large or small, and positive or negative, for any value of x. So the
deviation ( y − y ˆ)does not depend directly on x. (The ( y − ˆ y )deviations are called “residuals.”)
It turns out that the sums of squares of the deviations in equation (7) obey a similar equation,
Σ( y − y )^2 =Σ( y − y ˆ)^2 +Σ( y ˆ− y )^2. (8)
The sums of squared deviations have names. The left side of the equation is call the total sum of
squares, and is denoted SS(Total)= Σ ( y − y )^2. The terms on the right side are the error and
regression sums of squares, SS(Regression) = Σ ( y ˆ − y )^2 and SS(Error)= Σ( y − y ˆ)^2. For brevity,
we write SSR=SS(Regression), SSE=SS(Error), and SST=SS(Total), and equation (8) takes the form
SST=SSR+SSE. (9)
The total sum of squares, SST, is a measure of the total variation in the values of the dependent variable y. The regression sum of squares, SSR, is a measure of the variation in y that is attributable to variation in the independent variable x. Finally, the error sum of squares measures the variation in y that is not attributable to changes in x. Thus equation (9) shows the fundamental partitioning of the total variation into the portion attributable to x and the portion not attributable to x. The coefficient of determination , usually denoted R^2 , is SSR divided by SST, and thus measures the proportion of total variation in y that is attributable to variation in x ,
R^2 = SSR/SST. (10)
Analysis of Variance for Simple Linear Regression
The generic analysis of variance associated with the regression is shown in Table 2.
Source of Variation
Degrees of Freedom DF
Sum of Squares SS
Mean Square MS
Regression 1
SS for Regression SSR
MS for Regression MSR Error n-2 SSE MSE Total n-1 SST
The column headed DF contains degrees of freedom for the sums of squares. The column headed MS contains mean squares , which are the corresponding sums of squares divided by the
Analysis of Variance Computations for Simple Linear Regression
The sums of squares in the ANOVA table can be calculated from the summary statistics as SSR= S (^) xy^2 / S (^) xx , SST = S (^) yy , and SSE = S (^) yy - S (^) xy^2 / S (^) xx. These computations for the KWH data are
and SSE = 9578.8 – 5609.7 = 3968.9.
For the KWH data, the analysis of variance (ANOVA) is
Source of Variation DF SS MS Regression 1 5609.7 5609. Error 19 3968.9 208. Total 20 9578.
This gives R^2 = 5609.7/9578.6 = .5856.
Prediction and Estimation of Sub-population Means
It is often useful to make inference about the mean of a sub-population corresponding to a given value of x , say x 0. The estimate of the subpopulation mean is obtained by inserting x 0 into the
variance of the sampling distribution is
Therefore the standard error is
s.e.( y ˆ ) = (MSE(1/n + ( x (^) 0 − x )^2 / S (^) xx )) .5^. (16)
A 95% confidence interval for the mean of the sub-population of y values corresponding to x = x 0 is
Consider the conceivable days when the AC could be turned on for 10 hours. A 95% confidence interval for the mean KWH consumption on those days is
81.25 ± 2.1(208.9(1/21 + (10 – 6.93) 2 /196.64)) .5^ , or 81.25 ± 9.38 = (71.87,90.63).
When used to predict a value of y , the relevant variance is the prediction variance
The relevant standard error is
s.e.( y ˆ^ − y ) = (MSE(1 + 1/n + ( x 0 (^) − x )^2 / S (^) xx )) .5^. (19)
A 95% prediction interval for the y value corresponding to x = x 0 is
Now consider the particular day when the homeowner had the AC turned on for 10 hours. A 95% prediction interval is
81.25 ± 2.1(208.9(1 + 1/21 + (10 – 6.93) 2 /196.64)).5^ , or 81.25 ± 31.77 = (49.48,113.02).
Figures 3 shows 95% confidence intervals for subpopulation means at each possible value of value of AC, ranging from AC=0 to AC=15. Constructed in this manner, the set intervals form a “band” about the regression line. You can see that several individual data points are outside the interval. This illustrates the important distinction between a confidence interval and a prediction interval. The 95% for a confidence interval at a given value of AD refers to the probability that
Graphical Diagnostics for Goodness of Fit
Residual values, y − y ˆ, should be approximately normally distributed and independent.
Therefore, if the residuals are plotted versus values of AC, the resulting plot should show a random scattering of points. Such a plot is called a “residual plot” and can be used to visually assess whether the assumptions for the regression analysis are valid.
There are primarily three patterns to look for. One is for points that fall distinctly outside the general pattern of other points. Such points are called “outliers.” Another is a “bend” in the pattern, which indicated the relationship between the dependent variable and independent variable is not linear. The last is a “funnel” shaped pattern, that indicates the variance is not constant across all values of the independent variable.
Figure 5 shows a plot of KWH residuals plotted versus AC values. This plot indicates no obvious violation of model assumptions.
Regression with a Single Independent Variable: KWH v DRYER
Now we investigate the dependency of KWH on DRYER. Figure 6 shows the linear regression results.
The regression equation is
KWH = 46.66 + 12.74(DRYER).
The analysis of variance table is
Source of Variation DF SS MS Regression 1 3429.7 3429. Error 19 6148.8 323. Total 20 9578.
This gives R^2 = 3429.7/9578.6 = .3581, compared with R^2 = .5856 in the regression on AC. Thus, more variation is attributable to AC than to DRYER.
Figure 8 shows confidence limits for expected KWH consumption for all values of DRYER. The bands is generally wider than the band in Figure 3 because of the larger value of MS(Error).
Figure 9 shows prediction limits for individual values of KWH for all values of DRYER.
end; run ;
proc print data=acplot; run ;
Title2 'Regression of KWH vs AC'; run ;
data acplot; merge acplot kilowatt; by ac; run ;
proc reg data=acplot; id ac; model kwh=ac/p; plot kwh*ac; output out=acplot1 p=acpred r=acresid1; run ;
proc gplot data=acplot1; plot acresid1ac; plot acresid1acpred; run ;
proc reg data=acplot; id ac; model kwh=ac/p clm cli; plot kwh*ac; output out=acplot2 p=acpred lclm=lcl uclm=ucl lcl=lpl ucl=upl; run ;
proc print data=acplot2; run ;
proc gplot data=acplot2; plot kwhac acpredac lclac uclac / overlay; plot kwhac acpredac lplac uplac / overlay; run ;
Title2 'Regression of KWH vs DRYER'; run ;
proc sort data=kilowatt; by dryer; run ;
data dryplot;
do dryer= 0 to 3 by .1 ; kwh=. ; output; end; run ;
proc print data=dryplot; run ;
data dryplot; merge dryplot kilowatt; by dryer; run ;
proc reg data=dryplot; id ac; model kwh=dryer/p; plot kwh*dryer; output out=dryplot1 p=drypred r=dryresid1; run ;
proc gplot data=dryplot1; plot dryresid1dryer; plot dryresid1drypred; run ;
proc reg data=dryplot; id ac; model kwh=dryer/p clm cli; plot kwh*dryer; output out=dryplot2 p=drypred lclm=lcl uclm=ucl lcl=lpl ucl=upl; run ;
proc print data=dryplot2; run ;
proc gplot data=dryplot2; plot kwhdryer drypreddryer lcldryer ucldryer / overlay; plot kwhdryer drypreddryer lpldryer upldryer / overlay; run ;