hw8.sol

# hw8.sol - Page 1 of 7 Stat209/Ed260 D Rogosa Solutions...

This preview shows pages 1–3. Sign up to view the full content.

Stat209/Ed260 D Rogosa 2/26/09 Solutions Assignment 8. Matching and propensity score methods Problem 1. Matching to increase precision: Randomized blocks designs > dblock = read.table(file="D:\\drr06\\stat209\\dental.dat", header = T) > attach(dblock) 2x2 cell means in either order > tapply(Pain,list(as.factor(Acup),as.factor(Codeine)), mean) 1 2 1 0.600 1.0625 2 1.175 1.7875 > tapply(Pain,list(as.factor(Codeine),as.factor(Acup)), mean) 1 2 1 0.6000 1.1750 2 1.0625 1.7875 > blkaov = aov(Pain ~ as.factor(Block) + as.factor(Codeine) + as.factor(Acup) + + (as.factor(Codeine)*as.factor(Acup))) > summary(blkaov) Df Sum Sq Mean Sq F value Pr(>F) as.factor(Block) 7 5.5987 0.7998 55.2963 4.126e-12 *** as.factor(Codeine) 1 2.3112 2.3112 159.7901 2.773e-11 *** as.factor(Acup) 1 3.3800 3.3800 233.6790 7.465e-13 *** as.factor(Codeine):as.factor(Acup) 1 0.0450 0.0450 3.1111 0.0923 . Residuals 21 0.3037 0.0145 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > # now ignore blocking variable > blknoaov = aov(Pain ~ as.factor(Codeine) + as.factor(Acup) + + (as.factor(Codeine)*as.factor(Acup))) > summary(blknoaov) Df Sum Sq Mean Sq F value Pr(>F) as.factor(Codeine) 1 2.3112 2.3112 10.9640 0.0025659 ** as.factor(Acup) 1 3.3800 3.3800 16.0339 0.0004155 *** as.factor(Codeine):as.factor(Acup) 1 0.0450 0.0450 0.2135 0.6476320 Residuals 28 5.9025 0.2108 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 > # so the 2x2 with 8 replications per cell (no blocking version) has > # same SS and MS for the experimental factors but Mean square residual > # is approx 15 times larger, .2108/.0145. So relative efficiency is > # around 15 (there are more complex versions of rel eff; instead of > # 32 subjects, would need at least 400 to obtain same precision on > # experimental effects. In this ex blocking is valuable, as an approximate > # matching (on pain tolerance) > ------------------------------------------------------------ Problem 2. Mulivariate matching The example shown in lecture 2/24, from Anderson et al part a differences between treatment and control > match = read.table(file="D:\\drr06\\stat209\\matchex.dat", header = T) > attach(match) > #group differences (treatment vs control resevoir) > tapply(DBP, Grp, length) C T 20 6 > tapply(DBP, Grp, summary) \$C Min. 1st Qu. Median Mean 3rd Qu. Max. 70.00 87.25 90.00 94.15 101.30 120.00 \$T Min. 1st Qu. Median Mean 3rd Qu. Max. 65.0 90.5 93.0 91.5 98.5 108.0 > tapply(Age, Grp, summary) \$C Min. 1st Qu. Median Mean 3rd Qu. Max. 32.00 41.75 47.50 46.50 50.75 60.00 \$T Min. 1st Qu. Median Mean 3rd Qu. Max. 37.00 39.75 43.50 44.83 48.75 56.00 > table(Sex, Grp) Grp Sex C T F 11 4 M 9 2 Page 1 of 7 06/12/2010 http://www-stat.stanford.edu/~rag/stat209/09hw8.sol

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
> # since we will match gender exactly (categorical) look within females > tapply(DBP[Sex =="F"], Grp[Sex == "F"], summary) \$C Min. 1st Qu. Median Mean 3rd Qu. Max. 78.00 86.50 90.00 93.45 99.50 120.00 \$T Min. 1st Qu. Median Mean 3rd Qu. Max.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern