The regression model with dummy variables

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: group [1] P F P C C P F F P F C C C F F P C P C C F F C P P [26] F F C F P C C P P P C C C F F F P P F P Levels: C F P > is.factor(group) [1] TRUE ## See how R has coded the dummy variables for ## the ‘factor’ variable group using contrasts(): > contrasts(group) FP C00 F10 P01 So, C is the baseline group (because both dummy variables are 0). 11 12 What do we get when we fit the model in R. The regression model with dummy variables: > is.factor(group) [1] TRUE Yi = β0 + βF D1i + βP D2i + ￿i > lm.out=lm(rate ~ group) The model for each group (3 separate means): > coefficients(lm.out) (Intercept) groupF 82.524067 8.801067 Yi = β0 + ￿i Yi = (β0 + βF ) + ￿i Yi = (β0 + βP ) + ￿i Control group: Friend group: Pet group: ˆ β0 ˆ βF ˆ βP The group means: > tapply(rate,group,mean) C F P 82.52407 91.32513 73.48307 0.20 100 0.25 0.30 0.35 The expected value of Y is the same for all i within a group. groupP -9.041000 0.00 0.05 90 0.10 0.15 ● 5 10 15 20 25 80 0 Y 60 70 Written another way... E [Yi|groupi = C ] = µC = β0 E [Yi|groupi = F ] = µF = β0 + βF E [Yi|groupi = P ] = µP = β0 + βP C F P The distributions: 13 14 The dummy variable parameters represent t...
View Full Document

This note was uploaded on 06/12/2013 for the course MATHEMATIC MAT7870 taught by Professor Sun during the Winter '13 term at Wayne State University.

Ask a homework question - tutors are online