Transcript Lecture 21 – Thurs., Nov. 20
Lecture 21 – Thurs., Nov. 20
• Review of Interpreting Coefficients and Prediction in Multiple Regression • Strategy for Data Analysis and Graphics (Chapters 9.4 – 9.5) • Specially Constructed Explanatory Variables (Chapter 9.3) – Polynomial terms for curvature – Interaction terms – Sets of indicator variables for nominal variables
Interpreting Coefficients
• Multiple Linear Regression Model {
Y
|
X
1 ,....,
X p
} 0 1
X
1
p X p
the mean of Y that is associated with increasing X j by one unit and not changing X 1 ,…,X j-1 , X j+1 ,…,X p • Interpretation holds even if X 1 ,…,X p are correlated.
• Same warning about extrapolation beyond the observed X 1 ,…,X p points as in simple linear regression.
Coefficients in Mammal Study
Parameter Estimates
Term Estimate Std Error Prob>|t| Low er 95% Upper 95% Intercept -225.2921 83.05875 0.0080 -390.254 -60.33028 BODY GESTATION 1.8087434 0.354449 <.0001 1.1047774 2.5127094 LITTER 0.9858781 0.094283 <.0001 0.7986246 1.1731315 27.648639 17.41429 0.1158 -6.937651 62.234929 • It is estimated that – A 1 kg increase in body weight with gestation period and litter size held fixed is associated with a 0.90 g mean increase in brain weight [95% CI: (0.80,1.17)] – A 1 day increase in gestation period with body weight and litter size held fixed is associated with a 1.81g mean increase in brain weight [95% CI : (1.10,2.51)] – A 1 animal increase in litter size with body weight and gestation period held fixed is associated with a 27.65g mean increase in brain weight [95% CI: (-6.94, 62.23)]
Prediction from Multiple Regression
Parameter Estimates
Term Estimate Std Error Prob>|t| Low er 95% Upper 95% Intercept -225.2921 83.05875 0.0080 -390.254 -60.33028 BODY GESTATION 1.8087434 0.354449 <.0001 1.1047774 2.5127094 LITTER 0.9858781 0.094283 <.0001 0.7986246 1.1731315 27.648639 17.41429 0.1158 -6.937651 62.234929 • Estimated mean brain weight (=predicted brain weight) for a mammal which has a body weight of 3kg, a gestation period of 180 days and a litter size of 1
bra i
ˆ
nsize
225 .
29 0 .
99 * 3 1 .
81 * 180 27 .
65 * 1 131 .
13
Strategy for Data Analysis and Graphics
• Strategy for Data Analysis: Display 9.9 in Chapter 9.4
• Good graphical method for initial exploration of data is a matrix of pairwise scatterplots. To display this in JMP, click on Analyze, Multivariate and then put all the variables in Y, Columns.
Specially Constructed Explanatory Variables
• The scope of multiple linear regression can be dramatically expanded by using specially constructed explanatory variables: – Powers of the explanatory variables X j k model curvature in regression function.
can be used to – Indicator variables can be used to model the effect of nominal variables model interactive effects of explanatory variables
Curved Regression Functions
Bivariate Fit of YIELD By RAI NFALL
40 35 30 25 5 0 -5 -10 6 7 8 9 10 11 12 RAINFALL 13 14 15 16 17 20 6 7 8 9 10 11 12 13 14 15 16 17 RAINFALL • Linearity assumption in simple linear regression is violated. Transformations wouldn’t work because function isn’t monotonic.
Squared Term for Curvature
• Multiple Linear Regression Model: {
yield
|
rain
} 0 1
rain
2
rain
2
Bivariate Fit of YIELD By RAI NFALL
40 35
Parameter Estimates
Term Intercept RAINFALL (RAINFALL-10.7842)^2 Estimate 21.660175 1.0572654 -0.229364 Std Error 3.094868 0.293956 0.088635 30 5 25 0 -5 20 -10 6 6 7 8 9 10 11 12 13 14 15 16 17 RAINFALL 7 8 9 10 11 12 RAINFALL 13 14 15 16 17 t Ratio 7.00 3.60 -2.59 Prob>|t| <.0001 0.0010 0.0140
Terms for Curvature
• Two ways to incorporate squared or higher polynomial terms for curvature in JMP – Fit Model, create a variable rainfall 2 – Fit Y by X, under red triangle next to Bivariate Fit of Yield by Rainfall, click Fit Polynomial then 2, Quadratic instead of Fit Line (a model with both a squared and cubed term can be fit by clicking 3, Cubic) • Coefficients are not directly interpretable. Change in the mean of Y that is associated with a one unit increase in X depends on X {
Y
|
X
1 } {
Y
|
X
} [ 0 1 (
X
1 ) 2 (
X
1 ) 2 ] [ 0 1 1
X
2 [( 2 *
X
2 )
X
2 ] 1 ]
Interaction Terms
• Two variables are said to
interact
if the effect that one of them has on the mean response depends on the value of the other.
• An explanatory variable for interaction can be constructed as the product of the two explanatory variables that are thought to interact.
Interaction in Meadowfoam
• Does the effect of light intesnity on mean number of flowers depend on the timing of light regime?
• Multiple linear regression model that has term for { interaction:
flowers
|
light
,
early
} 0 1
light
2
early
3 (
light
*
early
) • Model is equivalent to {
flowers
|
light
,
early
} ( 0 2
early
) ( 1 3
early
) * • Change in mean of flowers for a one unit increase in light
light
intensity depends on timing onset.
• Coefficients are not easily interpretable. Best method for communicating findings with interaction is table or graph of estimated means at various combinations of interacting variables.
Interaction in Meadowfoam
Parameter Estimates
Term Intercept Estimate Std Error t Ratio Prob>|t| 71.623333 4.343305 16.49 <.0001 Early INTENS 11.523333 6.142361 1.88 0.0753 -0.041076 0.007435 -5.52 <.0001 Early*Intens 0.0012095 0.010515 0.12 0.9096 • There is not much evidence of an interaction. The p-value for the test that the interaction coefficient is zero is 0.9096.
Displaying Interaction – Coded Scatterplots (Section 9.5.2)
• A coded scatterplot is a scatterplot with different symbols to distinguish two or more
Overlay Plot Overlay Y's
groups 90.0000000000000
80.0000000000000
70.0000000000000
60.0000000000000
50.0000000000000
40.0000000000000
30.0000000000000
20.0000000000000
.0000000000000
INTENS Y 0 1
Coded Scatterplots in JMP
• Split the Y variable by the group identity variables (Click Tables, Split, then put Y variable in Split and Group Identity variable in Col ID).
• Graph, Overlay Plot, put the columns corresponding to the Y’s for the different group identity variables in Y and put the X variable (light intensity) in X.
Parallel vs. Separate Regression Lines
• Model without interaction between time onset and light intensity is a “parallel regression lines” model {
flowers
|
light
,
early
} 0 1
light
2
early
{
flowers
|
light
,
early
0 } 0 1
light flowers
|
light
,
early
light
0 1 2 • Model with interaction is a “separate regression lines” model { {
flowers
|
light
,
early
} 1 } 1
light
2
early
3 (
light
*
early
) 0 { {
flowers flowers
| |
light
,
early light
,
early
0 } 1 } 0 0 1
light
2 ( 1 3 )
light
*
early
Polynomials and Interactions Example
• An analyst working for a fast food chain is asked to construct a multiple regression model to identify new locations that are likely to be profitable. The analyst has for a sample of 25 locations the annual gross revenue of the restaurant (y), the mean annual household income and the mean age of children in the area. Data in fastfoodchain.jmp
• Relationship between y and each explanatory variable might be quadratic because restaurants attract mostly middle-income households and children in the mid age ranges.
fastfoodchain.jmp results
Parameter Estimates
Term Intercept Estimate Std Error t Ratio Prob>|t| -1133.981 320.0193 -3.54 0.0022 Income Age Income sq 173.20317 28.20399 6.14 <.0001 23.549963 32.23447 0.73 0.4739 -3.726129 0.542156 -6.87 <.0001 Age sq -3.868707 1.179054 -3.28 0.0039 (Income)( Age) 1.9672682 0.944082 2.08 0.0509 between revenue and age, revenue and income. Moderate evidence of an interaction between age and income.
Nominal Variables
• To incorporate nominal variables in multiple regression analysis, we use indicator variables.
• Indicator variable to distinguish between two groups: The time onset (early vs. late is a nominal variable). To incorporate it into multiple regression analysis, we used indicator variable early which equals 1 if early, 0 if late.
{
flowers
|
light
,
early
} 0 1
light
2
early
Nominal Variables with More than Two Categories
• To incorporate nominal variables with more than two categories, we use multiple indicator variables. If there are k categories, we need k-1 indicator variables.
Nominal Explanatory Variables Example: Auction Car Prices
• A car dealer wants to predict the auction price of a car.
– The dealer believes that odometer reading
and the car color
are variables that affect a car’s price (data from sample of cars in auctionprice.JMP) – Three color categories are considered: • White • Silver • Other colors Note: Color is a nominal variable.
Indicator Variables in Auction Car Prices
I 1 = 1 if the color is white 0 if the color is not white I 2 = 1 if the color is silver 0 if the color is not silver The category “Other colors” is defined by: I 1 = 0; I 2 = 0
Auction Car Price Model
• Solution – the proposed model is {
Y
|
odometer
,
color
} 0 1
odometer
2
I
1 3
I
2 – The data
Price
14636 14122 14016 15590 15568 14718 .
.
Odometer
37388 44758 45833 30862 31705 34010 .
.
I-1
1 1 0 0 0 0 .
.
I-2
0 0 0 0 1 1 .
.
White car Other color Silver color
Price
Example: Auction Car Price The Regression Equation
From JMP we get the regression equation PRICE = 16701-.0555(Odometer)+90.48(I-1)+295.48(I-2) Price = 16701 - .0555(Odometer) + 90.48(0) + 295.48(1) Price = 16701 - .0555(Odometer) + 90.48(1) + 295.48(0) Price = 6350 - .0278(Odometer) + 45.2(0) + 148(0) Odometer
Example: Auction Car Price The Regression Equation
From JMP we get the regression equation PRICE = 16701-.0555(Odometer)+90.48(I-1)+295.48(I-2) For one additional mile the auction price decreases by 5.55 cents.
A white car sells, on the average, for $90.48 more than a car of the “Other color” category A silver color car sells, on the average, for $295.48 more than a car of the “Other color” category.
Example: Auction Car Price The Regression Equation
There is insufficient evidence to infer that a white color car and a car of “other color” sell for a different auction price.
Xm18-02b There is sufficient evidence to infer that a silver color car sells for a larger price than a car of the “other color” category.
Parameter Estimates
Term Estimate Std Error t Ratio Prob>|t| Intercept 16700.646 184.3331 90.60 <.0001 Odometer -0.05554 0.004737 -11.72 <.0001 I-1 I-2 90.481959 68.16886 1.33 0.1876 295.47602 76.36998 3.87 0.0002
Shorthand Notation for Nominal Variables
• Shorthand Notation for regression model with Nominal Variables. Use all capital letters for nominal variables – Parallel Regression Lines model: {
flowers
|
light
,
TIME
}
light
TIME
– Separate Regression Lines model: {
flowers
|
light
,
TIME
}
light
TIME
(
light
*
TIME
)
Nominal Variables in JMP
• It is not necessary to create indicator variables yourself to represent a nominal variable.
• Make sure that the nominal variable’s modeling type is in fact nominal.
• Include the nominal variable in the Construct Model Effects box in Fit Model • JMP will create indicator variables. The brackets indicate the category of the nominal variable for which the indicator variable is 1.