Of the cars that have an i.d number 'id' in the years 2000, 2004 and 2008 I would like to find out how many remained in their 2000 deciles in 2004 and 2008 for miles travelled broken into deciles 'deciles_miles.' The issue I'm having is that xttrans2 only report the initial and end period but not subsequent periods in between?
Given I have created a variable 'nyear' that is equal to 3 if the i.d number is in all 3 years I was hoping to perform the xttrans2 command on years 2000 and 2004 then 2004 and 2008. However I'm having trouble as when ever I put specifications in the xttrans command I recieve an error message of some sorts.
For example in the last line of code if I replace nyear==3 with nyear==2 in an attempt to look at years 2000 and 2004 it states there are 'no observations' and returns the error message '__000001 not found'
Would I have to create this manually via the tab command similar to https://www.statalist.org/forums/for...or-each-period ?
Any ideas or help would be much appreciated.
Lastly, when I use a percentiles figure i.e. miles travelled broken into percentiles I receive the error message 'too many values' so is it possible to use a percentile value with the xttrans2 command and if not how would one create transitional probabilities for a figure broken into percentiles or even thousandths.
Code:
keep if year == 2000 | year == 2004 | year == 2008 bys id: gen nyear=[_N] tabstat id, stat(n) by(year) keep if nyear==3 tabstat id, stat(n) by(year) xttrans2 deciles_miles if nyear==3, prob matcell(Trans)
0 Response to xttrans2 - calculating transitional probabilities for multiple years.
Post a Comment