asdfree icon indicating copy to clipboard operation
asdfree copied to clipboard

add `income concentration examples.R` script to CPS

Open ajdamico opened this issue 8 years ago • 2 comments

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 )

ajdamico avatar Mar 12 '16 14:03 ajdamico

inquiry sent to census subject line gini index computation of standard error?

ajdamico avatar Mar 12 '16 17:03 ajdamico

@DjalmaPessoa heard back from census, first draft here https://github.com/ajdamico/asdfree/commit/05b5dad157af4e7d98ab004ccaf2787d34ad375c

ajdamico avatar Mar 15 '16 17:03 ajdamico