##### Problem One Angell <- read.table('http://math.uttyler.edu/nathan/classes/statistics/data/angell.data',header=TRUE) attach(Angell) ineast <- ifelse(region=='E',1,0) m1.1 <- lm(moral ~ hetero + ineast + hetero*ineast) # model is # moral = b0 + b1 hetero + b2 ineast + b3 hetero*ineast + err # # b2 gives difference in intercepts for the east/noneast lines # b3 gives difference in slopes for the east/noneast lines # # first question "Determine whether the effect of hetero on moral is # the same for the East as for other regions" # paraphrases to "Determine whether b3 is zero" summary(m1.1) # the p-value for H0: b3=0 is .6137, so we have no reason to reject # this hypothesis, and can conclude that b3=0, or, in other words, that # the effect of hetero on moral is the same for the East as for the # other regions. # second question "if so, whether there is, in general, a different # level of moral for a specified level of hetero in # the East when compared to the rest of the country." # # paraphrases to "if b3 = 0 determine whether b2 = 0 also" m1.2 <- lm(moral ~ hetero + ineast) summary(m1.2) # model is # moral = b0 + b1 hetero + b2 ineast + err # # p-value for H0: b2 = 0 is .0000135, so we reject this null hypothesis # and conclude b2 =/= 0, or, in other words, that there is a different # level of moral for a specified level of hetero in the East when # compared to the rest of the country. Geometrically we have # distinct, but parallel, lines. ##### Problem Two region inmw <- ifelse(region=='MW',1,0) inw <- ifelse(region=='W',1,0) m2.1 <- lm(moral ~ hetero + mobility + ineast + inmw + inw) m2.2 <- lm(moral ~ hetero + mobility) anova(m2.1,m2.2) # H0: slopes for ineast, inmw, and inw are all zero # H1: at least one of these slopes is nonzero # # the p-value is .07562, indicating a marginal significance. However, # keeping things at the .05 level we'll fail to reject the null # hypothesis. summary(m2.1) # we give the equation for each region: # # for the south: # moral = 13.40850 - 0.06647 hetero - 0.06729 mobility # # for the east: # moral = 13.40850+4.58939 - 0.06647 hetero - 0.06729 mobility # = 17.99789 - 0.06647 hetero - 0.06729 mobility # # for the midwest: # moral = 13.40850+2.06443 - 0.06647 hetero - 0.06729 mobility # = 15.47293 - 0.06647 hetero - 0.06729 mobility # # for the west: # moral = 13.40850+0.72487 - 0.06647 hetero - 0.06729 mobility # = 14.13337 - 0.06647 hetero - 0.06729 mobility ##### Problem Three m3.1 <- lm(moral ~ hetero + mobility + ineast + inmw + inw + ineast*hetero + ineast*mobility + inmw*hetero + inmw*mobility + inw*hetero + inw*mobility) anova(m3.1,m2.1) # H0: slopes for in(region)*hetero and in(region)*mobility are all zero # H1: at least some of these are non-zero # p-value = .6867, probably not a surprise that we fail to reject H0 # (given our results in problem 2) m3.2 <- lm(moral ~ hetero + mobility,subset=region=='S') Angell[region=='S',] summary(m3.2) #(Intercept) 13.75850 #hetero -0.05195 #mobility -0.10155 summary(m3.1) #(Intercept) 13.758497 4.336680 3.173 0.0034 ** #hetero -0.051954 0.035372 -1.469 0.1520 #mobility -0.101548 0.089959 -1.129 0.2676 #ineast 8.739683 8.567938 1.020 0.3156 #inmw 4.265281 6.224078 0.685 0.4983 #inw -2.407082 9.005628 -0.267 0.7910 #hetero:ineast -0.103960 0.097452 -1.067 0.2943 #mobility:ineast -0.116646 0.378952 -0.308 0.7603 #hetero:inmw -0.086774 0.094983 -0.914 0.3680 #mobility:inmw -0.003521 0.144197 -0.024 0.9807 #hetero:inw -0.147150 0.245948 -0.598 0.5540 #mobility:inw 0.167334 0.178624 0.937 0.3561 # # note that when we're in region 'S', ineast=inmw=inw = 0, so the line is # moral = 13.758497 -0.05194 hetero - 0.101548 mobility + err # # exactly what we got when running the regression only for the south.