Estimate the difference between the average gross hourly earnings of men and women expressed as a percentage of the average gross hourly earnings of men.
svygpg(formula, design, ...)
# S3 method for survey.design
svygpg(formula, design, sex, na.rm = FALSE, ...)
# S3 method for svyrep.design
svygpg(formula, design, sex, na.rm = FALSE, ...)
# S3 method for DBIsvydesign
svygpg(formula, design, sex, ...)
a formula specifying the gross hourly earnings variable
a design object of class survey.design
or class svyrep.design
from the survey
library.
future expansion
formula with a factor with labels 'male' and 'female'
Should cases with missing values be dropped?
Object of class "cvystat
", which are vectors with a "var
" attribute giving the variance and a "statistic
" attribute giving the name of the statistic.
you must run the convey_prep
function on your survey design object immediately after creating it with the svydesign
or svrepdesign
function.
Guillaume Osier (2009). Variance estimation for complex indicators of poverty and inequality. Journal of the European Survey Research Association, Vol.3, No.3, pp. 167-195, ISSN 1864-3361, URL https://ojs.ub.uni-konstanz.de/srm/article/view/369.
Jean-Claude Deville (1999). Variance estimation for complex statistics and estimators: linearization and residual techniques. Survey Methodology, 25, 193-203, URL https://www150.statcan.gc.ca/n1/en/catalogue/12-001-X19990024882.
library(laeken)
library(survey)
data(ses)
names( ses ) <- gsub( "size" , "size_" , tolower( names( ses ) ) )
des_ses <- svydesign(id=~1, weights=~weights, data=ses)
des_ses <- convey_prep(des_ses)
# linearized design
svygpg(~earningshour, des_ses, ~sex)
#> gpg SE
#> earningshour 0.24137 0.0104
# replicate-weighted design
des_ses_rep <- as.svrepdesign( des_ses , type = "bootstrap" )
des_ses_rep <- convey_prep(des_ses_rep)
svygpg(~earningshour, des_ses_rep, ~sex)
#> gpg SE
#> earningshour 0.24137 0.0107
if (FALSE) {
# database-backed design
library(RSQLite)
library(DBI)
dbfile <- tempfile()
conn <- dbConnect( RSQLite::SQLite() , dbfile )
dbWriteTable( conn , 'ses' , ses )
dbd_ses <- svydesign(id=~1, weights=~weights, data="ses", dbname=dbfile, dbtype="SQLite")
dbd_ses <- convey_prep( dbd_ses )
svygpg(formula=~earningshour, design=dbd_ses, sex= ~sex)
dbRemoveTable( conn , 'ses' )
}