STAT 211 Topic 10

From Notes
Jump to navigation Jump to search

« previous | Thursday, April 14, 2011 | next »


Simple Linear Regression

Predicting linear relationships between two variables X and Y: Y=A+BX, where rvs A,B∼Normal.

Goal: Find the line such that the squared distance (so distance values are positive) between the predicted and observed values is minimized.

What the line tells us:

  • Estimates/Predicts values (interpolation within range; extrapolation outside of range)
  • Describe ratio between two variables (slope)
y=β0+β1x+ϵ
Regression Model Equation
  • β0, β1, and x are assumed to be unknown fixed parameters.
  • ε Error variable: ϵ∼Normal(0,σ2) (σ2 is unknown)
  • Therefore y∼Normal(β0+β1x, σ2)

We have estimates for x (sample data), but we need estimates for β0 and β1.


Least Squares

Given points (x1,y1),(x2,y2),…,(xn,yn), our regression model is:

yi=β0+β1xi+ϵi

Squared distance between points is given by (yi−(β0+β1xi))2. Therefore the sum of squared differences is:

S(β0,β1)=∑i=1n(yi−β0−β1xi)2

Find β0 and β1 such that S(β0,β1) is minimized. (Take derivative, equate to zero, and solve)


Estimated Solutions: (both have normal distribution regardless of sample size)

β^0=∑(xi−x¯)(yi−y¯)∑(xi−x¯)2∼N(β0, )β^1=y¯−β^1x¯∼N(β1, σ2∑(xi−x¯)2)

Therefore, the final equation becomes

y^i=β^0+β^1xi

The fitted (predicted) value of yi is y^i=β^0+β^1xi


Residual (observed − fitted; yi−y^i) can be plotted to check how well the line fits.


All computer stat systems will return a coefficient of determination R2 value. This value is always between 0 and 1, and R2 close to 1 implies a better fitting line.


Tests for β1

Since we don't know σ, we can substitute an estimate sϵ (see below), then the standard deviation of β1 is a T-distribution with df n−2.

Therefore, we can do confidence intervals (β^1±tα/2⋅sβ^1) and t-test for H0: β1 = β10 (t=β^1−β10sβ^1)


Estimating σ2

Minimum value for D is the Error Sum of Squares:

D=∑i=0n(yi−(β^0+β^1xi))2=SSE

To obtain estimate for σ2, we divide SSE by the (remaining) degrees of freedom (after estimating β1 and β2) n−2:

sϵ=σ^=SSEn−2

ANOVA for Regression

SST=SSR+SSE=∑i=1n(yi−y¯)2Total Sum of SquaresSSE=∑i=1n(yi−(β^0+β^1xi))2Error Sum of SquaresSSR=SST−SSE=∑i=1n(y^i−y¯)2Regression Sum of SquaresR2=SSRSSTCoefficient of Determination

Source Sum of Squares Degrees of Freedom Mean Square f statistic
Regression Error SSR 1 MSR MSR / MSE
Error SSE n−2 MSE
Total SST n−1


Predicting with Regression

Suppose we have a new value that we want to estimate: x*

2 possible ways to calculate this:

  1. mean response (only think of value of regression model line): E(y|x=x*)=β^0+β^1x*
  2. prediction (include error variable ε): y^=β^0+β^1x*

Basically plugging in a new x value into the model equation to obtain a y^ estimate.

Mean Response

We want to narrow the range and reduce variance by as much as possible, so we disregard the variance of ε.

Calculate 100(1-α)% confidence interval for response with:

β^0+β^1x*±tα/2,n−2⋅sϵ1n+(x*−x¯)2∑(xi−x¯)2

Prediction

Because the regression model has the ε term, the prediction is actually within a range.

β^0+β^1x*±tα/2,n−2⋅sϵ1+1n+(x*−x¯)2∑(xi−x¯)2

Correlation Coefficient

Show how strongly related two random variables are.

Note: If X and Y are independent, then correlation is 0
Corr(X,Y)=ρX,Y=Cov(X,Y)V(X)V(Y)

where Covariance is

Cov(X,Y)=E(XY)−E(X)E(Y)


For a population where we do not know the pdf (ƒ(x, y)), we can estimate the sample correlation coefficient using

r=∑i=1n(xi−x¯)(yi−y¯)∑i=1n(xi−x¯)2∑i=1n(yi−y¯)2