The built-in R dataset ‘swiss’ gives fertility measures and socio-economic indicators for 47 French-speaking provinces of Switzerland for the period around 1888. The country was undergoing a demographic transition and fertility levels were starting to fall from the typically high levels characteristic of underdeveloped countries. The Fertility column gives a common standardized fertility measure, while the other variables give proportions of the population.
library(psych)
describe(swiss)
## vars n mean sd median trimmed mad min max
## Fertility 1 47 70.14 12.49 70.40 70.66 10.23 35.00 92.5
## Agriculture 2 47 50.66 22.71 54.10 51.16 23.87 1.20 89.7
## Examination 3 47 16.49 7.98 16.00 16.08 7.41 3.00 37.0
## Education 4 47 10.98 9.62 8.00 9.38 5.93 1.00 53.0
## Catholic 5 47 41.14 41.70 15.14 39.12 18.65 2.15 100.0
## Infant.Mortality 6 47 19.94 2.91 20.00 19.98 2.82 10.80 26.6
## range skew kurtosis se
## Fertility 57.50 -0.46 0.26 1.82
## Agriculture 88.50 -0.32 -0.89 3.31
## Examination 34.00 0.45 -0.14 1.16
## Education 52.00 2.27 6.14 1.40
## Catholic 97.85 0.48 -1.67 6.08
## Infant.Mortality 15.80 -0.33 0.78 0.42
“Fertility” has a mean of 70.14 and a standard deviation of 12.49.
pairs(swiss)
We will use a confidence level of 95% to find the confidence interval for Fertility and the other variables. Since n>30, a z test will be the appropriate to use for this dataset.
The significance level alpha = 0.05.
FERTILITY: COnfidence level upper:
#Z test: xbar+qnorm(0.95)*standard error #standard error=standard dev/sqrt(n)
#xbar=70.14, s.d.= 12.49
70.14+qnorm(0.95)*(12.49/sqrt(47))
## [1] 73.13668
Confidence interval lower: #xbar+qnorm(0.05)*standard error
70.14+qnorm(0.05)*(12.49/sqrt(47))
## [1] 67.14332
Our level of certainty about the true mean for the vaariable FERTILITY is 95% in predicting that the true mean is within the interval between 67.143 and 73.137.
Let’s look at the confidence intervals for the true mean for the remaining variables:
AGRICULTURE:
COnfidence level upper:
#xbar = 50.66, s.d.=22.71
50.66+qnorm(0.95)*(22.71/sqrt(47))
## [1] 56.10873
Confidence interval lower:
50.66+qnorm(0.05)*(22.71/sqrt(47))
## [1] 45.21127
EXAMINATION:
COnfidence level upper:
#xbar = 16.49, s.d.= 7.98
16.49+qnorm(0.95)*(7.98/sqrt(47))
## [1] 18.40461
Confidence interval lower:
16.49+qnorm(0.05)*(7.98/sqrt(47))
## [1] 14.57539
EDUCATION:
COnfidence level upper:
#xbar = 10.98, s.d.=9.62
10.98+qnorm(0.95)*(9.62/sqrt(47))
## [1] 13.28809
Confidence interval lower:
10.98+qnorm(0.05)*(9.62/sqrt(47))
## [1] 8.671906
CATHOLIC:
COnfidence level upper:
#xbar = 41.14, s.d.= 41.70
41.14+qnorm(0.95)*(41.7/sqrt(47))
## [1] 51.14494
Confidence interval lower:
41.14+qnorm(0.05)*(41.7/sqrt(47))
## [1] 31.13506
INFANT MORTALITY:
COnfidence level upper:
#xbar = 19.94, s.d.= 2.91
19.94+qnorm(0.95)*(2.91/sqrt(47))
## [1] 20.63819
Confidence interval lower:
19.94+qnorm(0.05)*(2.91/sqrt(47))
## [1] 19.24181