expected: Expected values in a table

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/expected.R

Description

Assuming independence, calculates expected values in a matrix or table.

Usage

1

Arguments

x

is a matrix or table

Details

Assuming independence, calculates expected values in a matrix or table.

Value

expected values

Author(s)

Tomas Aragon, [email protected], http://www.phdata.science

References

Steve Selvin (2001), Epidemiologic Analysis: A Case-Oriented Approach, Oxford University Press

See Also

See also margin.table

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
##From Selvin, 2001, p.2
##year = year of birth
##one+ = one or more congenital defects
##one = one congenital defect
dat <- c(369, 460, 434, 434, 506, 487, 521, 518, 526, 488,
605, 481, 649, 477, 733, 395, 688, 348)

##observed
oi <- matrix(dat, nrow =2)
colnames(oi) <- 1983:1991
rownames(oi) <- c("one+", "one")

##expected
ei <- expected(oi)

##Pearson chi-square test 
chi2.T <- sum((oi - ei)^2/ei)
pchisq(q = chi2.T, df = 8, lower.tail = FALSE)

epitools documentation built on May 29, 2017, 3:40 p.m.

Related to expected in epitools...