Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: ksmirnov
From
Maarten Buis <[email protected]>
To
[email protected]
Subject
Re: st: ksmirnov
Date
Tue, 21 Aug 2012 12:26:41 +0200
On Tue, Aug 21, 2012 at 11:40 AM, Guessab Houda wrote:
> I mean how can I say that the distribution is more or less similar to student with 8 degrees?
For that I typically like to add a portfolio of simulated variables
that were drawn from the distribution of interest. That way you can
get an informal idea of how much variation on can reasonably expect if
your model (a student t-distribution with 8 degrees of freedom) is
true.
*------------------ begin example -------------------
sysuse auto, clear
egen rank = rank(mpg), unique
su rank, meanonly
gen expected = -invttail(8, (rank - 0.5) / `r(max)')
su mpg
local mean = r(mean)
local sd = r(sd)
mata
void function dangerous_sort(string scalar var,
string scalar touse) {
real matrix x
st_view(x =., ., var, touse)
x[.,.] = x[order(x,1)]
}
end
gen byte touse = 1
sort expected
forvalues i = 1/10 {
gen sim`i' = rt(8)*`sd'/sqrt(4/3) + `mean'
mata: dangerous_sort("sim`i'", "touse")
local lpattern "`lpattern' solid"
local lcolor "`lcolor' gs8"
}
local lpattern "lpattern(`lpattern')"
local lcolor "lcolor(`lcolor')"
twoway line sim* expected, ///
`lcolor' `lpattern' || ///
scatter mpg expected, mstyle(p1) || ///
function t_8 = `mean' + x * `sd' / sqrt(4/3), ///
ra(expected) lstyle(refline) ///
legend(order(1 "simulation" ///
11 "observed" ///
12 "reference"))
*------------------- end example --------------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )
Hope this helps,
Maarten
---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany
http://www.maartenbuis.nl
---------------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/