Question

In: Math

The dataset HairEyesColor in R contains classifications of students by gender, color, and eye color. a)...

The dataset HairEyesColor in R contains classifications of students by gender, color, and eye color.

a) How many students are included in the data set?
b) Display the information using mosaicplot (HairEyeColor, col=c(1,2))
c) Is hair color independent of eye color for men?
d) Is hair color independent of eye color for women?

Use R and show R code

Solutions

Expert Solution

The R code is as follows

require(graphics)
data("HairEyeColor")
HairEyeColor

sum(HairEyeColor)
## Full mosaic
mosaicplot(HairEyeColor)
## Aggregate over sex (as in Snee's original data)
x <- apply(HairEyeColor, c(1, 2), sum)
x
mosaicplot(x, main = "Relation between hair and eye color")

# Mosaic Plot using VCD
library(vcd)
mosaic(HairEyeColor, shade=TRUE, legend=TRUE,main = "Relation between hair and eye color")

The results are

HairEyeColor
, , Sex = Male

Eye
Hair Brown Blue Hazel Green
Black 32 11 10 3
Brown 53 50 25 15
Red 10 10 7 7
Blond 3 30 5 8

, , Sex = Female

Eye
Hair Brown Blue Hazel Green
Black 36 9 5 2
Brown 66 34 29 14
Red 16 7 7 7
Blond 4 64 5 8

> sum(HairEyeColor)
[1] 592

The colors represent the level of the residual for that cell / combination of levels. The legend is presented at the plot's right. More specifically, blue means there are more observations in that cell than would be expected under the null model (independence). Red means there are fewer observations than would have been expected.

we see that the values are signficant for all hair colors within the male and female combinations , hence there is a relationship

read 2 rows from the graph at a time


Related Solutions

A class collects data on eye color and gender and organizes it into the table shown....
A class collects data on eye color and gender and organizes it into the table shown. Brown Blue Green Male 24 14 10 Female 20 20 12 Use the data to find the probability that a person randomly selected from this group: (a) does not have brown eyes. (b) has brown eyes or blue eyes. (c) is male or has green eyes. (d) is female, given that the person has blue eyes. (e) Find the probability that two people selected...
The dataset ’anorexia’ in the MASS package in R-Studio contains data for an anorexia study. In...
The dataset ’anorexia’ in the MASS package in R-Studio contains data for an anorexia study. In the study, three treatments (Treat) were applied to groups of young female anorexia patients, and their weights before (Prewt) and after (Postwt) treatment were recorded. The three treatments adminstered were no treatment (Cont), Cognitive Behavioural treatment (CBT), and family treatment (FT). Determine at the 5% significance level if there is a difference in mean weight gain between those receiving no treatment and those receiving...
The dataset ’anorexia’ in the MASS package in R-Studio contains data for an anorexia study. In...
The dataset ’anorexia’ in the MASS package in R-Studio contains data for an anorexia study. In the study, three treat- ments (Treat) were applied to groups of young female anorexia patients, and their weights before (Prewt) and after (Postwt) treatment were recorded. The three treatments adminstered were no treatment (Cont), Cognitive Behavioural treatment (CBT), and family treatment (FT). Determine at the 5% significance level if there is a difference in mean weight gain between those receiving no treatment and those...
The R library faraway contains the pima dataset. We will fit a model with test as...
The R library faraway contains the pima dataset. We will fit a model with test as a response and bmi (only) as a predictor to see the relationship between the odds of a patient showing signs of diabetes and his/her bmi. The odds o and probability p are related by: o = p/(1-p), p = o(1+o) Using the GLM function: a. Please estimate the amount of increase in the log(odds) when the bmi increases by 10. b. Give a 95%...
2. The dataset ’anorexia’ in the MASS package in R-Studio contains data for an anorexia study....
2. The dataset ’anorexia’ in the MASS package in R-Studio contains data for an anorexia study. In the study, three treatments (Treat) were applied to groups of young female anorexia patients, and their weights before (Prewt) and after (Postwt) treatment were recorded. The three treatments adminstered were no treatment (Cont), Cognitive Behavioural treatment (CBT), and family treatment (FT). Determine at the 5% significance level if Cognitive Behavioral treatment is effective in helping patients gain weight. Perform all necessary steps for...
In humans, brown eye color (B) is dominant over blue (b) while right-handedness (R) is dominant...
In humans, brown eye color (B) is dominant over blue (b) while right-handedness (R) is dominant over left-handedness (r). A brown-eyed, right-handed man marries a blue-eyed, right-handed woman. Their first child is blue-eyed and left-handed. List the genotypes of the parents.
The at rest pulse rate of 32 students were recorded. The dataset contains the following variables:...
The at rest pulse rate of 32 students were recorded. The dataset contains the following variables: (1) Gender, (2) Age, (3) Pulse Rate (beats per minute), (4) Ordinal scale for how good they think they are in shape (1 = poor, 5 = good), (5) Weight, (6) Height Is there evidence to suggest the typical pulse rate of males is less than females? Download/Display Data Gender Age Are you in shape? Pulse Rate (min) Weight Height (inches) Female 18 2...
Fitting a linear model using R a. Read the Toluca.txt dataset into R (this dataset can...
Fitting a linear model using R a. Read the Toluca.txt dataset into R (this dataset can be found on Canvas). Now fit a simple linear regression model with X = lotSize and Y = workHrs. Summarize the output from the model: the least square estimators, their standard errors, and corresponding p-values. b. Draw the scatterplot of Y versus X and add the least squares line to the scatterplot. c. Obtain the fitted values ˆyi and residuals ei . Print the...
The data set “UCBAdmissions” in R contains admission decisions by gender at six departments of UC...
The data set “UCBAdmissions” in R contains admission decisions by gender at six departments of UC Berkeley. For this data set, carry out appropriate test for independence between the admission decision and gender for each of the departments. What are your conclusions? Please submit your R script with the answer.
Task- genetics The genes for body color (A), eye color (B) and wing length (C) are...
Task- genetics The genes for body color (A), eye color (B) and wing length (C) are linked to the same autosomal chromosome of D. melanogaster, in the order of A - B - C. For body color, alleles encode 'A +' for wild type and 'a' for black body; for eye color, alleles encode 'B +' for wild type and 'b' for pink eyes; For wing length, alleles code 'C +' for wild type and 'c' for short wings. Wild-type...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT