Exercise 3.1 See the Arbuthnot data in HistData library. The Arbuthnot data set refers to Dr. John Arbuthnot, an 18th century physician, writer, and mathematician. He was interested in the ratio of newborn boys to newborn girls, so he gathered the christening records for children born in London for every year from 1629 to 1710. It also contains the variable Ratio, giving the ratio of male to female births.

library(“HistData”) library(“plotly”)

summary(Arbuthnot)

3.1 a. Make a plot of Ratio over Year. What features stand out? Which plot do you prefer to display the tendency for more male births?

maxRatio<-max(Arbuthnot\(Ratio) minRatio<-min(Arbuthnot\)Ratio) plot_ly(Arbuthnot, x= ~Year, y= ~Ratio, name=“Male vs Female Birth Ratio”, type=‘scatter’, mode=‘lines’,line = list(color = ‘black’, width = 1) ) %>% add_trace(y = ~maxRatio, name = ‘Maximum’, mode = ‘lines’, line = list(color = ‘blue’, width = 1)) %>% add_trace(y = ~minRatio, name=“Minimum”, mode =‘lines’, line = list(color= ‘green’, width=1)) %>% add_trace(y=1, name=“Reference Line”, mode=‘lines’, line = list(color=‘red’, width=1))

3.2 b. Plot the total number of christenings, Males + Females or Total (in 000s) over time. What unusual features do you see?

maxT <- max(Arbuthnot\(Total) minT <- min(Arbuthnot\)Total) plot_ly(Arbuthnot, x = ~Year, y = ~Total, name = ‘Total Number of Christenings(Unit:1,000)’, type = ‘scatter’, mode = ‘line’, line = list(color = ‘black’, width = 1)) %>% add_trace(y = ~maxT, name = ‘Max Christening’, line = list(color = ‘blue’, width = 1)) %>% add_trace(y = ~minT, name = ‘Min Christening’, line = list(color = ‘green’, width = 1))

Exercise 3.3 Use the data set WomenQueue to: (c) Make a reasonable plot showing departure from the binomial distribution.

## Number of cases in table: 100 
## Number of factors: 1

number of women in queues of length 10 might depart from a binomial distribution, Bin(n = 10, p = 1/2).

The deviation from binomial distribution might be caused by a small sample size, or a special queueing preference displayed by the women - the latter would require further investigation.

Exercise 3.4 Work on the distribution of male children in families in “Saxony” by fitting a binomial distribution, (n=12,p=1/2) , specifying equal probability for boys and girls. [Hint: youneed to specify both size and prob values for goodfit ().]

a.Carry out the GOF test for this fixed binomial distribution. What is the ratio of ??2/df? What do you conclude?

## 
##   Goodness-of-fit test for binomial distribution
## 
##                      X^2 df     P(> X^2)
## Likelihood Ratio 97.0065 11 6.978187e-16

b.Test the additional lack of fit for the model Bin(n=12,p=1/2) compared to the model Bin(n=12,p ^) where p hat is estimated from the data.

## 
##   Goodness-of-fit test for binomial distribution
## 
##                       X^2 df     P(> X^2)
## Pearson          249.1954 12 2.013281e-46
## Likelihood Ratio 205.4060 12 2.493625e-37

c.Use the plot(goodfit ()) method to visualize these two models.