*Thyne, Clayton *Intro to Stats, Chapter 3 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\chapter3 * This is necessary so you know where stata is saving things. ****Part 1: probability defined as limiting relative frequency *probability of each roll should be: 1/6 = .1666 *start w/ only 10 rolls clear set obs 10 gen roll10=1 + int(6*uniform()) tab roll10 hist roll10, gap(10) addlabels discrete xlabel(1(1)6) yline(.16666) title(10 rolls) saving(10.gph, replace) *now w/ 50 rolls clear set obs 50 gen roll50=1 + int(6*uniform()) tab roll50 hist roll50, gap(10) addlabels discrete xlabel(1(1)6) yline(.16666) title(50 rolls) saving(50.gph, replace) *now w/ 200 rolls clear set obs 200 gen roll200=1 + int(6*uniform()) tab roll200 hist roll200, gap(10) addlabels discrete xlabel(1(1)6) yline(.16666) title(200 rolls) saving(200.gph, replace) *now w/ 2000 rolls clear set obs 2000 gen roll2000=1 + int(6*uniform()) tab roll2000 hist roll2000, gap(10) addlabels discrete xlabel(1(1)6) yline(.16666) title(2000 rolls) saving(2000.gph, replace) *now w/ 200,000 rolls clear set obs 200000 gen roll200000=1 + int(6*uniform()) tab roll200000 hist roll, gap(10) addlabels discrete xlabel(1(1)6) yline(.16666) title(200000 rolls) saving(200000.gph, replace) *combine all figures above graph combine 10.gph 50.gph 200.gph 2000.gph 200000.gph ****Part 2: examining independence clear use "http://www.uky.edu/~clthyn2/intro_stats/data_set_1.dta" keep ccode abbrev muslim asia gen muslimmaj=1 if muslim>50 replace muslimmaj=0 if muslimmaj==. tab muslimmaj asia pwcorr muslimmaj asia, sig tabulate muslimmaj asia, chi2