asdfree
asdfree copied to clipboard
add `income concentration examples.R` script to CPS
showing simple usage of main convey
functions
https://github.com/ajdamico/asdfree/tree/master/Current%20Population%20Survey
this nearly matches the gini coefficient, but still need the standard error computation..
library(convey)
library(downloader)
library(survey) # load survey package (analyzes complex design surveys)
library(DBI) # load the DBI package (implements the R-database coding)
library(MonetDB.R) # load the MonetDB.R package (connects r to a monet database)
library(MonetDBLite) # load MonetDBLite package (creates database files in R)
setwd( "C:/My Directory/" )
cps.years.to.download <- 2015
source_url( "https://raw.githubusercontent.com/ajdamico/asdfree/master/Current%20Population%20Survey/download%20all%20microdata.R" , prompt = FALSE , echo = TRUE )
options( survey.replicates.mse = TRUE )
dbfolder <- paste0( getwd() , "/MonetDB" )
db <- dbConnect( MonetDBLite() , dbfolder )
w <- dbGetQuery( db , "SELECT DISTINCT h_seq , hsup_wgt , htotval FROM asec15" )
y <- svydesign( id=~1 , weights = ~hsup_wgt, data = w )
svygini( ~ htotval , y )
inquiry sent to census subject line gini index computation of standard error?
@DjalmaPessoa heard back from census, first draft here https://github.com/ajdamico/asdfree/commit/05b5dad157af4e7d98ab004ccaf2787d34ad375c