*Thyne, Clayton *Intro to Stats, Chapter 8 examples clear set mem 80m cd [your directory] * NOTE: the above command asks you to change the directory. The directory will depend on how you've set up * the folders on your computer. For example, my command is... * cd F:\teaching\Fall_2008\PS572-401-baby_stats\do_file_directories\chapter8 * This is necessary so you know where stata is saving things. ****Part 1: examining the 95% confidence interval *the "true" population of UK undergrads clear drawnorm real, n(30000) means(3.2) sds(1.2) hist real, freq norm *now our estimates clear drawnorm est1, n(20) means(3.2) sds(1.2) drawnorm est2, n(20) means(3.2) sds(1.2) drawnorm est3, n(20) means(3.2) sds(1.2) drawnorm est4, n(20) means(3.2) sds(1.2) drawnorm est5, n(20) means(3.2) sds(1.2) drawnorm est6, n(20) means(3.2) sds(1.2) drawnorm est7, n(20) means(3.2) sds(1.2) drawnorm est8, n(20) means(3.2) sds(1.2) drawnorm est9, n(20) means(3.2) sds(1.2) drawnorm est10, n(20) means(3.2) sds(1.2) drawnorm est11, n(20) means(3.2) sds(1.2) drawnorm est12, n(20) means(3.2) sds(1.2) drawnorm est13, n(20) means(3.2) sds(1.2) drawnorm est14, n(20) means(3.2) sds(1.2) drawnorm est15, n(20) means(3.2) sds(1.2) drawnorm est16, n(20) means(3.2) sds(1.2) drawnorm est17, n(20) means(3.2) sds(1.2) drawnorm est18, n(20) means(3.2) sds(1.2) drawnorm est19, n(20) means(3.2) sds(1.2) drawnorm est20, n(20) means(3.2) sds(1.2) sum *On average, 19 of 20 samples (95%) should fall within the C.I. we calculated in class. ****Part 2: using t instead of z clear use "http://www.uky.edu/~clthyn2/intro_stats/CH8_example.dta" ci UKgpa ****Part 3: difference in means test, unmatched samples ttest UKgpa == IAgpa, unpaired ****Part 4: difference in means test, matched samples order student IA UK gen UKgpa2=. replace UKgpa2 = 2.8 in 1 replace UKgpa2 = 3.9 in 2 replace UKgpa2 = 3.2 in 3 replace UKgpa2 = 3.3 in 4 replace UKgpa2 = 3.6 in 5 replace UKgpa2 = 2.5 in 6 replace UKgpa2 = 2.2 in 7 replace UKgpa2 = 3.0 in 8 replace UKgpa2 = 3.1 in 9 replace UKgpa2 = 4 in 10 *I'm going to assume you can do the same procedure we did earlier... *if not, see Table 8-3 on page 269 *Using Stata (the easy way), we just use... ttest UKgpa2 == UKgpa *we see that the students' avg GPAs increased by .43 with a C.I ... *of .112, .748. The t value of 3.056 is above the threshhold of 2.26 ... *(see Table V on page 673), so we can safely conclude that the ... *students' GPAs increased significantly with 95% confidence. *Now, pretend these are not paired. We use... ttest UKgpa2 == UKgpa, unpaired *Using this, we cannot safely conclude a significant increase. Why? ****Part 5: examining proportions clear use "http://www.uky.edu/~clthyn2/intro_stats/CH8_example.dta" gen UKmale=. replace UKmale = 0 in 1 replace UKmale = 0 in 2 replace UKmale = 1 in 3 replace UKmale = 1 in 4 replace UKmale = 0 in 5 replace UKmale = 1 in 6 replace UKmale = 0 in 7 replace UKmale = 0 in 8 replace UKmale = 0 in 9 replace UKmale = 1 in 10 sum prop UKmale ci UKmale, binomial *So, we can be 95% sure that the true popluation of males at UK *will be from .122 to .738. ****Part 6: examining the difference in two proportions clear use "http://www.uky.edu/~clthyn2/intro_stats/CH8_example.dta" gen UKmale=. replace UKmale = 0 in 1 replace UKmale = 0 in 2 replace UKmale = 1 in 3 replace UKmale = 1 in 4 replace UKmale = 0 in 5 replace UKmale = 1 in 6 replace UKmale = 0 in 7 replace UKmale = 0 in 8 replace UKmale = 0 in 9 replace UKmale = 1 in 10 gen IAmale=. replace IAmale = 1 in 1 replace IAmale = 0 in 2 replace IAmale = 1 in 3 replace IAmale = 1 in 4 replace IAmale = 1 in 5 replace IAmale = 1 in 6 replace IAmale = 0 in 7 replace IAmale = 0 in 8 replace IAmale = 1 in 9 replace IAmale = 1 in 10 prop UKmale IAmale prtest UKmale==IAmale *Though the difference in proportions shows that IA has a larger proportion *of males, we cannot be safely sure of this becuase the confidence interval *includes zero.