Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: GB2 question


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: GB2 question
Date   Fri, 1 Jan 2010 12:57:21 +0000 (GMT)

--- On Thu, 31/12/09, Jon Schwabish wrote:
> Is there a way to fix the process so that I can estimate
> the same predictions for the same people over multiple runs?
> That is, when I run the following code it is not the case
> that x1=x2 (even when setting a seed).
> 
> gb2fit inc, stats 
> qgb2 inc, gen(x1)
> 
> gb2fit inc, stats 
> qgb2 inc, gen(x2)
> 
> Ideally, I'd like to generate the same predictions for each
> person if I run my program multiple times.

Do you get the same predictions if use -set sortseed- instead
of -set seed-? -qgb2- looks at the quantile function, which
usually implies sorting, and by default Stata sorts observations
with exactly the same value randomly (from a logical point of 
view that is the most reasonable choice, but in practice it can
lead to surprises like the one you are facing). Moreover, the 
random sorting is not governed by -set seed-, but by 
-set sortseed-.
 
> Also, does anyone know how to construct a picture of the
> pdf of the GB2 distribution? 

You can use -twoway function- to graph a function, like
in the example below:

*-------------------- begin example --------------------
local a = 1
local b = 2
local p = .5
local q = .25
local B =  exp(lngamma(`p')+lngamma(`q')-lngamma(`p'+`q'))

twoway function /// 
 y = `a'*x^(`a'*`p'-1)*(`b'^(`a'*`p')) *   ///
     `B'*(1 + (x/`b')^`a' )^(`p'+`q'))^-1, ///
     range(0 5)
*----------------- end example --------------------------

Alternatively, if the aim is to compare your data with the 
Generalized Beta II distribution, you can use the -hangroot- 
package (If I am allowed some shameless self-promotion).
This can be installed by typing -ssc install hangroot-, you 
can get an idea of the kind of graphs it produced by looking 
at: <http://www.maartenbuis.nl/software/hangroot.html>

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index