我试图做一些事情在Stata或R.获得对数正态分布一些百分位数
我有一个工资分配(百分10,25,50,75,90)的百分位数,我想估计对数正态分布分配以适应它们。在Stata中有一个命令lognfit
,它适合单位记录数据的对数正态分布,但不适用于百分点。
是否值得使用Stata的gmm
命令,使用我的5个数据点来估计对数正态分布的两个参数,作为过度识别的系统?
我试图做一些事情在Stata或R.获得对数正态分布一些百分位数
我有一个工资分配(百分10,25,50,75,90)的百分位数,我想估计对数正态分布分配以适应它们。在Stata中有一个命令lognfit
,它适合单位记录数据的对数正态分布,但不适用于百分点。
是否值得使用Stata的gmm
命令,使用我的5个数据点来估计对数正态分布的两个参数,作为过度识别的系统?
这是一个Stata解决方案。
我给别人留下的景点gmm
。你也可以在标准正态分布的相应分位数上回归记录的分位数。这里是嵌入到实验中的代码,以了解该方法的工作情况。我们从对数正态中产生了1000个样本,每个样本的大小为1000,这是一个平均值为1且SD 2取幂的正态分布。这里是rangestat
,它可以完成所有的回归,每个样本一个回归。
clear
set obs 1000000
set seed 1066
set scheme s1color
gen y = exp(rnormal(1, 2))
egen sample = seq(), block(1000)
collapse (p10) y10=y (p25) y25=y (p50) y50=y (p75) y75=y (p90) y90=y, by(sample)
reshape long y, i(sample) j(p)
gen pred = invnormal(p/100)
gen log_y = log(y)
* must install from SSC using: ssc install rangestat
rangestat (reg) log_y pred, interval(sample 0 0)
qnorm b_cons if p==10, name(G1) yli(1) ytitle("") subtitle(mean known to be 1) yla(, ang(h))
qnorm b_pred if p==10, name(G2) yli(2) ytitle("") subtitle(SD known to be 2) yla(, ang(h))
graph combine G1 G2
谢谢大家的回答我很欣赏,因为我是这个论坛的新成员。 –
谢谢大家的响应。
我正在尝试这两个程序。在该R例如我用的是包library(rriskDistributions)
,特别是像
## example with only two quantiles
q <- stats::qlnorm(p = c(0.025, 0.975), meanlog = 4, sdlog = 0.8)
old.par <- graphics::par(mfrow = c(2, 3))
get.lnorm.par(p = c(0.025, 0.975), q = q)
get.lnorm.par(p = c(0.025, 0.975), q = q, fit.weights = c(100, 1),
scaleX = c(0.1, 0.001))
get.lnorm.par(p = c(0.025, 0.975), q = q, fit.weights = c(1, 100),
scaleX = c(0.1, 0.001))
get.lnorm.par(p = c(0.025, 0.975), q = q, fit.weights = c(10, 1))
get.lnorm.par(p = c(0.025, 0.975), q = q, fit.weights = c(1, 10))
graphics::par(old.par)
matrix I = I(1)
mat lis I
gmm ((y - exp({xb: percentile_10 percentile_20 percentile_25
percentile_30 percentile_50 percentile_60 percentile_75
percentile_90}))/exp({xb:})), instruments(percentile_10
percentile_20 percentile_25 percentile_30 percentile_50 percentile_60
percentile_75 percentile_90) twostep
下面是使用GMM,当然第一次尝试用GMM尝试我错过了一些东西。
尼克考克斯的答案很棒。我会尝试用这种方法来适合我的数据。
为什么你提到R时,这似乎是一个Stata问题? – lebelinoz
R标记已恢复。 –