EXST7005 Fall2010 12b Appendix 03

EXST7005 Fall2010 12b Appendix 03 - Statistical Methods I...

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: Statistical Methods I (EXST 7005) 1 2 3 4 5 6 7 8 Appendix 3 Page 184 ******************************************************************; *** Two varieties of a particular moth species occur in two ***; *** colors (brown and white). A biologist in North Carolina ***; *** wants to know if the distribution of the two varieties ***; *** differs with the area of the state. He collects ***; *** individuals from each region of the state and note the ***; *** number of each variety. ***; ******************************************************************; 9 dm'log;clear;output;clear'; 10 OPTIONS LS=99 PS=512 nocenter nodate nonumber; 11 12 ODS HTML style=minimal rs=none 13 body='C:\EXST 7005\SAS\Example03.html' ; NOTE: Writing HTML Body file: C:\EXST 7005\SAS\Example03.html 14 ODS RTF style=minimal rs=none 15 body='C:\EXST 7005\SAS\Example03.rtf' ; NOTE: Writing RTF Body file: C:\EXST 7005\SAS\Example03.rtf 16 ODS PDF style=minimal body='C:\EXST 7005\SAS\Example03.PDF'; NOTE: Writing ODS PDF output to DISK destination "C:\EXST 7005\SAS\Example03.PDF", printer "PDF". 17 18 TITLE1 'Introductory SAS example 3'; 19 20 options nocenter ps=256 ls=99 nodate nonumber nolabel; 21 title1 'Examples of Chi square tests'; 22 title2 'Chi square test of independence'; 23 data one; 24 input color $ area $ number; 25 cards; NOTE: The data set WORK.ONE has 6 observations and 3 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 25 ! run; 32 ; 33 proc print; title3 'Data listing'; 34 run; NOTE: There were 6 observations read from the data set WORK.ONE. NOTE: The PROCEDURE PRINT printed page 1. NOTE: PROCEDURE PRINT used (Total process time): real time 0.17 seconds cpu time 0.00 seconds Examples of Chi square tests Chi square test of independence Data listing Obs 1 2 3 4 5 6 color White White White Brown Brown Brown area west central east west central east number 92 12 37 8 4 18 James P. Geaghan Copyright 2010 Statistical Methods I (EXST 7005) Appendix 3 Page 185 36 proc freq; title3 'Proc Freq without weight statement'; 37 tables color*area; 38 run; NOTE: There were 6 observations read from the data set WORK.ONE. NOTE: The PROCEDURE FREQ printed page 2. NOTE: PROCEDURE FREQ used (Total process time): real time 0.14 seconds cpu time 0.03 seconds Examples of Chi square tests Chi square test of independence Proc Freq without weight statement The FREQ Procedure Table of color by area color area Frequency| Percent | Row Pct | Col Pct |central |east |west | Total ---------+--------+--------+--------+ Brown | 1 | 1 | 1 | 3 | 16.67 | 16.67 | 16.67 | 50.00 | 33.33 | 33.33 | 33.33 | | 50.00 | 50.00 | 50.00 | ---------+--------+--------+--------+ White | 1 | 1 | 1 | 3 | 16.67 | 16.67 | 16.67 | 50.00 | 33.33 | 33.33 | 33.33 | | 50.00 | 50.00 | 50.00 | ---------+--------+--------+--------+ Total 2 2 2 6 33.33 33.33 33.33 100.00 39 40 proc freq; title3 'Chi square analysis using Proc Freq'; 41 weight number; 42 tables color*area / chisq expected cellchi2 norow nocol nopercent; 43 run; NOTE: There were 6 observations read from the data set WORK.ONE. NOTE: The PROCEDURE FREQ printed page 3. NOTE: PROCEDURE FREQ used (Total process time): real time 0.28 seconds cpu time 0.00 seconds Examples of Chi square tests Chi square test of independence Chi square analysis using Proc Freq The FREQ Procedure James P. Geaghan Copyright 2010 Statistical Methods I (EXST 7005) Appendix 3 Page 186 Table of color by area color area Frequency | Expected | Cell Chi-Square|central |east |west | ---------------+--------+--------+--------+ Brown | 4 | 18 | 8 | | 2.807 | 9.6491 | 17.544 | | 0.507 | 7.2273 | 5.1919 | ---------------+--------+--------+--------+ White | 12 | 37 | 92 | | 13.193 | 45.351 | 82.456 | | 0.1079 | 1.5377 | 1.1047 | ---------------+--------+--------+--------+ Total 16 55 100 Total 30 141 171 Statistics for Table of color by area Statistic DF Value Prob -----------------------------------------------------Chi-Square 2 15.6764 0.0004 Likelihood Ratio Chi-Square 2 15.5329 0.0004 Mantel-Haenszel Chi-Square 1 10.6004 0.0011 Phi Coefficient 0.3028 Contingency Coefficient 0.2898 Cramer's V 0.3028 Sample Size = 171 44 45 46 47 ****************************************************************************; *** Testing for a Mendalian ration of 9 : 6 : 1 in a breeding experiment ***; ****************************************************************************; 48 options nocenter ps=60 ls=78 nodate nonumber; 49 title1 'Examples of Chi square tests'; 50 title2 'Chi square goodness of fit test'; 51 52 data GoodFit; 53 input color $ number; 54 cards; NOTE: The data set WORK.GOODFIT has 3 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds 54 ! run; 58 ; 59 proc print data=GoodFit; title3 'Raw Data listing'; 60 run; NOTE: There were 3 observations read from the data set WORK.GOODFIT. NOTE: The PROCEDURE PRINT printed page 4. NOTE: PROCEDURE PRINT used (Total process time): real time 0.26 seconds cpu time 0.00 seconds James P. Geaghan Copyright 2010 Statistical Methods I (EXST 7005) Appendix 3 Page 187 Examples of Chi square tests Chi square goodness of fit test Raw Data listing Obs 1 2 3 color red pink white number 153 72 17 61 62 proc freq data=GoodFit order=data; weight number; 63 title3 'Chi square analysis using Proc Freq'; 64 tables color / chisq nocum testp=(0.5625 0.3750 0.0625); 65 run; NOTE: There were 3 observations read from the data set WORK.GOODFIT. NOTE: The PROCEDURE FREQ printed page 5. NOTE: PROCEDURE FREQ used (Total process time): real time 0.12 seconds cpu time 0.03 seconds Examples of Chi square tests Chi square goodness of fit test Chi square analysis using Proc Freq The FREQ Procedure Test color Frequency Percent Percent -----------------------------------------red 153 63.22 56.25 pink 72 29.75 37.50 white 17 7.02 6.25 Chi-Square Test for Specified Proportions ------------------------Chi-Square 6.1983 DF 2 Pr > ChiSq 0.0451 Sample Size = 242 James P. Geaghan Copyright 2010 Statistical Methods I (EXST 7005) 67 68 69 70 71 72 Appendix 3 Page 188 ******************************************************************; *** A sample of fishes from North Carolina swamp streams ***; *** revealed 47 male Flier sunfish and 59 females. Test the ***; *** hypothesis that the population contains equal numbers of ***; *** males and females ***; ******************************************************************; 73 options nocenter ps=60 ls=78 nodate nonumber; 74 title1 'Examples of Chi square tests'; 75 title2 'Chi square of equal proportions'; 76 77 data EqualP; 78 input sex $ number; 79 cards; NOTE: The data set WORK.EQUALP has 2 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds 79 ! run; 82 ; 83 proc print data=EqualP; title3 'Raw Data listing'; 84 run; NOTE: There were 2 observations read from the data set WORK.EQUALP. NOTE: The PROCEDURE PRINT printed page 6. NOTE: PROCEDURE PRINT used (Total process time): real time 0.04 seconds cpu time 0.00 seconds Examples of Chi square tests Chi square of equal proportions Raw Data listing Obs 1 2 sex Female Male number 59 47 85 86 proc freq data=EqualP; weight number; 87 title3 'Chi square analysis using Proc Freq'; 88 tables sex / chisq expected cellchi2 binomial; 89 run; NOTE: There were 2 observations read from the data set WORK.EQUALP. NOTE: The PROCEDURE FREQ printed page 7. NOTE: PROCEDURE FREQ used (Total process time): real time 0.17 seconds cpu time 0.04 seconds James P. Geaghan Copyright 2010 Statistical Methods I (EXST 7005) Appendix 3 Page 189 Examples of Chi square tests Chi square of equal proportions Chi square analysis using Proc Freq The FREQ Procedure Cumulative Cumulative sex Frequency Percent Frequency Percent ----------------------------------------------------------Female 59 55.66 59 55.66 Male 47 44.34 106 100.00 Chi-Square Test for Equal Proportions --------------------Chi-Square 1.3585 DF 1 Pr > ChiSq 0.2438 Binomial Proportion for sex = Female -------------------------------Proportion 0.5566 ASE 0.0483 95% Lower Conf Limit 0.4620 95% Upper Conf Limit 0.6512 Exact Conf Limits 95% Lower Conf Limit 95% Upper Conf Limit 0.4569 0.6531 Test of H0: Proportion = 0.5 ASE under H0 Z One-sided Pr > Z Two-sided Pr > |Z| 0.0486 1.1655 0.1219 0.2438 Sample Size = 106 90 91 ods html close; 92 ods rtf close; 93 ods PDF close; NOTE: ODS PDF printed 7 pages to C:\EXST 7005\SAS\Example03.PDF. 94 95 run; 96 quit; 97 James P. Geaghan Copyright 2010 ...
View Full Document

Ask a homework question - tutors are online