TwoKids: Number of Boys in Two-Child Families

Description Usage Format Source References Examples

Description

The number of boys in a sample of 2,444 two-child families.

Usage

1

Format

A data frame with 3 observations on the following 2 variables.

num.boys

a numeric vector

count

a numeric vector

Source

Rodgers, J.L. and D. Doughty. 2001. Does having boys or girls run in the family? Chance Magazine Fall 2001: 8-13.

References

http://www.dartmouth.edu/~chance/chance_news/recent_news/chance_news_10.11.html#item13

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data(TwoKids)
TwoKids
observed <- TwoKids$count
expected <- c(585.3, 1221.4, 637.3)
chisq.test(observed, p = expected, rescale.p = TRUE)

# Alternate calculation, using Pr[male] = 0.512
# and rbinom. See Figure 5.7-1
n <- sum(observed)
pr.m <- 0.512
pr.f <- 0.488

# Calculate the probabilities of 0, 1, and 2 males
(pr.0 <- pr.f^2)
(pr.1 <- pr.m * pr.f + pr.f * pr.m)
(pr.2 <- pr.m^2)

set.seed(1)
(expected2 <- c(rbinom(1, n, pr.0),
                rbinom(1, n, pr.1),
                rbinom(1, n, pr.2)))
chisq.test(observed, p = expected2, rescale.p = TRUE)

Example output

Loading required package: nlme
Loading required package: lattice
Loading required package: grid
Loading required package: mosaic
Loading required package: dplyr

Attaching package: 'dplyr'

The following object is masked from 'package:nlme':

    collapse

The following objects are masked from 'package:stats':

    filter, lag

The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

Loading required package: ggformula
Loading required package: ggplot2

New to ggformula?  Try the tutorials: 
	learnr::run_tutorial("introduction", package = "ggformula")
	learnr::run_tutorial("refining", package = "ggformula")
Loading required package: mosaicData
Loading required package: Matrix

The 'mosaic' package masks several functions from core packages in order to add 
additional features.  The original behavior of these functions should not be affected by this.

Note: If you use the Matrix package, be sure to load it BEFORE loading mosaic.

Attaching package: 'mosaic'

The following object is masked from 'package:Matrix':

    mean

The following objects are masked from 'package:dplyr':

    count, do, tally

The following objects are masked from 'package:stats':

    IQR, binom.test, cor, cor.test, cov, fivenum, median, prop.test,
    quantile, sd, t.test, var

The following objects are masked from 'package:base':

    max, mean, min, prod, range, sample, sum

  num.boys count
1        0   530
2        1  1332
3        2   582

	Chi-squared test for given probabilities

data:  observed
X-squared = 20.038, df = 2, p-value = 4.454e-05

[1] 0.238144
[1] 0.499712
[1] 0.262144
[1]  582 1215  613

	Chi-squared test for given probabilities

data:  observed
X-squared = 16.764, df = 2, p-value = 0.0002289

abd documentation built on May 2, 2019, 4:46 p.m.