R/ageChildren.R
ageChildren.Rd
Goodness of fit to an expected (modelbased) age distribution
ageChildren( age, u5mr = 0, groups = "6:17=1; 18:29=2; 30:41=3; 42:53=4; 54:59=5" )
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

A list of class "ageChildren" with:
Variable  Description 
u5mr  Under five years mortality rate as deaths / 10000 persons / day 
observed  Table of counts in each (yearcentred) age group 
expected  Table of expected counts in each (yearcentred) age group 
X2  Chisquared test statistic 
df  Degrees of freedom for Chisquared test 
p  pvalue for Chisquared test 
# ChiSquared 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) #> #> Xsquared = 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) #> #> Xsquared = 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) #> #> Xsquared = 15.8496, df = 4, p = 0.0032 #> #>  #> svy$sex: 2 #> #> Age Test (Children) #> #> Xsquared = 6.8429, df = 4, p = 0.1444 #>