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

From |
Maarten buis <maartenbuis@yahoo.co.uk> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Markov processes and xttrans |

Date |
Wed, 30 Sep 2009 21:34:54 +0000 (GMT) |

--- On Wed, 30/9/09, Dmitriy Krichevskiy wrote: > I have a large panel data in which I have discretized > income into quintiles. I then tested to see if transition > processes (governing quintile transitions) are stationary. > I found that I can characterize transitions as Markov. So > I followed with xttrans command estimating transition > probabilities. But I also want to know what my confidence > intervals for transition probabilities estimates are? Here is a quick stab at an approximate solution. It copies the strategy of the official Stata command -proportion-, which is that these proportions/transition probabilities are nothing other means, so we can use the standard formulas for inference about the mean to get an approximation of the confidence intervals about these proportions. I am thus conveniently ignoring lots of potential problems here, and I leave it up to you to decide whether you find that acceptable. Hope this helps, Maarten *------------------ begin example ------------------------------ program drop _all program define xttransci, rclass byable(recall) sort *! version 1.0.0 MLB 30Sept2009 *! based on xttrans version 6, missing syntax varname [if] [in] [, I(varname) T(varname) ] xt_iis `i' local ivar "`s(ivar)'" xt_tis `t' local tvar "`s(timevar)'" tempvar touse mark `touse' `if' `in' markout `touse' `varlist' `ivar' `tvar' tempvar was is quietly { sort `ivar' `tvar' by `ivar': gen float `was' = `varlist' if _n<_N by `ivar': gen float `is' = `varlist'[_n+1] if _n<_N by `ivar': replace `touse'=0 if `touse'[_n+1]==0 & _n<_N levelsof `was' local levs `r(levels)' local k : word count `levs' tempname res matrix `res' = J(`=3*`k'',`k', .) tokenize `levs' forvalues i = 1/`k' { tempvar d`i' gen byte `d`i'' = `is' == ``i'' } forvalues i = 1/`k' { mean `d1'-`d`k'' if `touse' & `was' == ``i'' local ilb = (`i'-1)*3+1 local ip = (`i'-1)*3+2 local iub = (`i'-1)*3+3 local rown `"`rown' ``i'':lb ``i'':p ``i'':ub"' forvalues j = 1/`k' { matrix `res'[`ilb',`j'] = _b[`d`j''] - invttail(e(df_r),0.025)*_se[`d`j''] matrix `res'[`ip',`j'] = _b[`d`j''] matrix `res'[`iub',`j'] = _b[`d`j''] + invttail(e(df_r),0.025)*_se[`d`j''] } } matrix rownames `res' = `rown' matrix colnames `res' = `levs' } matlist `res', format(%9.3f) return matrix result `res' end webuse nlswork, clear xttransci msp exit *------------------------- end example ---------------------------- (For more on examples I sent to the Statalist see: http://www.maartenbuis.nl/example_faq ) -------------------------- 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/

**References**:**st: Markov processes and xttrans***From:*Dmitriy Krichevskiy <krichevskyd@gmail.com>

- Prev by Date:
**st: mi estimate and xtmixed: reporting of groups** - Next by Date:
**st: WG: RE: Identify min and max observations** - Previous by thread:
**st: Markov processes and xttrans** - Next by thread:
**st: re: serial correlation test in fe model** - Index(es):

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