Does anyone know how to caculate th Shannon
-Weiner index using stata?
#delimit ; * PREDICT FORECAST predict std_f, stdf; #delimit cr
#delimit ; // PREDICT FORECAST predict std_f, stdf; #delimit cr
clear set obs 10 gen str names = "" gen num = _n su num, meanonly di `r(max)' local abc a b c d e f g h i l forval i = 1/`r(max)' { foreach x of local abc { replace names=`"`x'"' if num == `i' } }
global y2 fdwti fdcoal strg_dev_fd fd_ng global exog weathershockhdd storage_sf var $y2 , lags(1) exog($exog)
estimates store m1_1L_f forecast create m1_1L_model, replace forecast estimates m1_1L_f
forecast solve, suffix(_forecast) begin(date2[`i']) periods(4)
* Example generated by -dataex-. To install: ssc install dataex clear input byte emp_stat int year float urbdum1 int age byte yrseduc float Under5 0 1995 1 40 10 0 1 1995 1 28 13 1 1 1995 1 23 13 0 0 1995 1 31 10 0 1 1995 1 37 13 0 1 1995 1 45 10 0 1 1995 1 47 12 0 1 1995 1 35 12 1 1 1995 1 35 12 1 0 1995 1 40 10 0 1 1995 1 39 . 0 1 1995 1 42 12 0 1 1995 1 21 12 0 1 1995 1 34 12 1 1 1995 1 41 12 0 1 1995 1 23 12 0 1 1995 1 55 13 0 1 1995 1 31 15 0 1 1995 1 46 12 0 1 1995 1 21 12 0 1 1995 1 34 15 1 0 1995 1 43 12 0 1 1995 1 29 13 1 1 1995 1 43 12 0 1 1995 1 36 12 0 1 1995 1 39 11 0 1 1995 1 45 12 0 1 1995 1 37 12 0 1 1995 1 41 12 0 1 1995 1 38 12 1 1 1995 1 39 12 0 1 1995 1 45 10 0 1 1995 1 36 11 1 1 1995 1 25 10 0 1 1995 1 27 12 0 1 1995 1 34 6 1 1 1995 1 38 10 1 1 1995 1 28 9 0 0 1995 1 31 9 1 1 1995 1 38 6 0 0 1995 1 22 9 1 1 1995 1 41 7 1 1 1995 1 26 8 1 1 1995 1 19 12 0 1 1995 1 20 12 1 1 1995 1 33 10 1 1 1995 1 43 9 0 1 1995 1 19 10 0 1 1995 1 23 12 0 1 1995 1 46 7 0 0 1995 1 23 10 0 1 1995 1 33 10 0 1 1995 1 42 13 0 1 1995 1 27 12 1 1 1995 1 25 12 0 1 1995 1 23 12 0 0 1995 1 20 11 1 1 1995 1 23 12 1 1 1995 1 39 12 0 1 1995 1 50 7 0 1 1995 1 33 8 0 1 1995 1 26 10 1 1 1995 1 19 12 1 1 1995 1 28 9 1 1 1995 1 29 12 0 1 1995 1 34 9 1 0 1995 1 20 7 1 1 1995 1 30 8 1 1 1995 1 43 9 0 1 1995 0 32 15 1 0 1995 0 29 8 0 0 1995 0 21 12 0 1 1995 0 22 12 0 1 1995 0 49 6 0 1 1995 0 50 12 0 1 1995 0 30 8 0 1 1995 0 41 6 1 1 1995 0 22 6 1 1 1995 0 24 6 1 1 1995 0 30 6 1 1 1995 0 52 6 0 1 1995 1 24 10 0 1 1995 1 30 12 0 1 1995 1 24 12 1 0 1995 1 28 12 1 0 1995 1 24 12 0 1 1995 1 43 10 0 0 1995 1 34 15 1 1 1995 1 32 12 0 1 1995 1 39 12 0 1 1995 1 54 10 0 1 1995 1 25 12 0 1 1995 1 28 8 0 1 1995 1 27 10 0 1 1995 1 42 12 0 1 1995 1 21 12 0 1 1995 1 24 12 0 1 1995 1 23 12 0 1 1995 1 26 12 1 1 1995 1 24 13 0 end label values age age
levelsof person, local(levels) foreach l of local levels { newey2 depvar mean_depvar if person == `l', force lag(4) }
yq is not regularly spaced -- use the force option to override
sysuse auto gen pw = 1 svyset [pw=pw] svy: reg mpg c.weight esttab, cells(b & se(par))
sysuse auto gen pw = 1 svyset [pw=pw] svy: mean mpg estat sd mat values = (r(mean),r(sd))' mat rownames values = "Mean" "SD" esttab matrix(values), cells(Mean & SD(par))
webuse grunfeld,clear replace invest = . if inrange(year, 1940, 1950) twoway line invest year if com == 1, cmissing(n)
esize twosample AGE, by(FEMALE) cohen
* Example generated by -dataex-. To install: ssc install dataex clear input double(AGE RACE FEMALE) 90 1 1 86 1 0 72 2 0 72 2 1 88 1 1 64 1 0 77 1 1 90 2 1 81 1 1 87 1 1 64 1 0 86 3 1 60 1 0 90 2 1 81 1 1 83 1 1 88 1 1 87 1 1 83 3 1 88 2 1 82 1 1 87 1 0 64 1 0 87 1 1 79 1 0 80 1 1 90 1 0 89 1 0 89 1 0 89 1 0 90 1 0 84 1 0 73 1 0 72 1 0 87 1 0 81 1 1 90 1 0 75 1 1 70 1 0 73 1 0 90 1 1 78 1 0 75 1 1 80 1 0 68 1 1 71 1 0 84 1 1 90 1 1 88 1 1 89 3 0 end
mi passive: gen ex_bmi = 0 mi passive: replace ex_bmi = 1 if bmi>45
mi estimate: svy: total ex_bmi, over(age_cat) mi estimate: omitted terms vary The set of omitted variables or categories is not consistent between m=1 and m=9; this is not allowed. To identify varying sets, you can use mi xeq to run the command on individual imputations or you can reissue the command with mi estimate, noisily
m=8 data: -> total ex_bmi, over(age_cat) cformat(%9.0f) noisily Total estimation Number of obs = 7,581 _subpop_1: age_cat = 40-49 _subpop_2: age_cat = 50-59 _subpop_3: age_cat = 60-69 _subpop_4: age_cat = 70-79 _subpop_5: age_cat = 80+ -------------------------------------------------------------- Over | Total Std. Err. [95% Conf. Interval] -------------+------------------------------------------------ ex_bmi | _subpop_1 | 53 7 39 67 _subpop_2 | 33 6 22 44 _subpop_3 | 32 6 21 43 _subpop_4 | 8 3 2 14 _subpop_5 | 0 (omitted) -------------------------------------------------------------- m=9 data: -> total ex_bmi, over(age_cat) cformat(%9.0f) noisily Total estimation Number of obs = 7,581 _subpop_1: age_cat = 40-49 _subpop_2: age_cat = 50-59 _subpop_3: age_cat = 60-69 _subpop_4: age_cat = 70-79 _subpop_5: age_cat = 80+ -------------------------------------------------------------- Over | Total Std. Err. [95% Conf. Interval] -------------+------------------------------------------------ ex_bmi | _subpop_1 | 51 7 37 65 _subpop_2 | 33 6 22 44 _subpop_3 | 33 6 22 44 _subpop_4 | 8 3 2 14 _subpop_5 | 1 1 -1 3 --------------------------------------------------------------