-1

I have some issue, potentially simple but I failed to figure out by far.

So I have a survey design as follows:

design1 = svrepdesign(
    weights=~W10,
    repweights=W,
    data = imputationList(list(imp1, imp2, imp3, imp4, imp5)),
    scale = 1,
    rscales = rep(1/999,1000),
    mse = FALSE,
    type = "bootstrap",
    combined.weights = TRUE
)

It works perfectly with svyby, svyquantiles etc from the package survey, e.g.:

median_income_by_country = MIcombine(
    with(
        design1,
        svyby(
            ~income,
            ~country,
            svyquantile,
            0.5,
            method="constant",
            interval.type="quantile",
            na.rm = TRUE,
            multicore=TRUE
        )
    )
)

Now I need to calculate the Gini index and other complex survey measurements, e.g., Generalized Entropy and Decomposition (svygei, svygeidec) by using the convey package.

So, I started with the simplest calculation to test, i.e.:

require (convey)
design2 <- convey_prep(design1)
gini.index <- svygini(~income, design = design2)

The last line returns an error:

Error in UseMethod("svygini", design) :

no applicable method for 'svygini' applied to an object of class "c('convey.design', 'svyimputationList')"

Thus my question is how to correct it?

Community
  • 1
  • 1
Rom
  • 25
  • 6

1 Answers1

1

from http://asdfree.com/survey-of-consumer-finances-scf.html

library(convey)
scf_design$designs <- lapply( scf_design$designs , convey_prep )

lodown:::scf_MIcombine( with( scf_design , svygini( ~ networth ) ) )
Anthony Damico
  • 5,779
  • 7
  • 46
  • 77
  • Thank you Anthony for your kind reply. I tired it before posting a question here, -the package ‘lodown’ is not available for R version 3.4.1. that I have installed. So I wondered how to sort out the issue of imputation list. I joined imp 1, imp2, imp3, imp4, imp5 dataframes into one, and tested by calculation of quantiles, but the results are slightly different from the ones I got by means of 'survey' package. – Rom Oct 28 '17 at 18:48
  • `devtools::install_github("ajdamico/lodown")` – Anthony Damico Oct 29 '17 at 03:42