The Data: Dr. Arbuthnot’s Baptism Records

source("http://www.openintro.org/stat/data/arbuthnot.R")
head(arbuthnot)
##   year boys girls
## 1 1629 5218  4683
## 2 1630 4858  4457
## 3 1631 4422  4102
## 4 1632 4994  4590
## 5 1633 5158  4839
## 6 1634 5035  4820
tail(arbuthnot)
##    year boys girls
## 77 1705 8366  7779
## 78 1706 7952  7417
## 79 1707 8379  7687
## 80 1708 8239  7623
## 81 1709 7840  7380
## 82 1710 7640  7288

Ex 1. What command would you use to extract just the counts of girls baptized?

## Girls batized each year
arbuthnot$girls
##  [1] 4683 4457 4102 4590 4839 4820 4928 4605 4457 4952 4784 5332 5200 4910
## [15] 4617 3997 3919 3395 3536 3181 2746 2722 2840 2908 2959 3179 3349 3382
## [29] 3289 3013 2781 3247 4107 4803 4881 5681 4858 4319 5322 5560 5829 5719
## [43] 6061 6120 5822 5738 5717 5847 6203 6033 6041 6299 6533 6744 7158 7127
## [57] 7246 7119 7214 7101 7167 7302 7392 7316 7483 6647 6713 7229 7767 7626
## [71] 7452 7061 7514 7656 7683 5738 7779 7417 7687 7623 7380 7288
##Total Girls baptized from 1629-1710
sum(arbuthnot$girls)
## [1] 453841

Ex 2. Is there an apparent trend in the number of girls baptized over the years?How would you describe it?

plot(x = arbuthnot$year, y = arbuthnot$girls, type = "l", col="red", lwd="2.5", main = "Arbuthnot", xlab = "Year", ylab = "Number of baptized Girls")

The number of girls batized started to grow from around 1659 till 1700 and reached it’s maximum between 1704-1705.

Ex 3. Now, make a plot of the proportion of boys over time. What do you see? Tip: If you use the up and down arrow keys, you can scroll through your previous commands, your so-called command history. You can also access it by clicking on the history tab in the upper right panel. This will save you a lot of typing in the future

##Plot of the proportion of boys over the time
plot(x = arbuthnot$year, y = arbuthnot$boys / (arbuthnot$boys + arbuthnot$girls), type = "l", col="blue", lwd="2.5", main = "Arbuthnot", xlab = "Year", ylab = "Proportion of Boys")

The maximum number of the propotion of boys is around in 1661. The propotion of boys is slowly goes down over the years and the minimun of the propotion of boys is approximately in 1704.

On Your Own

These data come from a report by the Centers for Disease Control http://www.cdc.gov/nchs/data/nvsr/nvsr53/nvsr53_20.pdf. Check it out if you would like to read more about an analysis of sex ratios at birth in the United States.

source("http://www.openintro.org/stat/data/present.R")
head(present)
##   year    boys   girls
## 1 1940 1211684 1148715
## 2 1941 1289734 1223693
## 3 1942 1444365 1364631
## 4 1943 1508959 1427901
## 5 1944 1435301 1359499
## 6 1945 1404587 1330869
tail (present)
##    year    boys   girls
## 58 1997 1985596 1895298
## 59 1998 2016205 1925348
## 60 1999 2026854 1932563
## 61 2000 2076969 1981845
## 62 2001 2057922 1968011
## 63 2002 2057979 1963747

1. What years are included in this data set? What are the dimensions of the data frame and what are the variable or column names?

##Years included in this data set
present$year
##  [1] 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953
## [15] 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967
## [29] 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981
## [43] 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995
## [57] 1996 1997 1998 1999 2000 2001 2002
## Dimensions of the Data Frame
dim (present)
## [1] 63  3
## Colomn Names
names(present)
## [1] "year"  "boys"  "girls"

2. How do these counts compare to Arbuthnot’s? Are they on a similar scale?

