Review Exercises - University of Massachusetts Amherst

Download Report

Transcript Review Exercises - University of Massachusetts Amherst

Review Exercises
Pagano and Gauvreau (2nd Edition)
Chapter 2: Problems
2, 9, 10 and 14
Review Exercise 2.5. #2.
How do ordinal data differ from
nominal data?
• The categories have an order.
The table below categorized
10,614,000 office visits in the US by duration.
Review Exercise 2.5. #9.
Duration (min)
# Visits (1000s)
0
390
1-5
227
6-10
1023
11-15
3390
16-30
4431
31-60
968
61+
185
Total
10,614
STATEMENT: Office visits are most often between 16 and 30
minutes long.
• Do you agree? (see Excel file: Chapter2-problems-pagano.xls
Review Exercise 2.5. #9.
Evaluate Rate of visits
Duration (min)
Width
# Visits
(1000s)
Rate of Visit
(per min)
0
1
390
390
1-5
5
227
6-10
5
1023
11-15
5
3390
16-30
15
4431
31-60
30
968
61+
?
185
Total
10,614
Are office visits most often between 16 and 30 minutes long?
• No- based on rates, 11-15 min has highest rate of visits. (see Excel)
Review Exercise 2.5. #10.
Construct a Bar Chart (ejs10b540p03.sas)
DATA d;
INPUT Year cases;
LABEL cases="Number of Cases";
CARDS;
1983 122
etc;
RUN;
Figures 1. Number of Pediatric AIDS cases reported in the US by Year
PROC GCHART ;
VBAR year / DISCRETE SUMVAR=cases;
TITLE1 "Figures 1. Number of Pediatric AIDS
cases reported in the US by Year";
FOOTNOTE1 "Source: &prg";
RUN;
Number of Cases
4000
3000
2000
1000
0
1983
1984
1985
1986
Year
Source: ejs10b540p03.sas
1987
1988
1989
Review Exercise 2.5. #14.
Construct a Percent Freq Polygon (ejs10b540p04.sas)
DATA d;
INPUT endpoint midpoint yr1979 yr1987;
LABEL endpoint="Blood Lead (ug/dl):ENDPOINT"
midpoint="Blood Lead (ug/dl):MIDPOINT"
yr1979="Percent";
CARDS;
20 10 11.5 37.8
etc ;
RUN;
SYMBOL INTERPOL=JOIN;
PROC GPLOT;
PLOT yr1979*midpoint yr1987*midpoint /OVERLAY
;
Figure 1. Initial Plot of Percent with Blood Lead for Canadian Workers by Year
Percent
40
30
20
TITLE1 "Figure 1. Initial Plot of Percent with Blood
Lead for Canadian Workers by Year";
10
FOOTNOTE1 "Source: &prg";
RUN;
0
10
20
30
40
50
Blood Lead (ug/dl):MIDPOINT
Source: ejs10b540p04.sas
60
70
80
90
Review Exercise 2.5. #14.
Construct a Percent Freq Polygon (ejs10b540p04.sas)
DATA d1;
INPUT endpoint midpoint yr1979 yr1987;
CARDS;
0 0 0 0
20 10 11.5 37.8
etc
95 85 9.4 0.4
100 100 0 0
;
RUN;
Figure 2. Relative Frequency of Percent with Blood Lead for Canadian Workers by Year
Figure 2. Percent with Blood Lead for Canadian Workers by Year
Percent
40
Percent
40
30
SYMBOL INTERPOL=JOIN;
PROC GPLOT;
30
20
PLOT yr1979*midpoint yr1987*midpoint /OVERLAY
;
20
10
TITLE1 "Figure 2. Percent with Blood Lead for
Canadian Workers by Year";
FOOTNOTE1 "Source: &prg";
RUN;
10
0
0
10
20
30
0
0
10
20
30
40
50
60
Blood Lead (ug/dl):MIDPOINT
40
50
60
Source: ejs10b540p04.sas
Blood Lead (ug/dl):MIDPOINT
Source: ejs10b540p04.sas
70
70
80
80
90
90
100
100
Review Exercise 2.5. #14.
Construct a Percent Freq Polygon (ejs10b540p04.sas)
Express as rates (per 10 years
DATA d2;
SET d1;
p1979=yr1979;
p1987=yr1987;
IF endpoint=20 THEN DO;
p1979=yr1979/2;
p1987=yr1987/2;
END;
RUN;
)
Figure 3. Percent with Blood Lead for 10 year intervals for Canadian Workers by Year
p1979
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0
10
20
30
40
50
Blood Lead (ug/dl):MIDPOINT
Source: ejs10b540p04.sas
60
70
80
90
100
Review Exercise 2.5. #14.
Construct a Percent Freq Polygon (ejs10b540p04.sas)
Express as rates (per 10 years)
DATA d2;
SET d1;
p1979=yr1979;
p1987=yr1987;
IF endpoint=20 THEN
DO;
p1979=yr1979/2;
p1987=yr1987/2;
END;
RUN;
Figure 3. Percent with Blood Lead for 10 year intervals for Canadian Workers by Year
p1979
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
0
10
20
30
40
50
Blood Lead (ug/dl):MIDPOINT
Source: ejs10b540p04.sas
60
70
80
90
100
Review Exercise 2.5. #14.
Construct a Cum Percent Distribution (ejs10b540p04.sas)
*******************************************;
*** Create cumulative percents
;
*******************************************;
DATA d2;
SET d1;
RETAIN cyr1979 cyr1987;
IF _N_=1 THEN DO;
cyr1979=0;
cyr1987=0;
END;
cyr1979=cyr1979+yr1979;
cyr1987=cyr1987+yr1987;
LABEL cyr1979="Cum Percent 1979"
cyr1987="Cum Percent 1987";
RUN;
SYMBOL INTERPOL=JOIN;
LEGEND1 label=none value=(h=2 font=swiss '1979' '1987')
POSITION=(bottom right inside) mode=protect
cborder=black;
PROC GPLOT;
PLOT cyr1979*endpoint cyr1987*endpoint /OVERLAY
LEGEND=Legend1;
TITLE1 "Figure 4. Cumulative Relative Frequency of
Percent with Blood Lead for Canadian Workers by
Year";
FOOTNOTE1 "Source: &prg";
RUN;
Figure 4. Cumulative Relative Frequency of Percent with Blood Lead for Canadian Workers by Year
Cum Percent 1979
100
90
80
70
60
50
40
30
20
10
0
0
10
20
30
40
50
60
Blood Lead (ug/dl):ENDPOINT
Source: ejs10b540p04.sas
70
80
90
100