0

I know there is a package called survey doing similar things. I do not know if there is any code or way to compute percentile ratio in R.

What I would like to get is the relative net worth held by top x% of households. So it will be the ratio:

  • (Top x percentile household's total wealth (0.99 quantile to max) / (total wealth in the economy)*

I found svrqsr in survey package but it gives me relative share, compared with lower 20 percentile households.

Any suggestion, or code reference that I can use?

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
  • See [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) for tips on making a reproducible post that folks can easily answer. I'm guessing without being able to see your data or code, but does `quantile` in base R not work for your purposes? – camille May 01 '18 at 20:05
  • I noticed that I can use svylorenz to compute the numbers. I am trying it out. – user9620331 May 01 '18 at 20:39

2 Answers2

2

follow the directions on http://asdfree.com/survey-of-consumer-finances-scf.html until you get to

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

then use

scf_MIcombine( with( scf_design , svyqsr( ~ networth , alpha1 = 0.01 ) ) )
Anthony Damico
  • 5,779
  • 7
  • 46
  • 77
0

Like @camille said, quantile can give you your threshold(in your case, net worth of the 99 percentile household). After that, it's just a matter of summing the values greater than than the threshold.

amt<-10^rnorm(1e5,4,1) # Assuming a log normal distribution
amt_99<-amt[amt>quantile(amt,0.99)]  #Top 1%
sum(amt_99)/sum(amt)  # Relative net worth
#Output : [1] 0.4521971
Rohit
  • 1,967
  • 1
  • 12
  • 15