4.3 Contrasts and differences in proportions

According to Heeringa et al. (2017), the proportions obtained in the rows of a two-way table can be interpreted as estimates for different subpopulations, defined from the levels of a categorical variable. In this context, it is relevant not only to estimate the proportions associated with each group, but also to evaluate the differences between them using linear contrasts.

For example, suppose the interest is in comparing the proportion of women living in poverty with the proportion of men in the same situation. Formally, this contrast can be expressed as \(\hat{p}_F - \hat{p}_M\), where \(\hat{p}_F\) represents the estimated proportion of women in poverty and \(\hat{p}_M\) the estimated proportion of men in that condition. To construct this contrast, the proportions of men and women in poverty are first estimated using the same procedure described in previous chapters. The corresponding results are presented in Table 4.12:

sex_poverty_proportion <- survey_design %>%
  group_by(Sex) %>%
  summarise(proportion = survey_mean(poor,
                                     na.rm = TRUE,
                                     vartype = c("se", "ci")))

sex_poverty_contrast <- svyby(
  formula = ~poor,
  by = ~Sex,
  design = survey_design,
  FUN = svymean,
  na.rm = TRUE,
  covmat = TRUE,
  vartype = c("se", "ci")
)
Table 4.12: Proportion living in poverty by sex
Sex proportion proportion_se proportion_low proportion_upp
Female 0.389 0.032 0.327 0.452
Male 0.395 0.037 0.322 0.467

Once the proportions of men and women living in poverty have been estimated, it is possible to calculate the difference between the two proportions together with its corresponding standard error. In this case, the estimated difference is obtained by subtracting the proportion of men in poverty from the proportion of women in the same condition:

0.3892 - 0.3946
## [1] -0.0054

To correctly calculate the variability associated with this difference, it is not enough to consider only the variances of each estimate separately. It is also necessary to incorporate the covariance between the two proportions, since the estimates come from the same sample and therefore are not independent. The variance-covariance matrix can be obtained with the vcov function; the results are presented in Table 4.13:

vcov(sex_poverty_contrast) %>%
  data.frame()
Table 4.13: Variance-covariance matrix of the poverty proportion by sex
Female Male
Female 0.000998 0.000918
Male 0.000918 0.001342

Based on this matrix, the standard error of the difference in proportions is estimated using the general expression for the variance of a difference between estimators, which corresponds to the sum of the variances of each estimate minus twice the covariance between them. In this case, the calculation is carried out as follows:

sqrt(0.0009983 + 0.0013416 - 2 * 0.0009183)
## [1] 0.0224

However, the survey package makes it possible to carry out this procedure directly using the svycontrast function, which calculates both the linear contrast and its associated standard error. To obtain the difference between the proportions of women and men living in poverty, the following code is used:

svycontrast(
  stat = sex_poverty_contrast,
  contrasts = list(sex_difference = c(1, -1))
) %>%
  data.frame()
##                contrast sex_difference
## sex_difference -0.00532         0.0224

From this, it is concluded that the difference between the proportions of women and men living in poverty is -0.005 (-0.5%), with a standard error of 0.022, indicating that the estimated proportion of women living in poverty is slightly lower than that observed among men.

Another exercise that can be developed from a household survey consists of estimating the proportion of unemployed people by region of residence. To do this, unemployment proportions are estimated for each of the regions considered in the analysis. The results obtained are presented in Table 4.14:

region_unemployment_proportion <- survey_design %>%
  filter(!is.na(unemployed)) %>%
  group_by(Region) %>%
  summarise(proportion = survey_mean(unemployed,
                                     na.rm = TRUE,
                                     vartype = c("se", "ci")))

region_unemployment_contrast <- svyby(
  formula = ~unemployed,
  by = ~Region,
  design = survey_design %>%
    filter(!is.na(unemployed)),
  FUN = svymean,
  na.rm = TRUE,
  covmat = TRUE,
  vartype = c("se", "ci")
)
Table 4.14: Proportion unemployed by region
Region proportion proportion_se proportion_low proportion_upp
Norte 0.049 0.020 0.009 0.088
Sur 0.066 0.024 0.019 0.113
Centro 0.039 0.012 0.014 0.063
Occidente 0.040 0.012 0.016 0.064
Oriente 0.030 0.013 0.005 0.054

Once the unemployment proportions by region have been estimated, the next step is to evaluate whether there are statistically significant differences between some of these proportions using linear contrasts. In particular, the interest is in comparing the differences between the estimated unemployment proportions of different regions. The contrasts considered are \(\hat{p}_{North} - \hat{p}_{Center} = 0.01004\), \(\hat{p}_{South} - \hat{p}_{Center} = 0.02691\), and \(\hat{p}_{West} - \hat{p}_{East} = 0.01046\). In matrix form, these regional contrasts can be written as follows:

\[ \left[\begin{array}{ccccc} 1 & 0 & -1 & 0 & 0\\ 0 & 1 & -1 & 0 & 0\\ 0 & 0 & 0 & 1 & -1 \end{array}\right] \]

To calculate the standard errors associated with each of the previous contrasts, it is necessary to consider not only the variances of the regional estimates, but also the covariances between them. This information is summarized in the variance-covariance matrix of the estimated unemployment proportions by region, presented below:

vcov(region_unemployment_contrast) %>%
  data.frame()
Table 4.15: Variance-covariance matrix of the unemployment proportion by region
Norte Sur Centro Occidente Oriente
Norte 0 0.000 0 0 0
Sur 0 0.001 0 0 0
Centro 0 0.000 0 0 0
Occidente 0 0.000 0 0 0
Oriente 0 0.000 0 0 0

Note that the covariances between the regional estimates are equal to zero because the samples selected in each region are independent of one another. Therefore, the standard error of each contrast is obtained by applying the variance expression for the difference between two estimators. In this case, the calculation reduces to the square root of the sum of the corresponding variances:

sqrt(0.0002981 + 0.0002884 - 2 * 0)
## [1] 0.0242
sqrt(0.0001968 + 0.0002884 - 2 * 0)
## [1] 0.022
sqrt(0.0001267 + 0.0004093 - 2 * 0)
## [1] 0.0232

Alternatively, the survey package allows these contrasts to be calculated directly using the svycontrast function, which obtains both the estimated differences between proportions and their respective standard errors. In this case, the contrasts defined above are estimated as follows:

svycontrast(
  stat = region_unemployment_contrast,
  contrasts = list(
    north_south = c(1, 0, -1, 0, 0),
    south_center = c(0, 1, -1, 0, 0),
    west_east = c(0, 0, 0, 1, -1)
  )
) %>%
  data.frame()
##              contrast     SE
## north_south    0.0100 0.0236
## south_center   0.0269 0.0268
## west_east      0.0105 0.0176

References

Heeringa, S. G., West, B. T., Heeringa, S. G., & Berglund, P. A. (2017). Applied survey data analysis. chapman; hall/CRC.