Question
Source: Discrete Data Analysis with R By: Michael Friendly Exercise 2.4 The data set DanishWelfare in vcd gives a 4-way, 3 4 3 5 table
Source: "Discrete Data Analysis with R" By: Michael Friendly
Exercise 2.4 The data set DanishWelfare in vcd gives a 4-way, 3 4 3 5 table as a data frame in frequency form, containing the variable Freq and four factors, Alcohol, Income, Status, and Urban. The variable Alcohol can be considered as the response variable, and the others as possible predictors.
(a) Read the data and find the total number of cases represented in this table.
(b) See the structure of the data and change the variables Alcohol and Income into ordered variables.
(c) Convert this data frame to table form, DanishWelfare.tab, a 4-way array containing the frequencies with appropriate variable names and level names (hint: review xtabs()).
(d) The variable Urban has 5 categories. Find the total frequencies in each of these.
Exercise 2.5 The data set UKSoccer in vcd gives the distributions of number of goals scored by the 20 teams in the 1995/96 season of the Premier League of the UK Football Association. (a) Verify that the total number of games represented in this table is 380. (c) Express each of the marginal totals as proportions. The result should be like following:
And Exercise 2.6 The one-way frequency table Saxony in vcd records the frequencies of families with 0, 1, 2, . . . 12 male children, among 6115 families with 12 children. Another data set, Geissler, in the vcdExtra package, gives the complete tabulation of all combinations of boys and girls in families with a given total number of children (size). The task here is to make an equivalent table, Saxony12 from the Geissler data.
(a) Use subset() to make a data frame, sax12 containing the Geissler observations in families with size==12. Sample result:
(b) Select the columns for boys and Freq.
(c) Use xtabs() with a formula, Freq ~ boys, to create the one-way table.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started