R/ageChildren.R
ageChildren.RdGoodness 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" )
| 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 (year-centred) age group |
| expected | Table of expected counts in each (year-centred) age group |
| X2 | Chi-squared test statistic |
| df | Degrees of freedom for Chi-squared test |
| p | p-value for Chi-squared test |
# 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 #>