Goodness of fit to an expected (model-based) age distribution

ageChildren(
  age,
  u5mr = 0,
  groups = "6:17=1; 18:29=2; 30:41=3; 42:53=4; 54:59=5"
)

Arguments

age

Vector of ages

u5mr

Under five years mortality rate as deaths / 10,000 persons / day

groups

Age groupings specified as recodes parameter in the bbw::recode() function; default is "6:17=1; 18:29=2; 30:41=3; 42:53=4; 54:59=5"

Value

A list of class "ageChildren" with:

VariableDescription
u5mrUnder five years mortality rate as deaths / 10000 persons / day
observedTable of counts in each (year-centred) age group
expectedTable of expected counts in each (year-centred) age group
X2Chi-squared test statistic
dfDegrees of freedom for Chi-squared test
pp-value for Chi-squared test

Examples

# Chi-Squared test for age of children in dp.ex02 sample dataset using an # u5mr of 1 / 10,000 / day. svy <- dp.ex02 ac <- ageChildren(svy$age, u5mr = 1) ac
#> #> Age Test (Children) #> #> X-squared = 21.4366, df = 4, p = 0.0003 #>
# Apply function to each sex separately # Males acM <- ageChildren(svy$age[svy$sex == 1], u5mr = 1) acM
#> #> Age Test (Children) #> #> X-squared = 15.8496, df = 4, p = 0.0032 #>
# Females acF <- ageChildren(svy$age[svy$sex == 2], u5mr = 1) # Simplified call to function by sex by(svy$age, svy$sex, ageChildren, u5mr = 1)
#> svy$sex: 1 #> #> Age Test (Children) #> #> X-squared = 15.8496, df = 4, p = 0.0032 #> #> ------------------------------------------------------------ #> svy$sex: 2 #> #> Age Test (Children) #> #> X-squared = 6.8429, df = 4, p = 0.1444 #>