summary(present$boys)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 1211684 1799857 1924868 1885600 2058524 2186274
summary(arbuthnot$boys)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    2890    4759    6073    5907    7576    8426
summary(present$girls)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## 1148715 1711405 1831679 1793915 1965538 2082052
summary(arbuthnot$girls)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    2722    4457    5718    5535    7150    7779

By comparing the counts we can see a huge difference between Arbuthnot and Present data summary and can conclude these counts not on a similar scale.

3. Make a plot that displays the boy-to-girl ratio for every year in the data set. What do you see? Does Arbuthnot’s observation about boys being born in greater proportion than girls hold up in the U.S.? Include the plot in your response.

Boy-to-girl ratio for every year

present$boys/present$girls 
##  [1] 1.054817 1.053969 1.058429 1.056767 1.055757 1.055391 1.058698
##  [8] 1.055449 1.053820 1.053760 1.053716 1.052078 1.050934 1.053399
## [15] 1.051460 1.050742 1.051286 1.050672 1.049374 1.049480 1.048873
## [22] 1.050057 1.047948 1.052717 1.047188 1.051137 1.048540 1.049964
## [29] 1.053417 1.052997 1.054719 1.051845 1.051271 1.052129 1.054797
## [36] 1.053605 1.052538 1.052569 1.052657 1.051749 1.052837 1.051615
## [43] 1.050597 1.051976 1.050199 1.052061 1.050876 1.050000 1.049991
## [50] 1.049720 1.049676 1.045849 1.050017 1.049955 1.047877 1.048928
## [57] 1.047062 1.047643 1.047190 1.048791 1.047998 1.045686 1.047986

Boy-to-girl ratio for plot

plot(x = present$year, y = present$boys /present$girls, type = "l", col = "blue", lwd="2.5", main = "Present Boy-To-Girl Ratio", xlab = "Year", ylab = "Boy-to-Girl Ratio")

##Boy to Girl proportion over the years
present$boys / (present$boys + present$girls)
##  [1] 0.5133386 0.5131376 0.5141926 0.5138001 0.5135613 0.5134745 0.5142562
##  [8] 0.5134883 0.5131024 0.5130881 0.5130778 0.5126891 0.5124173 0.5130027
## [15] 0.5125423 0.5123716 0.5125011 0.5123550 0.5120462 0.5120713 0.5119269
## [22] 0.5122088 0.5117064 0.5128408 0.5115250 0.5124656 0.5118474 0.5121866
## [29] 0.5130068 0.5129073 0.5133154 0.5126337 0.5124973 0.5127013 0.5133340
## [36] 0.5130513 0.5127982 0.5128057 0.5128266 0.5126110 0.5128692 0.5125792
## [43] 0.5123372 0.5126648 0.5122425 0.5126849 0.5124035 0.5121951 0.5121931
## [50] 0.5121286 0.5121179 0.5112054 0.5121992 0.5121845 0.5116894 0.5119398
## [57] 0.5114951 0.5116337 0.5115255 0.5119072 0.5117182 0.5111665 0.5117154
plot(x = present$year, y = present$boys /(present$boys +present$girls), type = "l", col = "blue", lwd="2.5", main = "Present Proportion of Boys", xlab = "Year", ylab = "Proportion of Boys")

Based on the analysis above, Boy-to-girl ratio as well as proportion are decreasing over the time.

Also, by comparing the proportions, we can conclude that Arbuthnot’s observation about boys being born in greater proportion than girls holds up.

present$boys /(present$boys+present$girls) > present$girls/(present$boys+present$girls)
##  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [15] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [29] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [43] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [57] TRUE TRUE TRUE TRUE TRUE TRUE TRUE

4. In what year did we see the most total number of births in the U.S.? You can refer to the help files or the R reference card http://cran.r-project.org/doc/contrib/Short-refcard.pdf to find helpful commands

present$year[(present$girls + present$boys) == max(present$boys + present$girls)]
## [1] 1961