Download Project - Review Notes - Regression Analysis | ISQS 5349 and more Study Guides, Projects, Research Information Technology in PDF only on Docsity!
Andrew J. Patterson
Regression Definitions : Regression is the study of how the distribution of Y(response variable) changes for different values of X(predictor).
- Stochastic- a stochastic process is a random process
- Deterministic- a deterministic process has a known outcome.
SIMPLE LINEAR REGRESSION
pg. 10
- The model is stated as Yi = β 0 + β 1 Xi + ≤i where:
Yi is the value of the response variable of the ith^ trial. β 0 is the mean of the pdf of Y when X = 0. β 1 is the increase in the expected value of Y associated with a one unit increase in X. ≤i is a random error term with E{≤i} = 0, and variance V ar{≤i} = σ^2 {≤i} = σ^2
Ordinary Least Squares
pg. 17
- Least Squares calculates the parameters β 0 β 1 such that the sum of the square of the residuals is a minimum, i.e., let
Q =
∑^ n
i=
(Yi − β 0 − β 1 Xi)^2
The least squares method chooses β 0 β 1 , such that Q is a minimum.
Residuals
pg. 25
- the ith^ residual is defined as the difference between the observed and the predicted values, i.e. ei = Yi − Yˆi = Yi − (b 0 + b 1 Xi) = Yi − b 0 − b 1 Xi
- a property of the residuals is ∑n
i=
ei = 0
Estimation of Error Terms Variance σ^2
pg. 27
∑^ n
i=
(Yi − Yˆi)^2 =
∑^ n
i=
e^2 i. SSE has n-2 df.
- Mean Square Error: M SE = SSEn− 2 =
∑ (Yi− Yˆi)^2 n− 2 =
∑ (^) e 2 i n− 2
- MSE is an unbiased estimator of σ^2. i.e., E[M SE] = σ^2
INFERENCES CONCERNING β 1
pg. 44
b 1 =
(Xi − X¯)(Yi Y¯ ) ∑ (Xi − X¯)^2
Var {b 1 } = σ^2 {b 1 } = σ^2 ∑ (Xi − X¯)^2
To estimate the of the variance of b 1 , since we don’t know the correct σ^2 ,we use
s^2
M SE
(Xi − X¯)^2
Confidence Interval for β 1
pg. 50
- the confidence interval for β 1 is
b 1 − t(1 − α/2; n − 2)s{b 1 } < β 1 < b 1 + t(1 − α/2; n − 2)s{b 1 }
Tests Concerning β 1
pg. 51
- let the test statistics t∗^ = (^) s{bb^11 }
- to test H 0 : β 1 = 0 vs. H 1 : β 1 6 = 0.
We would reject the null hypothesis if |t∗| > t(1 − α/2; n − 2)
INTERVAL ESTIMATION OF E{Yh}
pg. 56
[
1 n +^ ∑(X h−^ X¯)^2 (Xi− X¯)^2
]
Confidence Interval for E{Yh}
pg. 59
Yˆh − t(1−α/2;n−2)s
Yˆh
< E
Yˆh
< Yˆh + t(1−α/2;n−2)s
Yˆh
= Yˆh−t(1−α/2;n−2)
M SE
[
n
(Xh − X¯)^2 ∑ (Xi − X¯)^2
] 1 / 2
< E
Yˆh
< Yˆh+t(1−α/2;n−2)
M SE
[
n
(Xh − X¯)^2 ∑ (Xi − X¯)^2
] 1 / 2
- Prediction Interval for Yh
- s^2 {pred} = M SE
[
1 + (^1) n + (Xh−^ ∑ X¯)^2 (Xi− X¯)^2
]
Y^ ˆh − t(1−α/2;n−2)s{pred} < Yˆh < Yˆh + t(1−α/2;n−2)s{pred}
= Yˆh−t(1−α/2;n−2)
M SE
[
n
(Xh − X¯)^2 ∑ (Xi − X¯)^2
] 1 / 2
< Yˆh < Yˆh+t(1−α/2;n−2)
M SE
[
n
(Xh − X¯)^2 ∑ (Xi − X¯)^2
] 1 / 2
- notice the only difference between the C.I. and the P.I. is the 1 under the √^ for the standard deviation
TRANSFORMATIONS
pg. 126
- see website for in depth explanation of using transformation
- if there is skewness, take the log
- you can also group them(binning)
TESTS FOR ASSUMPTION
pg. 110
- Linearity:
- to test H 0 : E(Y ) = β 0 + β 1 X vs. H 1 : E(Y ) 6 = β 0 + β 1 X we would fit the data to the model E(Y ) = β 0 + β 1 X + β 2 X^2. Then we would perform a test of H 0 : β 2 = 0;
- Non Constant Variance:
- to test for non constant variance we take the residual plot and divide the data around the median and test for equal variance in the 2 groups with the F-test.
MULTIPLE REGRESSION
pg. 215
- Model is Y = β 0 + β 1 X 1 + β 2 X 2... βkXk + ≤ in matrix terms we write Y = Xβ + ≤
Y
n× 1
Y 1
Y 2
Yn
X
n×p
1 X 11 X 12... X 1 ,p− 1 1 X 21 X 22... X 2 ,p− 1 .. .
1 Xn 1 Xn 2... Xn,p− 1
β
p× 1
β 1 β 2 .. . βp
p× 1
≤n
Here p is the number of βs The Least Squares estimate of β is
βˆ = (^) b p× 1
= (X′X)
p×p
− 1 (X′Y ) p× 1
Tests/Intervals
- To test H 0 : βj = 0, the t-stat is tj = (^) s.e.b{jbj }
- we reject H 0 if tj > t(α/ 2 , n − p)
- we get s.e.{bj } from the covariance matrix of the vector b
Cov(b) = σ^2 (X′X)−^1
the above matrix is a diagonal matrix if assumptions (2) and (3) hold. So let Cjj be the diagonal of (X′X)−^1 , then the StdDev(bj )=s.e.{bj }=σ
Cjj
- if we don’t know σ^2 , then estimate it with
σˆ^2 = MSE =
n − p
SSE =
n − p
(Yi − Yˆi)^2
- so that the t-statistic becomes tj =
bj √ MSE · Cjj
Full/Restricted F-test
- Example: the Full model is E(Y ) = β 0 + β 1 X 1 + β 2 X 2 + β 3 X 3 Reduced Model: E(Y ) = β 0 + β 2 X 2
- to test H 0 : β 1 = β 3 = vs. H 1 : β 1 6 = 0 or β 3 6 = 0 the test statistic is
F ∗ =
SSER −SSEF dfR −dfF
SSEF dfF
- Reject H 0 if F ∗ > F (1 − α, dfR − dfF , dfF )
CONFOUNDING VARIABLES
A confounding variable is an external variable that affects both the response(Y) and predictor(X) variables. To control confounding variables we first identify them, and then include them in the model. If they are truly a confounding variable, then the other variable will show to be insignificant.
INTERACTION
pg. 224
- interaction occurs when the effect of one predictor variable depends on the levels of other predictor variables.
- Example: Suppose our model is E(Y ) = β 0 + β 1 X 1 + β 2 X 2. Also assume that β 2 changes for different values of X 2.
- We change our model to account for interaction as E(Y ) = β 0 + β 1 X 1 + β 2 X 2 + β 3 X 1 X 2
Effect Heredity
- this simply says that we include all lower-order terms when higher-order terms are present. Higher-Order Terms Lower-Order Terms X^2 X X 1 X 2 X 1 , X 2 X 1 X 2 X 3 X 1 , X 2 , X 3 , X 1 X 2 , X 1 X 3 , X 2 X 3
Multicollinearity
pg. 285
- Multicollinearity is when there are correlations between one or more predictor variables.
- perfect multicollinearity means that a column is an linear combinations of other columns in the X matrix
- Recall: Var {bj } = σ^2
Cjj (from (X′X) diagonal).
Cjj =
(1 − R^2 j )(n − 1)s^2 xj
where R^2 j = R^2 when you regress Xj on all other X’s
PRESS
pg. 345
- used for predicting out of sample data
- so what we do is remove a sample from our data set, find our regression function, and then evaluate how well it predicted the deleted sample with
P RESS =
n
∑^ n
i=
(Yi − Yˆi(i))^2
where Yˆi(i) is the prediction of case i, where case i was deleted from the data
- PRESS tells you how well your model will fit outside data
- unlike Cp, you don’t have a full model assumption
Summary
Criteria Comment Cp full model assumption R^2 R^2 inc. when you add a variable problem of overfitting R^2 a adds penalty, but not enough PRESS computational difficulities SSE on validation sample computation difficulties, need lots of data
VARIABLE SELECTION
pg. 347
Forward Selection
- enter the most significant variable, based on some threshold
- continue to enter variables until non are significant
- if a new variable causes an existing one to be insignificant, leave it in
Backward Selection
- start with the full model
- remove variables one at a time based on p-value
- stop when all variables left are significant, based on some threshold
Stepwise Selection
- enter the most significant variable, based on some threshold
- continue to enter variables until non are significant
- if a variable becomes insignificant when a new variable is entered, then you delete it
OUTLIERS
3 ways to see outliers are
- remoteness in X-space
- remoteness in prediction(Y -space), also called a residual outlier
- remoteness in both X and Y
Statistics For Identifying Outliers
Hat Diagonal
hii = X i′ (X′X)−^1 Xi
- where Xi denotes the ith^ case, or X − i′^ is the ith^ row of X
- higher hii means more remote
Deleted Student Residual
rstudent =
ei(i) √ Var
ei(i)
Cook’s D
D =
ei(i)hii p · MSE
- large D means observation i has a large effect on the fitted regression function
LEAST-MEDIAN SQUARES(LMS)
BOOTSTRAPPING
- used when normality does not hold
C.I. for β
bj − g(1 − α/2)s.e.{bj } < βj < bj − g(α/2)s.e.{bj }
- where g is the distribution of (^) s.e.bj^ −{bβjj }
- this g is estimated with the data
METHOD
- let b 0 , b 1 be the OLS estimates
- let e 1 , e 2 ,... , en be the OLS residuals
- then we create bootstrap data sets Set 1 Y 1 ∗ = b 0 + b 1 X 1 + ≤∗ 1 Set 2 Y 2 ∗ = b 0 + b 1 X 2 + ≤∗ 2 Set n Y (^) n∗ = b 0 + b 1 Xn + ≤∗ n
- we let ≤∗^ be a with replacement sample from the original ≤s
- from Set 1 we get b∗ 0 , b∗ 1 , t∗ 0 = b
∗ 0 −b 0 s.e.{b∗ 0 } , t
∗ 1 =^
b∗ 1 −b 1 s.e.{b∗ 1 } ,
- we repeat step 5 and generate NBOOT data sets.
- we can get g(α/2) and g(1 − α/2) by taking the α and 1 − α percentiles of t∗ 0 , t∗ 1
PARAMETER INTERPRETATION
Category Model NE E(Y ) = (β 0 + β 2 ) + (β 1 + β 5 )X 1 NC E(Y ) = (β 0 + β 3 ) + (β 1 + β 6 )X 1 S E(Y ) = (β 0 + β 4 ) + (β 1 + β 7 )X 1 W E(Y ) = β 0 + β 1 X 1
STEP FUNCTION REGRESSION
Goal: Compare Y when % HS is low versus when % HS is high. Model: Y = β 0 + β 1 D + ≤
where
D =
0 if X < c 1 if x ≥ c
Here, c is any constant that divides X into high and low parts.
Binning
We define dummies for all bins
D 1 =
1 if X < 10 0 otherwise
D 2 =
1 if 10 ≤ X < 20 0 otherwise
D 3 =
1 if 20 ≤ X < 30 0 otherwise
The model: Y = β 0 + β 1 D 1 + β 2 D 2 + β 3 D 3 + ≤
Individual Models Category Model X < 10 E(Y ) = β 0 + β 1 10 ≤ X < 20 E(Y ) = β 0 + β 2 20 ≤ X < 30 E(Y ) = β 0 + β 3 30 ≤ X < 40 E(Y ) = β 0
Ordinal Score Model
We define the ordinal score S as
S =
1 if X < 10 2 if 10 ≤ X < 20 3 if 20 ≤ X < 30 4 if X ≥ 30
S E(Y) 1 β 0 + β 1 2 β 0 + 2β 1 3 β 0 + 3β 1 4 β 0 + 4β 1
PIECEWISE LINEAR REGRESSION
E(Y ) =
β 0 + β 1 X if X < 12 γ 0 + γ 1 X if X ≥ 12 There is usually the constraint that
β 0 + β 1 (X = 12) = γ 0 + γ 1 (X = 12)
This forces the lines to meet at X = 12 The model is then
Y = β 1 + β 1 X + β 2 D(X − 12) + ≤
where
D =
0 if X < 12 1 if X ≥ 12
Category Model X < 12 Y = β 0 + β 1 + ≤ X ≥ 12 Y = (β 0 − 12 β 2 ) + (β 1 + β 2 )X + ≤
if we want to model a discontinuity at X = 12, then we would change our model to
Y = β 1 + β 1 X + β 2 D(X − 12) + β 3 D + ≤
WEIGHTED LEAST SQUARES - WLS
- WLS corrects problems with heteroscedasticity.
- it can get you more efficient of accurate estimates
- correct standard errors (assuming you choose the correct weights)
- correct prediction intervals.
WLS Method and Assumptions
- suppose Yi = β 0 + β 1 Xi 1 + β 2 Xi 2 + · · · + βkXik + ≤i
if we assume Var {≤i} =
σ^2 wi
- the whole caveat of WLS is choosing the wi’s. Note: wi = σ
2 Var{≤i} =^
σ^2 Var{Yi}
- so wi ∝ (^) Var^1 {Yi}. So the closer the value is to the regression line, the higher the weight it gets.
Maximum Likelihood Estimation
The model is matrix form is Y n× 1
= X
n×p
β p× 1
n× 1
- this satisfies (0), (1), (4) - (2) and (3) are replaced by the assumption that Cov(Y ) = V
- the Likelihood function is then
f (Y ; β, V )L(β, V ; Y ) =
(2π)n/^2 |V |^1 /^2
exp
(Y − Xβ)′V −^1 (Y − Xβ)
- the ML estimates of β, V are the values that maximize f (Y ; β, V ).
- the log likelihood function is
ln L(β, V ; Y ) = −
n 2
ln(2π) −
ln |V | −
(Y − Xβ)′V −^1 (Y − Xβ)
- the estimate of β is the same as with OLS, if we use the MLE of V
β^ ˆM L = (X′^ VˆM LX)−^1 X′^ Vˆ (^) M L−^1 Y
LIKELIHOOD RATIO TESTS
- H 0 :Restricted Model
- H 1 :Full Model
- the test statistic is χ^2 = 2(ln LF − ln LR). LF is the likelihood of the full model and LR is the likelihood of the reduced model.
- we reject H 0 if χ^2 > χ^2 df,α. where df = (# of parameters in the full model) - (# of parameters of the reduced model)
- another way to compare models is with the AIC. AIC = −2 ln L + 2(# parameters). We want a model with smaller AIC (since it is -2ln L).
REPEATED MEASURES
- used for times series or when we have repeated observations
- using the lift index example, we have
Model Y = β 0 + β 1 X
Cov(≤) =
n 1 ×n 1 0 · · · 0 0
n 2 ×n 2 0 0 ..
. 0
ΣT
nT ×nT
Σi is the covariance matrix within a work/task combination. This assumes that the correlation between worker/taks combos is zero.
RANDOM EFFECT MODELS
Using the lift index example again, the model is
Yit = β 0 + β 1 Xit + ui + ≤it
- i is a worker/task combo
- t = observation within worker/task
- ui is a random effect on worker/task. Assume that ui ∼ N (0, σ u^2 )
- ≤ is the error. Assume ≤it ∼ N (0, σ^2 ). We also assume that ui is independent of ≤it
- an equivalent model can be done with dummy variables. Each worker/task gets their own dummy variable.
Y = β 0 + β 1 X + β 2 D 1 + β 3 D 2 +... + β 115 D 114 + ≤
- this model is too complicated and we get the same results if we use the random effects model
- the covariance structure of the random effects is equivalent to the compound symmetry (CS) structure. (^)
σ^2 + σ^2 u σ u^2 σ^2 u σ u^2 σ^2 u σ^2 + σ^2 u σ^2 u σ u^2 σ^2 u σ u^2 σ^2 + σ u^2 σ u^2 σ^2 u σ u^2 σ^2 u σ^2 + σ^2 u
RANDOM COEFFICIENTS MODELS
- model Yit = (β 0 + ui) ︸ ︷︷ ︸ random intercept
+β 1 Xit + ≤it
- this is the same as the CS covariance structure.
- with this method, each IDTask has a different intercept
IDTask = 1 Y = (β 0 + u 1 ) + β 1 X 1 t + ≤ 1 t IDTask = 2 Y = (β 0 + u 2 ) + β 1 X 2 t + ≤ 2 t
- this forces different intercepts with the same slope for all IDTasks
RANDOM COEFFICIENTS REGRESSION - RCR
- Model Yit = (β 0 + γ 0 i) + (β 1 + γ 1 ,i)Xit + ≤it
- with (^) ( γ 0 i γ 1 i
([
]
,
[
σ 00 σ 01 σ 10 σ 11
])
- this is an unstructured covariance matrix. The only restrictions on the covariance matrix are
- covariance matrix cannot have negative values on diagonal
- it must be positive semi-definite
ASSUMPTIONS
(0) - still coming from a pdf randomly
(1) - subsumed by Π(X) = e
β 0 +β 1 X 1+eβ^0 +β^1 X (2) - subsumed by binomial variance. V ar(Y ) = Π(1 − Π) (3) - still assumed (4) - subsumed from logistic curve
Odds, Odds Ratio, Logistic Odds
odds =
eβ^0 +β^1 X 1+eβ 0 +β 1 X 1 1+eβ^0 +β^1 X
= eβ^0 +β^1 X
ln
= β 0 + β 1 X = log odds = logit function
Odds Ratio
- eβ^1 = odds ratio = odds of successes given 1 unit increase in Xodds of succes given X
odds(X+1) odds(X)
eβ^0 +β^1 (X+1) eβ^0 +β^1 X^
= eβ^1
- so if eβ^1 = 1.175, then there is 17.5% higher odds of success per additional increase in X
- so if eβ^1 = .72, then there is 28% decrease in odds of success per additional increase in X
LATENT VARIABLE THRESHOLD MODEL
- this allows us to generalize from binary to ordinal
- define U = latent variable (unobserved) = propensity for failure
- assume that there is a threshold to this propensity so when U, β, there is a success
- Regression model for propensity is U = β 1 X + ≤
- P(Success) = P (U < β 0 ) = P (−β 1 X + ≤ < β 0 ) = P (≤ < β 0 + β 1 X) = F (β 0 + β 1 X
- where F = cdf of ≤
- suppose F (≤) = e
≤ 1+e≤^ , then the
P(Success) = F (β 0 + β 1 X) =
eβ^0 +β^1 X 1 + eβ^0 +β^1 X
Probit model
- U = −β 1 + ≤, where ≤ ∼ N (0, 1)
- P(Success)=P (U, β 0 ) = P (≤ < β 0 + β 1 X)
- since ≤ is normal then P (z < β 0 + β 1 X) = Φ(β 0 + β 1 X)
- this is called the probit regression model with P(Success) = Φ(β 0 + β 1 X), where Φ is the standard normal cumulative distribution function (cdf).
ORDINAL RESPONSE
- Y = 1, 2 , 3 , 4 ,,etc. Y P(Y) 1 Π 1 (X) 2 Π 2 (X) 3 Π 3 (X)
- model U = −β 1 X + ≤
P (Y = 1) = P (U < β 01 ) = P (≤ < β 01 + β 1 X) = F (β 01 + β 1 X) P (Y < 2) = P (U < β 02 ) = P (≤ < β 02 + β 1 X) = F (β 02 + β 1 X)
- note that to get P (Y = 2), we must subtract P (Y ≤ 2) − P (Y = 1),
P (Y = 2) = F (β 02 + β 1 X) − F (β 01 + β 1 X)
R
TYPE MEASURES
- R^2 is really an OLS statistic
R^2 = 1 −
Var {Y |X} Var {Y }
- this compares the intercept only model with the intercept and X’s model
- when using maximum likelihood approaches we can redefine the R^2
R^2 M L = 1 −
[
L(0)
L( βˆ)
] 2 /n
- where L(0) is the likelihood for intercept only, and L( βˆ) is the likelihood for intercept
- in log likelihood we get
R^2 M L = 1 − exp
χ^2 n
- if assumption (0)-(4) are satisfied then R^2 M L = R^2
- problem with this is that even with a perfect model, R^2 M L < 1
- Max-Rescaled R^2
R^2 M RM L =
R^2 M L
1 − [L(0)]^2 /n
NOMINAL RESPONSE (MULTINOMIAL LOGIT)
- similar to ordinal but there is no ordering to the Y values (categorical)
- Example: Y =Favorite subject
- GOAL
Y P(Y)
Math j = 1 Π 1 (X) Science j = 2 Π 2 (X) Art j = 3 Π 1 (X)