R 使用调查数据计算百分之一的富人集中了多少

R 使用调查数据计算百分之一的富人集中了多少,r,survey,R,Survey,我想用R来计算百分之一的富人集中了多少。例如,可能是这样的情况:1%的富人集中了该国33%的总财富 我有一个包含变量的调查数据集: 资产:每一个人(行)的总资产价值 wgt:与每个个体(行)相关的样本重量 计算浓度的最佳方法是什么 非常感谢 欢迎来到SO。请不要被下层选民气馁,我认为你的问题是完全合理的。假设您的调查设计对象是scf.design。。这样,您可以使用 #计算最高百分位的截止点 请看:。嗯,你们对他太严厉了。:)对于我们这些熟悉调查的人来说,这个问题有一个非常简单的程序性答案!

我想用R来计算百分之一的富人集中了多少。例如,可能是这样的情况:1%的富人集中了该国33%的总财富

我有一个包含变量的调查数据集:

  • 资产:每一个人(行)的总资产价值
  • wgt:与每个个体(行)相关的样本重量
计算浓度的最佳方法是什么


非常感谢

欢迎来到SO。请不要被下层选民气馁,我认为你的问题是完全合理的。假设您的调查设计对象是
scf.design
。。这样,您可以使用

#计算最高百分位的截止点

请看:。嗯,你们对他太严厉了。:)对于我们这些熟悉
调查的人来说,这个问题有一个非常简单的程序性答案!我就是那个给你发了一封关于SCF基尼系数的邮件的人。我会试试你的解决方案。效果很好!再次感谢!
# compute the cutoff point for the top percentile
y <- coef( svyquantile( ~ asset , scf.design , 0.99 ) )
# for this, you probably don't need the standard error, 
# so immediately just extract the coefficient (the actual number)
# and discard the standard error term by using the `coef` function
# around the `svyquantile` call

# create a new flag in your survey design object
# that's a 1 if the individual is in the top percentile
# and a 0 for everybody else
scf.design <- update( scf.design , onepct = as.numeric( asset > y ) )

# calculate the aggregate of all assets
# held by the top percentile
# and also held by everybody else
svyby( ~asset , ~onepct , scf.design , svytotal )

# or, if you like, calculate them separately
svytotal( ~asset , subset( scf.design , onepct == 1 ) )

svytotal( ~asset , subset( scf.design , onepct == 0 ) )

# and divide each of those numbers by all assets
# held by everybody
svytotal( ~asset , scf.design )