Solution to the Additional Exercises for Chapter 4 Ware, Ferron, and

advertisement
Solution to the Additional Exercises for Chapter 4
Ware, Ferron, and Miller (2013)
In the additional exercises for Chapters 2 and 3, we examined the distributions of the Fall Kindergarten
IRT reading scores for Asian and Hispanic children. In doing so, we first generated frequency tables,
histograms, and stem-and-leaf plots to examine the aspects of location, spread, and shape. We then
considered quantitative measures of those features, looking at the mode, median, and mean; the range,
interquartile range, the average deviation, and the variance and its square-root, the standard deviation.
Last, we considered the issue of shape, specifically looking at measures of symmetry (skewness) and
curvature (kurtosis). Based on our results, we were able to make some “guarded” statements regarding
the similarities and differences between the two sets of scores. In these additional exercises for Chapter 4,
we will consider ways in which to describe categorical (nominal) variables. We have created a data file
containing all of the variables in the ecls2577 data set and all of the cases indicated to be Hispanic (3) or
Asian (5). In the file, there are a number of categorical variables; we will focus on three of them: the
language spoken in the child’s home (wklangst), whether the child is enrolled in a public (1) or private (2)
school (s2kpupri), and the educational level of the child’s mother (wkmomed).
After reading in the data, create factor-type variables with labels:
# Create factor-type variables with labels
hisp.asian$f.race <- factor(race, levels = c(3,5),
labels = c("Hispanic", "Asian"), ordered = TRUE)
hisp.asian$f.lang <- factor(wklangst, levels = 1:2,
labels = c("~English", "English"), ordered = TRUE)
hisp.asian$f.school <- factor(s2kpupri, levels = 1:2,
labels = c("Public", "Private"), ordered = TRUE)
# Set up labels for educational level
ednames <- c("8th.Grade.or.Less",
"9th.to.12th Grade", "HS.Grad/GED",
"Voc/Tech.Prog", "Some.College",
"Coll.Grad", "Some.Grad/Prof.School",
"Master's", "Doctoral/Prof.Deg")
hisp.asian$f.momed <- factor(wkmomed, levels = 1:length(ednames),
labels = ednames, ordered = TRUE)
In order to describe the distributions of these three variables for both Hispanic and Asian children,
1. Tabulate the variables, first without regard to race:
> table(f.race)
f.race
Hispanic
Asian
155
111
> table(f.lang)
f.lang
~English English
65
201
> table(f.school)
f.school
Public Private
186
80
> table(f.momed)
f.momed
8th.Grade.or.Less
2
9th.to.12th Grade
17
HS.Grad/GED
70
Voc/Tech.Prog
8
Some.College
78
Coll.Grad
58
Some.Grad/Prof.School
4
Master's
22
Doctoral/Prof.Deg
7
Then by racial group:
> # Get frequency tables, saving tables for IOD
> t.lang <- table(f.lang, f.race)
> t.lang
f.race
f.lang
Hispanic Asian
~English
21
44
English
134
67
> t.school <- table(f.school, f.race)
> t.school
f.race
f.school Hispanic Asian
Public
101
85
Private
54
26
> t.momed <- table(f.momed, f.race)
> t.momed
f.race
f.momed
Hispanic Asian
8th.Grade.or.Less
1
1
9th.to.12th Grade
12
5
HS.Grad/GED
44
26
Voc/Tech.Prog
5
3
Some.College
58
20
Coll.Grad
24
34
Some.Grad/Prof.School
3
1
Master's
6
16
Doctoral/Prof.Deg
2
5
2. Create barcharts:
# Getting barplots
par(mfrow = c(1, 2))
# Home Language - Plot for Hispanic Children
with(subset(hisp.asian, subset = f.race == "Hispanic"),
barplot(table(f.lang)/length(f.lang),
xlab = "Home Lang. for Hispanic Children",
ylab = "Proportions", ylim = c(0,1)))
# Home Language - Plot for Asian Children
with(subset(hisp.asian, subset = f.race == "Asian"),
barplot(table(f.lang)/length(f.lang),
xlab = "Home Lang. for Asian Children",
ylab = "Proportions", ylim = c(0,1)))
# School Type - Plot for Hispanic Children
with(subset(hisp.asian, subset = f.race == "Hispanic"),
barplot(table(f.school)/length(f.school),
xlab = "Sch. Type for Hispanic Children",
ylab = "Proportions", ylim = c(0,1)))
# School Type - Plot for Asian Children
with(subset(hisp.asian, subset = f.race == "Asian"),
barplot(table(f.school)/length(f.school),
xlab = "Sch. Type for Asian Children",
ylab = "Proportions", ylim = c(0,1)))
par(mfrow = c(1, 1))
# Single for Mother's Educational Level, too many bars
# Mother's Educational Level - Hispanic Students
with(subset(hisp.asian, subset = f.race == "Hispanic"),
barplot(table(f.momed)/length(f.momed),
xlab = "Mothers's Educational Level for Hispanic Children",
ylab = "Proportions", ylim = c(0,1)))
# Mother's Educational Level - Asian Students
with(subset(hisp.asian, subset = f.race == "Asian"),
barplot(table(f.momed)/length(f.momed),
xlab = "Mothers's Educational Level for Asian Children",
ylab = "Proportions", ylim = c(0,1)))
1.0
0.0
0.2
0.4
Proportions
English
~English
English
0.8
0.6
0.4
0.2
0.0
0.0
0.2
0.4
Proportions
0.6
0.8
1.0
Home Lang. for Asian Children
1.0
Home Lang. for Hispanic Children
Proportions
0.6
0.8
1.0
0.8
0.6
0.4
0.0
0.2
Proportions
~English
Public
Private
Sch. Type for Hispanic Children
Public
Private
Sch. Type for Asian Children
1.0
0.8
0.6
0.4
0.0
0.2
Proportions
8th.Grade.or.Less
Voc/Tech.Prog
Master's
0.6
0.4
0.2
0.0
Proportions
0.8
1.0
Mothers's Educational Level for Hispanic Children
8th.Grade.or.Less
Voc/Tech.Prog
Master's
Mothers's Educational Level for Asian Children
3. Calculate the indices of dispersion:
> # For Language
> h.vals.lang <- c(t.lang[1,1], t.lang[2,1])
> a.vals.lang <- c(t.lang[1,2], t.lang[2,2])
> # IOD for Language - Hispanic Children
> indexdisp(h.vals.lang)
[1] 0.468512
> # IOD for Language - Asian Children
> indexdisp(a.vals.lang)
[1] 0.9570652
> # For School Type
> h.vals.sch <- c(t.school[1,1], t.school[2,1])
> a.vals.sch <- c(t.school[1,2], t.school[2,2])
> # IOD for School Type - Hispanic Children
> indexdisp(h.vals.sch)
[1] 0.9080541
> # IOD for School Type - Asian Children
> indexdisp(a.vals.sch)
[1] 0.7174742
> # For Mother's Educational Level
> h.vals.ed <- c(t.momed[1,1], t.momed[2,1], t.momed[3,1], t.momed[4,1],
+
t.momed[5,1], t.momed[6,1], t.momed[7,1], t.momed[8,1], t.momed[9,1])
> a.vals.ed <- c(t.momed[1,2], t.momed[2,2], t.momed[3,2], t.momed[4,2],
+
t.momed[5,2], t.momed[6,2], t.momed[7,2], t.momed[8,2], t.momed[9,2])
> # IOD for Mother's Educational Level - Hispanic Children
> indexdisp(h.vals.ed)
[1] 0.8395942
> # IOD for Mother's Educational Level - Asian Children
> indexdisp(a.vals.ed)
[1] 0.8922571
Summarize…
Download