我进行了两个样本的 Kolmogorov-Smirnov 检验。我想要一种将其导出为漂亮图表的方法。我知道简单的 OLS 回归有outreg2
,但有没有可以用于 KS 测试的等价物?
问问题
46 次
1 回答
0
这是两组案例的一些代码。两变量情况的代码在一定程度上必然有所不同,但我认为更容易。
sysuse auto, clear
* redundant in this case, but not in all others
drop if missing(mpg, foreign)
sort mpg foreign
cumul mpg if foreign, gen(cdf_foreign)
cumul mpg if !foreign, gen(cdf_domestic)
foreach v of var cdf* {
replace `v' = `v'[_n-1] if missing(`v')
}
foreach v of var cdf* {
bysort mpg (`v') : replace `v' = `v'[_N]
}
foreach v of var cdf* {
replace `v' = 0 if missing(`v')
}
gen diff = abs(cdf_domestic - cdf_foreign)
sort diff
replace diff = . if diff != diff[_N]
set scheme s1color
line cdf_foreign cdf_domestic mpg, c(J J) sort color(blue red) ///
|| rspike cdf_foreign cdf_domestic mpg if diff < . , ///
legend(order(2 "Domestic" 1 "Foreign") ring(0) pos(11) col(1)) yla(0 0.25 0.5 0.75 1, ang(h))
于 2021-02-09T13:58:56.840 回答