ST3900/4950HOMEWORK/LAB 2 Solutions Spring, 2018
Question 1
- For REACT:
- Stem-and-leave plots of REACT for two doses:
react Stem-and-Leaf Plot for dose= 1.00
Frequency Stem & Leaf
1.00 4 . 8
2.00 5 . 49
1.00 6 . 9
1.00 Extremes (>=15.8)
react Stem-and-Leaf Plot for dose= 2.00
Frequency Stem & Leaf
1.00 4 . 9
2.00 5 . 05
1.00 6 . 7
1.00 Extremes (>=18.2)
(SAS 9.4 does not produce stem-and-leave plots, so 4950 students need to draw the plots by other software or by hand)
- Both stem-and-leaf plots show extreme outliers, so we cannot assume REACT is normally distributed for both Doses, also supported by normality tests (p-values less than .05) and normal Q-Q plots (far off from a line; not shown here); output shown below:
Therefore, we cannot do a t test. In addition, both stem-and-leaf plots show of a similar shape. We will do a Wilcoxon rank sum test.
SAS output:
Wilcoxon Two-Sample TestExact Test
One-Sided Pr >= S / 0.5000
Two-Sided Pr >= |S - Mean| / 1.0000
Zincludesacontinuitycorrectionof0.5.
SPSS output:
The p value is extremely large (~1.00!!), so the distributions of REACT of the two doses are not significantly different.
- i. Stem-and-leave plots of LIVER_WT for two doses:
for dose= 1.00
Frequency Stem & Leaf
1.00 9 . 8
2.00 10 . 29
1.00 11 . 8
1.00 12 . 2
For dose= 2.00
Frequency Stem & Leaf
1.00 9 . 9
1.00 10 . 5
1.00 11 . 9
1.00 12 . 0
1.00 13 . 8
- We can use t tests since the data of liver_wt pass the normality tests for both doses:
All p values (sig. in the table) are larger than .05. Now we conduct 2-sample t tests:
SAS output:
SPSS output:
The p-value 0.46 (in SAS) or 0.47 (in SPSS) of the test of the equality of variances indicates that it is reasonable to assume equal variances. Therefore, we can use the pooled t-test. The p-value is 0.456 and so we cannot reject the null hypothesis. In conclusion, we have insufficient evidence to claim there is a significant difference between LIVER_WT for DOSE 1 and LIVER_WT for DOSE 2.
Question 2
Create two lists of assignments of 8 subjects; one for men and the other for women. For SPSS students, check the SPSS random number handout for details. Here is the SAS code:
** Assign each subject a random number from Unif[0,1];
DATA RANDOM;
DO SUBJ= 1TO8;
GRP=RANUNI(123);
OUTPUT;
END;
RUN;
** Sort the random numbers into 2 groups AND print the results;
PROCRANKDATA=RANDOM GROUPS=2OUT=ASGNMNT;
VAR GRP;
RUN;
PROCPRINTDATA=ASGNMNT NOOBS;
* NOOBS = take off the column of OBS;
TITLE"SUBJECT TREATMENT ASSIGNMENTS";
VAR SUBJ GRP;
RUN;
Repeat the same code again for the list for women. But change the “seed” 123 in the function RANUNI if you want a different list. For example, use RANUNI(234).
1
For men:
subjranduniftreatment
10.686636Aspirin
20.090040Tylenol
30.848049Aspirin
40.331484Tylenol
50.076618Tylenol
60.740453Aspirin
70.237824Tylenol
80.780284Aspirin
For women:
subjranduniftreatment
10.149149Tylenol
20.299081Tylenol
30.440395Aspirin
40.652699Aspirin
50.417568Aspirin
60.543076Aspirin
70.096551Tylenol
80.033844Tylenol
1
SAS CODE FOR QUESTION 1
DATA LIVEREXP;
INPUTSUBJECT $
DOSE $
REACT
LIVER_WT;
DATALINES;
1 1 5.4 10.2
2 1 5.9 9.8
3 1 4.8 12.2
4 1 6.9 11.8
5 1 15.8 10.9
6 2 4.9 13.8
7 2 5.0 12.0
8 2 6.7 10.5
9 2 18.2 11.9
10 2 5.5 9.9
;
**NUMERICAL AND GRAPHICAL SUMMARIES FOR ALL VARIABLES;
PROCUNIVARIATEDATA=LIVEREXP NORMALPLOT;
TITLE"DESCRIPTIVE STATISTICS FOR REACT";
VAR REACT;
HISTOGRAM REACT / MIDPOINTS=7.0 TO 17.0 BY 5NORMAL;
HISTOGRAM REACT / MIDPOINTS=6.0 TO 18.0 BY 3NORMAL;
RUN;
PROCSORTDATA=LIVEREXP;
BY DOSE;
RUN;
PROCUNIVARIATEDATA=LIVEREXP NORMALPLOT;
TITLE"DESCRIPTIVE STATISTICS FOR REACT AND DOSE";
BY DOSE;
VAR REACT;
RUN;
PROCNPAR1WAY WILCOXONDATA=LIVEREXP;
CLASS DOSE;
VAR REACT;
EXACTWILCOXON;
RUN;
PROCUNIVARIATEDATA=LIVEREXP NORMALPLOT;
TITLE"DESCRIPTIVE STATISTICS FOR LIVER_WT AND DOSE";
BY DOSE;
VAR LIVER_WT;
RUN;
PROCTTESTDATA=LIVEREXP;
TITLE"T-TEST FOR LIVER_WT AND DOSE";
CLASS DOSE;
VAR LIVER_WT;
RUN;
1