首页 > 解决方案 > 重新格式化累积数据

问题描述

我有累积家庭的数据,对照他们拥有的累积财富。我附上了少量数据的图像。使用 Rdiff()函数可以让我得到多少家庭拥有多少财富,这是好的。
我的目标是找到我的数据的基尼指数,我首先需要以家庭分布均匀的格式获取该指数。大约有 20000 行,这意味着我需要将拥有的财富一次标准化为 0.005% 或类似的东西,以便实现与家庭(1,2 等)而不是家庭百分比的真实财富分配。

图片

编辑:

structure(list(ï..0.002 = c(0.005, 0.007, 0.017, 0.025, 0.027, 
0.037, 0.047, 0.057, 0.067, 0.075, 0.081, 0.09, 0.1, 0.107, 0.116, 
0.124, 0.13, 0.138, 0.145, 0.151), X.0.002 = c(-0.004, -0.005, 
-0.008, -0.01, -0.01, -0.013, -0.015, -0.017, -0.019, -0.02, 
-0.021, -0.022, -0.024, -0.025, -0.026, -0.027, -0.027, -0.028, 
-0.029, -0.03)), row.names = c(NA, 20L), class = "data.frame")

使用https://ocr.space/进行数据 OCR :

Obs wealth  households  
1   -0.002  0.002   
2   -0.004  0.005   
3   -0.005  0.007   
4   -0.008  0.017   
5   -0.01   0.025   
6   -0.01   0.027   
7   -0.013  0.037   
8   -0.015  0.047   
9   -0.017  0.057   
10  -0.019  0.067   
11  -0.02   0.075   
12  -0.021  0.081   
13  -0.022  0.09    
14  -0.024  0.1 

标签: rstatisticscumulative-frequency

解决方案


我建议您使用该approx函数使用插值将数据转换为均匀分布的形式。

interpolation <- approx(x = df$cum_hh, y = df$cum_wealth, xout = seq(0, 1, by = 0.00005))

interpolation$x ## evenly spaced cumulative households
interpolation$y ## interpolated cumulative wealth

推荐阅读