grahamstark / SurveyDataWeighting.jl

reweighting survey data so that it sums to some target totals.
MIT License
3 stars 0 forks source link

Moving from R to Julia #2

Open ayushpatnaikgit opened 2 years ago

ayushpatnaikgit commented 2 years ago

Hi, thank you for making this package.

I am moving my code from R to Julia. I am a user of the survey package in R. The R code takes several hours to run so I wonder if this Julia package can be used for my problem.

I have household level data of income and I want to compute the statewise total. Here is how I do it in R:

    srvydsgn <- svydesign(id= ~HOUSEHOLD_ID, strata = ~STATE,
    weight = ~WEIGHT_FOR_STATE, data = monthly_income_data, nest = TRUE)
    state.total.income <- svyby(~income),
        by= ~STATE+YEARMON, design = srvydsgn, svytotal, keep.var=FALSE)

state.total.income will be a monthly timeseries of aggregate household income.

I think it will be useful to have a section of the documentation of the package on moving from R to Julia.

grahamstark commented 2 years ago

Hi Ayush,

thanks for this. I confess I've never used R Survey Design but will have a look at what it's doing. Or could you explain what the code above does?

thanks for your interest,

Graham