Quantcast
Channel: Statalist
Viewing all 65051 articles
Browse latest View live

Error Running xtcsd test

$
0
0
Hi Dear,

When I run xtcsd, pesaran after estimating fixed effects model in Stata.....I get the error saying "unknown function *sqrt()
r(133);"
and when I run xtcsd, frees or xtcsd, friedman....In both cases, I get the error saying "no observations
r(2000);"

Can you please guide me what can be the possible reasons for these errors?

Thank you.

define size dummy of city

$
0
0
Dear All, the following question is from here (https://bbs.pinggu.org/forum.php?mod...=1#pid57703787). The data set is
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(id year pop)
3 2003  200
3 2004  500
3 2005  600
3 2006  700
1 2003  600
1 2004  800
1 2005  900
1 2006 1000
2 2003  600
2 2004  900
2 2005 1200
2 2006 1300
4 2003  400
4 2004  500
4 2005  600
4 2006  700
5 2003  900
5 2004  950
5 2005 1000
5 2006 1100
end
For each id, a "big" dummy is defined to be 1 (for all the observations in this id) if the population (pop) is larger than 500 in the year 2016, 0 otherwise. Similarly, a "medium" dummy is defined if 200 < pop < 500, and a "small" dummy is defined as pop < 200. Any suggestions? Thanks.

Hausman Test

$
0
0
Hello,
This is my first post so forgive me if I explain anything wrong.
I am currently running a panel data and want to know whether to use Fixed Effects regression or a Random Effects regression, in order to do so I believe the Hausman test is the best possible way of doing this. From what I understand if the value of Prob>chi2 is above 0.05 then Random Effects should be used. However I get a value of 0.9375 which seems incredibly high, is there any explanation for this or am I doing something wrong?
Here is the code:

** Fixed Effects**
xtreg gincdif1 Immigrationfromforeigncountri RegionalDebtGDP1 UnemploymentRate lnRGDP, fe
estimates store fixed
** Now we run a Random Effects**
xtreg gincdif1 Immigrationfromforeigncountri RegionalDebtGDP1 UnemploymentRate lnRGDP, re
estimates store random

hausman fixed random

Many thanks,
Pepito

egen newvar = group(oldvar), label

$
0
0
Hi.

I want to assign values to string data. Therefore I tried to convert the string var into a numeric one containing data like
Code:
fre new_numeric_var
1 "theatre one"
2 "central theatre"
3 "museum downtown"
4 "whatever"
...
So, each text entered by the intereviewer for a respondent should be assigned a number - identical chars the same number (observations with 100% identical string answers the same number).
I tried this submitting
Code:
egen t1m19v09_1_e0 = group(t1m19v09_1), label
Stata prompts "too few quotes",
So, according to Nick's recommendations in the thread
https://www.stata.com/statalist/arch.../msg00712.html
I checked varlabel ("Musik: Sonstiges (offen)") and
Code:
update query
- but "all files are up to date".

What options are left to be checked?

Combining CMP and Finite Mixture Models (FMM)

$
0
0
Dear all,

I estimate a recursive system of equations using cmp command and like to adress unbserved heterogeneity within my model. Is it possible to solve this problem within the cmp command or combine the cmp with the fmm command?

Thank you!

Recentered Influence Functions (RIF) in Stata: RIF-Regression and RIF-Decomposition

$
0
0
Dear all,
Thanks to Prof Baum, a new update to the "oaxaca_rif" command is now available. This new update adds more extensions to the RIFVAR command. Now, it includes most of the Recentered Influence functions described in:
Chung, Choe, and Philippe Van Kerm. 2018. "Foreign Workers and the Wage Distribution: What Does the Influence Function Reveal." Econometrics no. 6 (2):28.
Cowell, Frank A., and Emmanuel Flachaire. 2007. "Income Distribution and Inequality Measurement: The Problem of Extreme Values." Journal of Econometrics no. 141 (2):1044-1072.
Essama-Nssah, Boniface, and Peter J. Lambert. 2012. "Influence Functions for Policy Impact Analysis." In Inequality, Mobility and Segregation: Essays in Honor of Jacques Silber, edited by John A. Bishop and Rafael Salas, 135-159. Howard House, Wagon Labe, Bigley BD16 1WA, UK: Emerald Group Publishing Limited.
Firpo, Sergio P., Nicole M. Fortin, and Thomas Lemieux. 2018. "Decomposing Wage Distributions Using Recentered Influence Function Regressions." Econometrics no. 6 (3):41.
Heckley, Gawain, Ulf- G. Gerdtham, and Gustav Kjellsson. 2016. "A General Method for Decomposing the Causes of Socioeconomic Inequality in Health." Journal of Health Economics no. 48:89-106. doi: https://doi.org/10.1016/j.jhealeco.2016.03.006.

In addition to this, the new update also includes the command -rifhdreg-. This command does everything that the -rifreg- and -xtrifreg- commands do, for all the statistics that can be obtained through rifvar.

Best Regards
Fernando

Interpreting my results with variables for Age Categories

$
0
0
I am running the following fixed effects regression

xtreg recycling loginc logpopden age1120 age2130 age3140 age4150 age5160 age6170 age7180 age81plus md11 md12 md13 md14 md15 md16 md17 md18 md19 md20 md21 md22 md23 md24 md25 md26 md27 md28 md29 md291 wasteavg dryavg quarter2 quarter3 quarter4 year2 year3 year4 year5, fe vce(cluster acode)

Where age1120...age81 plus are the percentages of people in each a local authority that fall into that age category (0-10 is dropped to avoid multicollinearity). I am trying to understand whether for example having more young people increases the recycling rate (which is also in percentages). How can I interpret the coefficients on age categories?

Is it correct that a 1% increase in the percentage of people aged 11-20 in that local authority it associated with
-0.296% decrease in the recycling rate compared with the age 0-10 category?

My results look like this:

Fixed-effects (within) regression Number of obs = 5,862
Group variable: acode Number of groups = 311

R-sq: Obs per group:
within = 0.3716 min = 4
between = 0.1048 avg = 18.8
overall = 0.1549 max = 20

F(39,310) = 43.00
corr(u_i, Xb) = -0.5252 Prob > F = 0.0000

(Std. Err. adjusted for 311 clusters in acode)
------------------------------------------------------------------------------
| Robust
recycling | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
loginc | 12.03771 6.237323 1.93 0.055 -.2351345 24.31055
logpopden | -1.332437 2.427655 -0.55 0.583 -6.109203 3.444329
age1120 | -.2954794 .6908926 -0.43 0.669 -1.654911 1.063953
age2130 | .1885658 .6400376 0.29 0.768 -1.070802 1.447933
age3140 | .7329204 .9751467 0.75 0.453 -1.185823 2.651664
age4150 | -.3526127 1.066931 -0.33 0.741 -2.451955 1.74673
age5160 | 1.275646 .9134214 1.40 0.164 -.5216435 3.072936
age6170 | .024184 .9108853 0.03 0.979 -1.768116 1.816484
age7180 | 1.218289 .8260266 1.47 0.141 -.4070386 2.843617
age81plus | -.3917339 1.448403 -0.27 0.787 -3.241678 2.45821
md11 | .4255393 .4895818 0.87 0.385 -.5377843 1.388863
md12 | -.5535315 .4137792 -1.34 0.182 -1.367703 .2606396
md13 | -.9062759 .5197156 -1.74 0.082 -1.928892 .1163405
md14 | -.1184019 .4622045 -0.26 0.798 -1.027857 .7910528
md15 | .5687996 .58112 0.98 0.328 -.5746388 1.712238
md16 | .0920765 .7555284 0.12 0.903 -1.394536 1.578689
md17 | -.2591195 .3896524 -0.67 0.507 -1.025818 .5075785
md18 | -.051231 .5992336 -0.09 0.932 -1.230311 1.127848
md19 | -.0115919 .4511141 -0.03 0.980 -.8992246 .8760409
md20 | -1.560113 .4897158 -3.19 0.002 -2.5237 -.5965258
md21 | -1.002337 .5052073 -1.98 0.048 -1.996406 -.0082675
md22 | -1.213785 .5130708 -2.37 0.019 -2.223327 -.2042435
md23 | .1537965 .5411894 0.28 0.776 -.9110726 1.218666
md24 | .392942 .4239478 0.93 0.355 -.4412372 1.227121
md25 | .1252963 .871987 0.14 0.886 -1.590465 1.841058
md26 | .5656828 .3854658 1.47 0.143 -.1927775 1.324143
md27 | 1.367237 .367305 3.72 0.000 .6445112 2.089964
md28 | .3488904 .3075395 1.13 0.257 -.2562384 .9540191
md29 | -.0347408 .680321 -0.05 0.959 -1.373372 1.30389
md291 | .3742537 .3683196 1.02 0.310 -.3504689 1.098976
wasteavg | 1.467284 .5581088 2.63 0.009 .3691235 2.565444
dryavg | -.6221646 .6502192 -0.96 0.339 -1.901566 .6572366
quarter2 | -4.480375 .1217009 -36.81 0.000 -4.71984 -4.240911
quarter3 | -4.181014 .1181899 -35.38 0.000 -4.41357 -3.948458
quarter4 | -2.514117 .1012822 -24.82 0.000 -2.713405 -2.31483
year2 | -.3664256 .2981572 -1.23 0.220 -.9530934 .2202422
year3 | -1.513213 .5369766 -2.82 0.005 -2.569793 -.4566336
year4 | -3.069163 .9697009 -3.17 0.002 -4.977191 -1.161135
year5 | -4.18252 1.169431 -3.58 0.000 -6.483547 -1.881493
_cons | -114.9097 80.65038 -1.42 0.155 -273.6011 43.78166
-------------+----------------------------------------------------------------
sigma_u | 4.7016969
sigma_e | 2.5497095
rho | .77274705 (fraction of variance due to u_i)
------------------------------------------------------------------------------

.

Graph axes with same range?

$
0
0
I'm a new user in Stata and want both of the axes in a scatter plot to span the same range without needing to specify the ranges for each variable.

For example: Treatment before (values range from 0 to 100) and after (values range from 0 to 80). I need both axes to display the range from 0 to 100 without needing to type "ylabel (0 100) xlabel (0 100)". Is there a general command for that (something like "ylabel xlabel (same)")?

One specific year cannot be merged even though merging variables have the same values in master and using data

$
0
0
Hi everyone,

I am working with two panel datasets with which I am trying to perform a 1:1 merge. Ultimatly, I want to add the variable fiscal year to my master dataset. My merging variables are FIRM_ID, DATE, and PERSON_ID. Hence, my code looks like

Code:
merge 1:1 firm_id date person_id using "...\file.dta", keep(master match) nogenerate
There are no duplicates for the combination of the three merging variables in neither of the two datasets.

The merging process itself works well. However, one out of eight years does not merge properly. Taking a look at the population of the variable in the master and the using dataset might help to explain the problem:

This is how fiscal year is populated in the using dataset

Array

And this is how it is populated in the master dataset after the merge

Array

Apparantly, the merging works quiet well except for the fiscal year 2009.

Of course, I have already compared the observations which did not match. However, the observations occur in both datasets and 2009 should be as populated as all the other years in the data after the merge. Furthermore, each of the three merging variables have the same format in both datasets. I really do not understand why Stata does not properly merge this one year, whereas all the others work quite well.

Has anyone ever experienced anything similar? Do you have any ideas how to solve the problem?

I would really appreciate your answers.

Best regards,
Sebastian

generate new variable using egen with sum/count

$
0
0
Hello everyone, hope you all have a good day ahead.

So i want to ask 1 question.. i have a data set which consist of ID, Year, Dummy_rich.

Year ID rich
2005 1101 0
2006 1101 0
2007 1101 1
2008 1101 0
2009 1101 0
2010 1101 1
2011 1101 1
2012 1101 0
2013 1101 1
2005 1102 0
2006 1102 0
2007 1102 0
2008 1102 0
2009 1102 1
2010 1102 1
2011 1102 0
2012 1102 1
2013 1102 2
2005 1103 1
2006 1103 0
2007 1103 1
2008 1103 1
2009 1103 0
2010 1103 3
2011 1103 1

Then i want to create one other variable which formed by the calculation of sum dummy_rich, but in different way. i don't know what is the name of this form. here it is

Year ID rich sum_rich
2005 1101 0 0
2006 1101 0 0
2007 1101 1 1
2008 1101 0 1
2009 1101 0 1
2010 1101 1 2
2011 1101 1 3
2012 1101 0 3
2013 1101 1 4
2005 1102 0 0
2006 1102 0 0
2007 1102 0 0
2008 1102 0 0
2009 1102 1 1
2010 1102 1 2
2011 1102 0 2
2012 1102 1 3
2013 1102 2 5
2005 1103 1 1
2006 1103 0 1
2007 1103 1 2
2008 1103 1 3
2009 1103 0 3
2010 1103 3 6
2011 1103 1 7

Do you guys could help me to find out what is the name of this form and the syntax which i could use in stata? Thank you so much.

ohya Fyi, i already tried several syntax such as egen count, egen sum, egen total, gen _n and so on..

Interaction terms to check if variables are interdependent?

$
0
0
I have the potentially endogenous variables Loan size and the loan rate. Loan rate is my dependent variable and loan size is an Independent variable. I implemented an interaction of loan size with my test variables to see if my test variables are affected by loan size. Can this Count as an indirect check for endogeneity? As I could not find suitbale Instruments to conduct an instrumental variable Approach and dropping loan size turned my test variables insignificant, I want to check if endogeneity is a substantial problem in my model.
input float Loanspread_pct int Age long Totalassets byte Numberofemployees float Corporationdummy long Grossprofit float(Profitability_pct Leverage_pct) long Loansize byte Maturity double(GDPGrowth Duration) byte Housebank str6 Loantype float Banks
5.45 8 1500 28 1 1600 6.25 95 475 10 .015 0 0 "Credit" 7
1.25 8 1500 28 1 1600 6.25 95 475 10 .015 0 0 "Credit" 1
2.52 6 500 15 1 800 8.75 50 150 10 .015 5.75 1 "Credit" 8
9.14 6 500 15 1 800 8.75 50 30 1 .015 5.75 1 "LC" 8
9.07 6 500 15 1 800 8.75 50 20 1 .015 6 1 "LC" 8
8.72 23 387 10 0 815 3.435583 72 80 1 .022 10 1 "LC" 8
8.67 24 415 10 0 830 5.060241 77 80 1 .022 11 1 "LC" 8
8.55 25 400 10 0 850 3.529412 90 120 1 .015 12 1 "LC" 8
5.02 24 415 10 0 830 5.060241 77 60 6 .022 1 0 "Credit" 7
9.42 15 800 25 1 3500 3.4285715 20 100 1 .015 4.666666666666667 0 "LC" 3
4.07 15 800 25 1 3500 3.4285715 20 620 20 .015 0 0 "Credit" 6
9.31 15 800 25 1 3500 3.4285715 20 230 3 .015 5 0 "LC" 5
1.76 7 130 8 0 300 23.333334 40 50 10 .015 4.75 1 "Credit" 1
.71 1 60 3 0 190 0 0 20 10 .005 0 1 "Credit" 1
9.16 7 130 8 0 300 23.333334 40 15 3 .022 3 0 "LC" 3
3.26 20 450 12 1 800 8.125 26 50 10 .015 10.083333333333334 0 "Credit" 8
4.33 18 462 12 1 830 8.192771 32 125 5 .022 8 0 "Credit" 8
5.17 19 438 12 1 755 7.549669 30 100 5 .022 0 0 "Credit" 4
8.15 20 450 12 1 800 8.125 26 15 1 .015 10 0 "LC" 8
8.26 19 438 12 1 755 7.549669 30 15 1 .022 9 0 "LC" 8
8 18 462 12 1 830 8.192771 32 15 1 .022 8 0 "LC" 8
8.84 19 438 12 1 755 7.549669 30 120 1 .022 10 0 "LC" 5
8.97 18 462 12 1 830 8.192771 32 120 1 .022 9 0 "LC" 5
8.67 20 450 12 1 800 8.125 26 10 1 .015 10.583333333333334 0 "LC" 5
3.9 15 320 10 1 1000 8 55 70 6 .015 7 0 "Credit" 5
4.09 15 320 10 1 1000 8 55 100 5 .015 5.166666666666667 0 "Credit" 4
3.33 10 277 12 1 800 9.375 60 150 4 .015 5.083333333333333 1 "Credit" 5
2.79 18 720 25 1 1800 11.38889 45 350 3 .022 12 1 "Credit" 5
2.45 20 695 25 1 2000 10.5 45 300 6 .015 14 1 "Credit" 5
4.55 3 248 3 1 500 11 44 30 4 .017 0 0 "Credit" 3
4.91 4 250 3 1 600 8.333333 50 50 5 .022 1.33 0 "Credit" 4
10.05 3 248 3 1 500 11 44 8 1 .017 0 0 "LC" 7
10.02 4 250 3 1 600 8.333333 50 8 1 .022 1 0 "LC" 7
10.03 4 250 3 1 600 8.333333 50 10 3 .022 1.083 0 "LC" 9
9.84 2 462 25 1 1750 2.2857144 45 100 1 .022 0 0 "LC" 9
9.43 3 450 29 1 1900 2.710526 50 200 3 .022 .5833333333333334 0 "LC" 9
9.62 3 450 29 1 1900 2.710526 50 100 1 .022 1 0 "LC" 9
5.26 2 462 25 1 1750 2.2857144 45 250 5 .022 0 0 "Credit" 4
5.12 4 440 29 1 2000 2.5 50 200 5 .015 1.4166666666666667 0 "Credit" 4
8.16 7 360 9 1 415 18.795181 25 15 1 .017 5 1 "LC" 7
8.11 8 350 9 1 435 18.62069 25 25 1 .022 6 1 "LC" 7
8.04 9 345 9 1 430 18.60465 30 15 1 .022 7 1 "LC" 7
2.58 45 1000 14 0 1450 7.931035 60 350 7 .005 15 1 "Credit" 7
2.27 50 1050 15 0 1500 6.666667 70 300 10 .015 20 1 "Credit" 7
8.23 45 1000 14 0 1450 7.931035 60 150 1 .005 15 1 "LC" 7
8.07 46 970 15 0 1400 6.785714 70 150 1 .022 16.5 1 "LC" 7
8.05 47 960 15 0 1475 6.779661 70 150 1 .017 17.75 1 "LC" 7
8.78 7 350 3 0 400 12.5 50 20 1 .015 7 1 "LC" 6
3.39 7 350 3 0 400 12.5 50 15 5 .015 7 1 "Credit" 6
2.9 25 500 25 1 1100 18.181818 80 150 10 .015 15 1 "Credit" 5
2.6 25 500 25 1 1100 18.181818 80 400 15 .015 15 1 "Credit" 5
8.52 25 500 25 1 1100 18.181818 80 50 1 .015 15 1 "LC" 5
2.1 40 620 25 0 2000 15 20 150 10 .015 20 1 "Credit" 5
8.12 40 620 25 0 2000 15 20 50 1 .015 20 1 "LC" 5
2.57 35 380 12 1 1500 6.666667 30 25 5 .015 15 1 "Credit" 5
3.12 4 400 7 0 950 13.68421 25 300 5 .017 3 1 "Credit" 7
2.54 7 425 9 0 1000 12.3 20 250 7 .015 6 1 "Credit" 7
8.76 4 400 7 0 950 13.68421 25 50 1 .017 3 1 "LC" 7
8.82 5 415 8 0 975 14.358974 20 80 1 .022 4.333333333333333 1 "LC" 7
8.87 6 410 9 0 935 13.368984 20 80 1 .022 5.333333333333333 1 "LC" 7
8.66 7 425 9 0 1000 12.3 20 80 1 .015 6 1 "LC" 7
2.85 102 370 6 0 427 14.285714 42 80 5 .022 23 1 "Credit" 5
9.24 102 370 6 0 427 14.285714 42 30 1 .022 8 0 "LC" 6
9.17 103 375 6 0 430 13.953488 45 45 1 .022 8.75 0 "LC" 6
1.6 102 370 6 0 427 14.285714 42 80 5 .022 0 0 "Credit" 2
1.91 17 3500 28 1 2875 5.495652 38 500 10 .005 14 1 "Credit" 5
3.76 22 3625 30 1 3000 5 40 400 7 .022 4 0 "Credit" 3
9.36 22 3625 30 1 3000 5 40 60 2 .022 5 0 "LC" 4
9.68 22 3625 30 1 3000 5 40 50 2 .022 .16666666666666666 0 "LC" 4
4.61 18 3100 15 1 2600 6.538462 50 150 3 .018 5 0 "Credit" 3
4.65 18 3100 15 1 2600 6.538462 50 130 4 .018 4 0 "Credit" 4
9.4 18 3100 15 1 2600 6.538462 50 50 2 .018 4 0 "LC" 4
2.09 26 2650 35 1 2300 9 21 300 5 .022 22 1 "Credit" 7
2.15 27 2710 35 1 2425 9.278351 28 250 7 .017 23 1 "Credit" 7
1.98 29 2665 33 1 2400 8.75 25 50 9 .022 25.25 1 "Credit" 7
1.75 30 2700 33 1 2350 8.297873 25 80 10 .015 26.333333333333332 1 "Credit" 7
7.8 27 2710 34 1 2425 9.278351 28 80 1 .017 23.166666666666668 1 "LC" 7
2.74 17 1980 26 1 1650 8.939394 26 325 10 .022 16 1 "Credit" 7
2.7 19 2050 26 1 1700 8.941176 31 150 8 .022 18.333333333333332 1 "Credit" 7
2.55 20 1930 26 1 1750 8.857142 33 220 5 .015 19.166666666666668 1 "Credit" 7
8.15 19 2050 26 1 1700 8.941176 31 80 1 .022 18.166666666666668 1 "LC" 7
end
[/CODE]
Code:
xtset Banks
Code:
xtreg Loanspread_pct Age Totalassets Numberofemployees Corporationdummy Grossprofit Profitability_pct Leverage_pct Loansize Maturity GDPGrowth_pct Duration Housebank c.Loansize#c.Duration c.Loansize#i.Housebank if Loantype=="LC", fe vce (cluster Banks)

Robust
Loanspread~t Coef. Std. Err. t P>t [95% Conf. Interval]

Age .0070297 .0067637 1.04 0.339 -.0095205 .0235798
Totalassets .0008028 .0000978 8.21 0.000 .0005636 .001042
Numberofem~s -.0151647 .0204591 -0.74 0.487 -.0652264 .034897
Corporatio~y -.4132243 .2830996 -1.46 0.195 -1.105944 .2794954
Grossprofit .0001536 .0002272 0.68 0.524 -.0004024 .0007096
Profitabil~t -.0353282 .0320068 -1.10 0.312 -.113646 .0429896
Leverage_pct .0144695 .0036746 3.94 0.008 .005478 .0234609
Loansize -.0046372 .0026792 -1.73 0.134 -.011193 .0019186
Maturity .00222 .1535463 0.01 0.989 -.3734942 .3779341
GDPGrowth_~t -.0282088 .1915538 -0.15 0.888 -.496924 .4405065
Duration -.141632 .0406531 -3.48 0.013 -.2411066 -.0421574
Housebank .0503532 .5911262 0.09 0.935 -1.396081 1.496787

c.Loansize#
c.Duration .0000725 .0004771 0.15 0.884 -.0010949 .00124

Housebank#
c.Loansize
1 -.0034348 .0105666 -0.33 0.756 -.0292903 .0224207

_cons 9.61221 .5827605 16.49 0.000 8.186247 11.03817

sigma_u 1.0533132
sigma_e .28206771
rho .93308652 (fraction of variance due to u_i)

Also in respect of the Interpretation of the interaction coefficient, does the positive coefficient of Duration#Loansize mean that the effect of Duration on Loanspread_pct is stronger by
.0000725 percentage points
when loansize increases by 1000€?

How to assign different Treatment depending on the date of birth

$
0
0
Hello,
I have two different datasets, in the first one i have a ID identifier for each person and the date of birth ( i used the command date). Then, i have a second dataset in which each observation is a different day for different air pollution variables (CO, PM10 etc). What i want to do is to assign for each ID in my first dataset the mean of the air pollution variable for the 30 days before the date of birth.
I hope someone can help me out with this one, and any type of information on how i could procede it would be very helpful.
Thanks for the time!
Sebastian

Calculating media of several variables with missing data

$
0
0
Good afternoon, I like would to calculate the media of several variables with missing data.

Code:
var1    var2    var3    var4
 40      83       9        1
 43     .02      98       22
 33.5    2       78       3
  1      99       5       .
  .       6      7        .
 56.4    .        1       8
When I generate a new variable, it do not count with the variable with missing values.

Thank you!

Gabriel Ferreira
(Stata 10.1 SE)

Compute returns based on lag variable

$
0
0
Hello,

Can you please help me with the following issue:
I want to form quantiles based on the credit rating (quantile_cr_monthly) at time (month) t.
At time t+1, I would like to compute the average returns (ret_eom) for the observations within the quantile formed at month t.

I tried the following command, but it returns a "not sorted" error:
I first define each monthly observation as:
gen mdate = ym(yr, month)

To compute the average returns, I tried:
bysort mdate quantile_cr_monthly: egen ptf_ret_cr_lead=mean(f.ret_eom)

Thank you for your help!

Difference in differences with PPML and Log-OLS reveal substantially different results

$
0
0
Dear Statalisters,
I have differences-in-differences setting where I have multiple treatments that occur at different times for different treated units. My main specification is the following one:
Y_it= β_1 Post_it + δi + γt+ u_it where Post_it is the value of treatment for application i at week t, and δi and γt are application and time fixed effect parameters that are estimated.

I use following commands to estimate the above specification:
Code:
xtpqml downloads post timefe*, fe i(app) cluster(app)
and also:
Code:
xtreg ln(downloads + 1) post timefe*, fe vce(cluster app)
However, although the number of observations are the same, results are very different: while I get a positive and significant coefficient (0.464) on the post variable in the first specification, I get a negative and significant coefficient in the second specification (-0,13)

My dependent variable has the mean of 3.53, standard deviation of 16.7. Negative binomial (NB) fits better than Poisson specification, however given that no true fixed-effect estimator has yet been proposed in the NB, I use Poisson.

Which specification I have to use?
I can also attach the part of the data if it will make it easier

GLM for grouped/ blocked population standardized binary data.

$
0
0
Sorry for imposing further but I could really use some help. Let me explain more.

I have data on incidences of poisonings in each of the 50 US states by quarter for 26 quarters. Each poisoning could result in one of
2 outcomes - no/ minor adverse medical outcome [outcome==1] or severe adverse medical outcome [outcome=2]. So the outcome is essentially binary - outcome 1 or outcome 2
. I
want to evaluate the impact of a certain government policy adopted by a subset of states [identified in the data below with variable treated==1] poisonings.
I also have, separately from the US Census, the population of each state (variable 'pop' below). My data looks as follows:

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str5 state float qtr long poisonings float(total poisonings_popstd outcome post) byte treated long pop float(x1 x2 x3 x4 x5 x6)
"AK"  1  20  27  2.769937 1 0 1  722038  7.733333 27.7  4.545096 28.878407 .52014977 .08111796
"AK"  1   7  27  .9694781 2 0 1  722038  7.733333 27.7  4.545096 28.878407 .52014977 .08111796
"AK"  2  20  29  2.769937 1 0 1  722038  7.566667 27.7  4.545096 28.878407 .52014977 .08111796
"AK"  2   9  29 1.2464718 2 0 1  722038  7.566667 27.7  4.545096 28.878407 .52014977 .08111796
"AK"  3  27  35 3.7394154 1 0 1  722038       7.5 27.7  4.545096 28.878407 .52014977 .08111796
"AK"  3   8  35 1.1079749 2 0 1  722038       7.5 27.7  4.545096 28.878407 .52014977 .08111796
"AK"  4  18  32 2.4929435 1 0 1  722038  7.466667 27.7  4.545096 28.878407 .52014977 .08111796
"AK"  4  14  32  1.938956 2 0 1  722038  7.466667 27.7  4.545096 28.878407 .52014977 .08111796
"AK"  5  11  26  1.506026 2 0 1  730399  7.333333 27.7 4.6983337  29.19467  .5209735  .0854725
"AK"  5  15  26  2.053672 1 0 1  730399  7.333333 27.7 4.6983337  29.19467  .5209735  .0854725
"AK"  6   6  29  .8214688 2 0 1  730399  7.166667 27.7 4.6983337  29.19467  .5209735  .0854725
"AK"  6  23  29  3.148964 1 0 1  730399  7.166667 27.7 4.6983337  29.19467  .5209735  .0854725
"AK"  7  13  17  1.779849 1 0 1  730399  7.033333 27.7 4.6983337  29.19467  .5209735  .0854725
"AK"  7   4  17 .54764587 2 0 1  730399  7.033333 27.7 4.6983337  29.19467  .5209735  .0854725
"AK"  8  18  23 2.4644065 1 0 1  730399         7 27.7 4.6983337  29.19467  .5209735  .0854725
"AK"  8   5  23  .6845573 2 0 1  730399         7 27.7 4.6983337  29.19467  .5209735  .0854725
"AK"  9  16  18 2.1708307 1 0 1  737045         7 27.7  4.786403   29.4967  .5228226 .08950587
"AK"  9   2  18 .27135384 2 0 1  737045         7 27.7  4.786403   29.4967  .5228226 .08950587
"AK" 10  10  19 1.3567692 2 0 1  737045         7 27.7  4.786403   29.4967  .5228226 .08950587
"AK" 10   9  19 1.2210923 1 0 1  737045         7 27.7  4.786403   29.4967  .5228226 .08950587
"AK" 11  18  24  2.442185 1 0 1  737045         7 27.7  4.786403   29.4967  .5228226 .08950587
"AK" 11   6  24  .8140616 2 0 1  737045         7 27.7  4.786403   29.4967  .5228226 .08950587
"AK" 12  18  28  2.442185 1 0 1  737045         7 27.7  4.786403   29.4967  .5228226 .08950587
"AK" 12  10  28 1.3567692 2 0 1  737045         7 27.7  4.786403   29.4967  .5228226 .08950587
"AK" 13   7  12  .9506904 1 0 1  736307         7 27.7  4.795406    29.827  .5233248 .09415574
"AK" 13   5  12  .6790646 2 0 1  736307         7 27.7  4.795406    29.827  .5233248 .09415574
"AK" 14  16  24 2.1730065 1 0 1  736307         7 27.7  4.795406    29.827  .5233248 .09415574
"AK" 14   8  24 1.0865033 2 0 1  736307         7 27.7  4.795406    29.827  .5233248 .09415574
"AK" 15  18  24 2.4446325 1 0 1  736307  6.866667 27.7  4.795406    29.827  .5233248 .09415574
"AK" 15   6  24  .8148775 2 0 1  736307  6.866667 27.7  4.795406    29.827  .5233248 .09415574
"AK" 16  16  25 2.1730065 1 0 1  736307       6.6 27.7  4.795406    29.827  .5233248 .09415574
"AK" 16   9  25 1.2223163 2 0 1  736307       6.6 27.7  4.795406    29.827  .5233248 .09415574
"AK" 17  23  29 3.1184454 1 0 1  737547       6.5 27.7  4.818702  30.10442  .5234001 .09878014
"AK" 17   6  29  .8135075 2 0 1  737547       6.5 27.7  4.818702  30.10442  .5234001 .09878014
"AK" 18  12  27  1.627015 1 0 1  737547       6.5 27.7  4.818702  30.10442  .5234001 .09878014
"AK" 18  15  27 2.0337687 2 0 1  737547       6.5 27.7  4.818702  30.10442  .5234001 .09878014
"AK" 19   6  13  .8135075 2 0 1  737547       6.5 27.7  4.818702  30.10442  .5234001 .09878014
"AK" 19   7  13   .949092 1 0 1  737547       6.5 27.7  4.818702  30.10442  .5234001 .09878014
"AK" 20   3  23 .40675375 2 0 1  737547  6.633333 27.7  4.818702  30.10442  .5234001 .09878014
"AK" 20  20  23 2.7116916 1 0 1  737547  6.633333 27.7  4.818702  30.10442  .5234001 .09878014
"AK" 21  19  31   2.56236 1 0 1  741504  6.766667 27.7  4.911483  30.41499  .5231637 .10406608
"AK" 21  12  31 1.6183325 2 0 1  741504  6.766667 27.7  4.911483  30.41499  .5231637 .10406608
"AK" 22   8  18 1.0788883 2 0 1  741504  6.866667 27.7  4.911483  30.41499  .5231637 .10406608
"AK" 22  10  18 1.3486104 1 0 1  741504  6.866667 27.7  4.911483  30.41499  .5231637 .10406608
"AK" 23   5  27  .6743052 2 0 1  741504         7 27.7  4.911483  30.41499  .5231637 .10406608
"AK" 23  22  27  2.966943 1 0 1  741504         7 27.7  4.911483  30.41499  .5231637 .10406608
"AK" 24   9  20 1.2137494 2 0 1  741504         7 27.7  4.911483  30.41499  .5231637 .10406608
"AK" 24  11  20 1.4834714 1 0 1  741504         7 27.7  4.911483  30.41499  .5231637 .10406608
"AK" 25  16  26 2.1627877 1 0 1  739786  7.033333 27.7         .         .         .         .
"AK" 25  10  26 1.3517423 2 0 1  739786  7.033333 27.7         .         .         .         .
"AK" 26  20  31 2.7034845 1 0 1  739786  7.133333 27.7         .         .         .         .
"AK" 26  11  31 1.4869165 2 0 1  739786  7.133333 27.7         .         .         .         .
"AL"  1 127 191  2.646476 1 0 0 4798834 10.166667   31 26.847376   28.9922  .4852006 .14009614
"AL"  1  64 191 1.3336573 2 0 0 4798834 10.166667   31 26.847376   28.9922  .4852006 .14009614
"AL"  2 120 183 2.5006075 1 0 0 4798834        10   31 26.847376   28.9922  .4852006 .14009614
"AL"  2  63 183  1.312819 2 0 0 4798834        10   31 26.847376   28.9922  .4852006 .14009614
"AL"  3  62 172 1.2919805 2 0 0 4798834  9.666667   31 26.847376   28.9922  .4852006 .14009614
"AL"  3 110 172 2.2922235 1 0 0 4798834  9.666667   31 26.847376   28.9922  .4852006 .14009614
"AL"  4  52 161 1.0835966 2 0 0 4798834  8.633333   31 26.847376   28.9922  .4852006 .14009614
"AL"  4 109 161 2.2713852 1 0 0 4798834  8.633333   31 26.847376   28.9922  .4852006 .14009614
"AL"  5  66 171  1.370556 2 0 0 4815564         8   31 26.951054  29.14335  .4851257 .14522338
"AL"  5 105 171   2.18043 1 0 0 4815564         8   31 26.951054  29.14335  .4851257 .14522338
"AL"  6  65 198   1.34979 2 0 0 4815564       8.2   31 26.951054  29.14335  .4851257 .14522338
"AL"  6 133 198  2.761878 1 0 0 4815564       8.2   31 26.951054  29.14335  .4851257 .14522338
"AL"  7 127 202  2.637282 1 0 0 4815564  8.066667   31 26.951054  29.14335  .4851257 .14522338
"AL"  7  75 202   1.55745 2 0 0 4815564  8.066667   31 26.951054  29.14335  .4851257 .14522338
"AL"  8 123 196  2.554218 1 0 0 4815564  7.666667   31 26.951054  29.14335  .4851257 .14522338
"AL"  8  73 196  1.515918 2 0 0 4815564  7.666667   31 26.951054  29.14335  .4851257 .14522338
"AL"  9 128 193  2.649851 1 0 0 4830460       7.4   31 27.068136 29.300863  .4850109 .14920263
"AL"  9  65 193 1.3456275 2 0 0 4830460       7.4   31 27.068136 29.300863  .4850109 .14920263
"AL" 10 104 168 2.1530042 1 0 0 4830460       7.1   31 27.068136 29.300863  .4850109 .14920263
"AL" 10  64 168 1.3249255 2 0 0 4830460       7.1   31 27.068136 29.300863  .4850109 .14920263
"AL" 11  62 169 1.2835217 2 0 0 4830460  7.133333   31 27.068136 29.300863  .4850109 .14920263
"AL" 11 107 169   2.21511 1 0 0 4830460  7.133333   31 27.068136 29.300863  .4850109 .14920263
"AL" 12  93 170 1.9252825 1 0 0 4830460  7.233333   31 27.068136 29.300863  .4850109 .14920263
"AL" 12  77 170  1.594051 2 0 0 4830460  7.233333   31 27.068136 29.300863  .4850109 .14920263
"AL" 13  87 160 1.7965997 1 0 0 4842481  7.233333   31  27.15205 29.434875  .4848089 .15354267
"AL" 13  73 160 1.5074917 2 0 0 4842481  7.233333   31  27.15205 29.434875  .4848089 .15354267
"AL" 14  76 159 1.5694435 2 0 0 4842481         7   31  27.15205 29.434875  .4848089 .15354267
"AL" 14  83 159 1.7139975 1 0 0 4842481         7   31  27.15205 29.434875  .4848089 .15354267
"AL" 15  75 178  1.548793 2 0 0 4842481       6.6   31  27.15205 29.434875  .4848089 .15354267
"AL" 15 103 178  2.127009 1 0 0 4842481       6.6   31  27.15205 29.434875  .4848089 .15354267
"AL" 16  65 145 1.3422872 2 0 0 4842481  6.233333   31  27.15205 29.434875  .4848089 .15354267
"AL" 16  80 145 1.6520457 1 0 0 4842481  6.233333   31  27.15205 29.434875  .4848089 .15354267
"AL" 17  64 116 1.3187284 1 0 0 4853160       6.1   31  27.26294  29.60861   .484659  .1574272
"AL" 17  52 116 1.0714668 2 0 0 4853160       6.1   31  27.26294  29.60861   .484659  .1574272
"AL" 18  47 131  .9684412 2 0 0 4853160  6.166667   31  27.26294  29.60861   .484659  .1574272
"AL" 18  84 131  1.730831 1 0 0 4853160  6.166667   31  27.26294  29.60861   .484659  .1574272
"AL" 19  60 138  1.236308 2 0 0 4853160       6.1   31  27.26294  29.60861   .484659  .1574272
"AL" 19  78 138 1.6072003 1 0 0 4853160       6.1   31  27.26294  29.60861   .484659  .1574272
"AL" 20  61 139  1.256913 2 0 0 4853160         6   31  27.26294  29.60861   .484659  .1574272
"AL" 20  78 139 1.6072003 1 0 0 4853160         6   31  27.26294  29.60861   .484659  .1574272
"AL" 21  50 138 1.0278031 2 0 0 4864745  5.966667   31  27.34045 29.740936  .4843596  .1613207
"AL" 21  88 138 1.8089335 1 0 0 4864745  5.966667   31  27.34045 29.740936  .4843596  .1613207
"AL" 22  67 145  1.377256 2 0 0 4864745  5.833333   31  27.34045 29.740936  .4843596  .1613207
"AL" 22  78 145 1.6033728 1 0 0 4864745  5.833333   31  27.34045 29.740936  .4843596  .1613207
"AL" 23  70 124 1.4389243 1 0 0 4864745  5.833333   31  27.34045 29.740936  .4843596  .1613207
"AL" 23  54 124 1.1100273 2 0 0 4864745  5.833333   31  27.34045 29.740936  .4843596  .1613207
"AL" 24  85 134 1.7472652 1 0 0 4864745       5.8   31  27.34045 29.740936  .4843596  .1613207
"AL" 24  49 134 1.0072471 2 0 0 4864745       5.8   31  27.34045 29.740936  .4843596  .1613207
end

My hypothesis is that the new state policies have reduced the number of poisonings resulting in minor/ no adverse medical outcome [outcome==1] and increased the rate of poisonings resulting in more severe adverse medical outcomes [outcome==2]. Since the outcome, at the individual level is essentially binary (result in outcome 1 or 2), I have been recommended a *blocked/ grouped* logit to test if the policy increased the probability of the worse outcomes and reduced the probability of the more minor adverse outcome [outcome==1]. For reasons of past literature, I included fixed effects for each state, quarter and state specific linear and quadratic time trends. I run the following:

Code:
 glm poisonings post treated  x1 x2 x3 x4 x5 x6 state_share_rural_2010 md_100000 pa_1000
> 00 rn_100000 i.qtr i.stateFIPS i.stateFIPS#(c.qtr c.qtrsq)  if outcome==2, family(binom
> ial total) link(logit) vce(cluster state)
note: 53.stateFIPS omitted because of collinearity
note: 54.stateFIPS omitted because of collinearity
note: 55.stateFIPS omitted because of collinearity
note: 55.stateFIPS#c.qtr omitted because of collinearity
note: 55.stateFIPS#c.qtrsq omitted because of collinearity

Iteration 0:   log pseudolikelihood = -3591.7962 
Iteration 1:   log pseudolikelihood = -3588.9357 
Iteration 2:   log pseudolikelihood = -3588.9354 

Generalized linear models                         No. of obs      =      1,128
Optimization     : ML                             Residual df     =      1,097
                                                  Scale parameter =          1
Deviance         =  1364.558325                   (1/df) Deviance =     1.2439
Pearson          =  1350.134022                   (1/df) Pearson  =   1.230751

Variance function: V(u) = u*(1-u/total)           [Binomial]
Link function    : g(u) = ln(u/(total-u))         [Logit]

                                                  AIC             =   6.418325
Log pseudolikelihood = -3588.935448               BIC             =  -6345.379

                                           (Std. Err. adjusted for 47 clusters in state)
----------------------------------------------------------------------------------------
                       |               Robust
            poisonings |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-----------------------+----------------------------------------------------------------
                  post |   .1280374   .0449471     2.85   0.004     .0399427    .2161321
               treated |   9.455857   18.72428     0.51   0.614    -27.24306    46.15478
                    x1 |  -.0317194    .023618    -1.34   0.179    -.0780098     .014571
                    x2 |  -.5660772   1.021753    -0.55   0.580    -2.568676    1.436522
                    x3 |   .0800275   .5061473     0.16   0.874    -.9120029    1.072058
                    x4 |  -.0137807    .307849    -0.04   0.964    -.6171536    .5895922
                    x5 |   122.5292   101.0741     1.21   0.225    -75.57246    320.6308
                    x6 |   44.02676    24.5068     1.80   0.072    -4.005688     92.0592
state_share_rural_2010 |  -10.30704   65.50204    -0.16   0.875    -138.6887    118.0746
             md_100000 |  -.0520859    .094167    -0.55   0.580    -.2366498    .1324779
             pa_100000 |   .0444265   .2285538     0.19   0.846    -.4035307    .4923837
             rn_100000 |   .0143391   .0295121     0.49   0.627    -.0435036    .0721817
                       |
                   qtr |
                    2  |  -.0681311   .0350371    -1.94   0.052    -.1368026    .0005403
                    3  |  -.0792729   .0404783    -1.96   0.050    -.1586088    .0000631
                    4  |  -.1231814   .0446144    -2.76   0.006    -.2106239   -.0357388
                    5  |  -.3408823   .1485142    -2.30   0.022    -.6319648   -.0497997
                    6  |   -.376968    .152566    -2.47   0.013    -.6759919   -.0779441
                    7  |  -.3821582   .1491666    -2.56   0.010    -.6745193   -.0897971
                    8  |  -.4553765   .1579642    -2.88   0.004    -.7649807   -.1457722
                    9  |   -.593276   .2767458    -2.14   0.032    -1.135688   -.0508643
                   10  |  -.5681158   .2796033    -2.03   0.042    -1.116128   -.0201034
                   11  |  -.6535904   .2897996    -2.26   0.024    -1.221587   -.0855936
                   12  |  -.6966991   .2820733    -2.47   0.014    -1.249553   -.1438457
                   13  |  -.9303921   .4069777    -2.29   0.022    -1.728054   -.1327305
                   14  |  -.9062193   .4147891    -2.18   0.029    -1.719191   -.0932476
                   15  |  -.9076593   .4173466    -2.17   0.030    -1.725644    -.089675
                   16  |  -.8987763   .4118481    -2.18   0.029    -1.705984   -.0915689
                   17  |  -1.132076   .5379077    -2.10   0.035    -2.186356   -.0777966
                   18  |  -1.035746    .547678    -1.89   0.059    -2.109175    .0376827
                   19  |  -1.055255   .5546635    -1.90   0.057    -2.142376    .0318653
                   20  |  -1.113239   .5579486    -2.00   0.046    -2.206798   -.0196796
                   21  |   -1.26025   .6798281    -1.85   0.064    -2.592689    .0721882
                   22  |  -1.202498   .6817646    -1.76   0.078    -2.538732    .1337362
                   23  |  -1.181239   .6835069    -1.73   0.084    -2.520888    .1584101
                   24  |  -1.187128   .7014095    -1.69   0.091    -2.561865    .1876099
                       |
             stateFIPS |
                    2  |  -8.947468   15.81543    -0.57   0.572    -39.94515    22.05021
                    4  |   -12.0106   25.66544    -0.47   0.640    -62.31393    38.29274
                    5  |  -6.085038   14.60429    -0.42   0.677    -34.70891    22.53884
                    6  |  -11.44933   26.53333    -0.43   0.666     -63.4537    40.55503
                    8  |  -3.529745   8.667129    -0.41   0.684    -20.51701    13.45752
                    9  |  -4.957952   18.50464    -0.27   0.789    -41.22638    31.31047
                   10  |  -9.679517   27.42826    -0.35   0.724    -63.43792    44.07889
                   12  |  -1.411309   12.39931    -0.11   0.909     -25.7135    22.89089
                   13  |  -8.957343   23.76524    -0.38   0.706    -55.53636    37.62167
                   15  |   2.410176   19.07879     0.13   0.899    -34.98357    39.80392
                   16  |   .5550814   5.612196     0.10   0.921    -10.44462    11.55478
                   17  |  -10.10562   27.64226    -0.37   0.715    -64.28347    44.07222
                   18  |  -7.997299   22.59134    -0.35   0.723    -52.27551    36.28091
                   19  |   1.256184   5.697489     0.22   0.825     -9.91069    12.42306
                   20  |  -2.694958   4.422801    -0.61   0.542    -11.36349    5.973572
                   21  |  -6.169956   13.26489    -0.47   0.642    -32.16867    19.82876
                   22  |  -6.391388   21.14652    -0.30   0.762     -47.8378    35.05502
                   23  |   4.271387   23.94119     0.18   0.858    -42.65247    51.19525
                   24  |  -6.223166   22.78421    -0.27   0.785    -50.87939    38.43306
                   25  |  -5.287871   21.46285    -0.25   0.805    -47.35428    36.77854
                   26  |   2.713903   4.803896     0.56   0.572     -6.70156    12.12937
                   27  |  -12.14202   22.93662    -0.53   0.597    -57.09697    32.81292
                   28  |  -.4793367     2.3538    -0.20   0.839      -5.0927    4.134027
                   29  |   1.934788   6.445643     0.30   0.764    -10.69844    14.56802
                   30  |   2.677419   18.53608     0.14   0.885    -33.65263    39.00747
                   31  |  -6.732864   10.03005    -0.67   0.502     -26.3914    12.92567
                   32  |   -9.16496   26.75222    -0.34   0.732    -61.59834    43.26842
                   33  |  -8.881691   14.92266    -0.60   0.552    -38.12956    20.36618
                   34  |  -5.947119   26.02535    -0.23   0.819    -56.95588    45.06164
                   35  |  -9.350599   18.14553    -0.52   0.606    -44.91518    26.21399
                   36  |  -4.148707   17.65852    -0.23   0.814    -38.75877    30.46136
                   37  |  -1.345194   4.815853    -0.28   0.780    -10.78409    8.093704
                   39  |  -6.138378   22.08242    -0.28   0.781    -49.41913    37.14237
                   40  |  -6.719478   15.08482    -0.45   0.656    -36.28517    22.84622
                   41  |   2.539168   3.731686     0.68   0.496    -4.774802    9.853138
                   42  |  -4.229331   16.34496    -0.26   0.796    -36.26487    27.80621
                   44  |  -6.861775   26.88413    -0.26   0.799     -59.5537    45.83015
                   45  |  -10.46153   20.59378    -0.51   0.611     -50.8246    29.90154
                   46  |  -10.28722   16.97919    -0.61   0.545    -43.56582    22.99138
                   47  |  -6.669694   18.00786    -0.37   0.711    -41.96446    28.62507
                   48  |  -10.08412   25.88989    -0.39   0.697    -60.82737    40.65912
                   49  |   -11.6419   27.24898    -0.43   0.669    -65.04893    41.76512
                   51  |  -8.827182   18.90776    -0.47   0.641    -45.88571    28.23135
                   53  |          0  (omitted)
                   54  |          0  (omitted)
                   55  |          0  (omitted)
                       |
       stateFIPS#c.qtr |
                    1  |   .0873125   .0090174     9.68   0.000     .0696387    .1049863
                    2  |   .0062401   .0516663     0.12   0.904    -.0950241    .1075043
                    4  |   .0232368   .0121039     1.92   0.055    -.0004864    .0469601
                    5  |  -.0140137   .0073818    -1.90   0.058    -.0284817    .0004543
                    6  |   .0474572   .0153308     3.10   0.002     .0174094    .0775051
                    8  |   .0428852   .0263179     1.63   0.103    -.0086969    .0944674
                    9  |   .0875877   .0138127     6.34   0.000     .0605154    .1146601
                   10  |   .0494902   .0226979     2.18   0.029     .0050031    .0939773
                   12  |  -.0365217   .0119252    -3.06   0.002    -.0598947   -.0131488
                   13  |  -.0292258   .0121902    -2.40   0.017    -.0531182   -.0053334
                   15  |  -.0103332   .0455048    -0.23   0.820    -.0995209    .0788545
                   16  |   .1305838   .0095613    13.66   0.000     .1118441    .1493235
                   17  |   .0688074   .0069859     9.85   0.000     .0551152    .0824995
                   18  |    .043609   .0060178     7.25   0.000     .0318142    .0554037
                   19  |   .0700069   .0107145     6.53   0.000     .0490069    .0910069
                   20  |   .0670102   .0134287     4.99   0.000     .0406904    .0933301
                   21  |  -.0177537   .0126121    -1.41   0.159     -.042473    .0069656
                   22  |   .1274598   .0128937     9.89   0.000     .1021886    .1527311
                   23  |   .1445257   .0190443     7.59   0.000     .1071996    .1818519
                   24  |   .0023594   .0252601     0.09   0.926    -.0471494    .0518682
                   25  |  -.0220327    .027342    -0.81   0.420    -.0756221    .0315566
                   26  |   .0698199    .008729     8.00   0.000     .0527114    .0869283
                   27  |   .0593758   .0098976     6.00   0.000     .0399768    .0787747
                   28  |   .0904343   .0075578    11.97   0.000     .0756213    .1052474
                   29  |   .0323497   .0063185     5.12   0.000     .0199657    .0447338
                   30  |   .0640228   .0149398     4.29   0.000     .0347413    .0933043
                   31  |   .1089145   .0132758     8.20   0.000     .0828945    .1349346
                   32  |   .0247509   .0193151     1.28   0.200     -.013106    .0626079
                   33  |   .0090151   .0174771     0.52   0.606    -.0252395    .0432696
                   34  |   .0532562   .0139683     3.81   0.000     .0258788    .0806335
                   35  |  -.0146453   .0179873    -0.81   0.416    -.0498997    .0206092
                   36  |  -.0012594   .0227893    -0.06   0.956    -.0459255    .0434068
                   37  |    .046556   .0144417     3.22   0.001     .0182508    .0748612
                   39  |   .0157902   .0124939     1.26   0.206    -.0086973    .0402778
                   40  |  -.0534207   .0100618    -5.31   0.000    -.0731415   -.0336999
                   41  |  -.0450526   .0146912    -3.07   0.002    -.0738469   -.0162583
                   42  |   .0743016   .0164902     4.51   0.000     .0419815    .1066217
                   44  |   .0563772   .0083841     6.72   0.000     .0399447    .0728098
                   45  |   .0279634   .0201218     1.39   0.165    -.0114745    .0674013
                   46  |   .1439447   .0710833     2.03   0.043     .0046241    .2832654
                   47  |   .0001434   .0143339     0.01   0.992    -.0279506    .0282374
                   48  |   .0460944   .0084858     5.43   0.000     .0294626    .0627262
                   49  |    .041073   .0182258     2.25   0.024      .005351     .076795
                   51  |   .0420577   .0182573     2.30   0.021     .0062741    .0778413
                   53  |   .0221912   .0212663     1.04   0.297    -.0194901    .0638724
                   54  |   .0086252   .0130878     0.66   0.510    -.0170265    .0342768
                   55  |          0  (omitted)
                       |
     stateFIPS#c.qtrsq |
                    1  |  -.0022872   .0003433    -6.66   0.000    -.0029602   -.0016143
                    2  |  -.0002177   .0014478    -0.15   0.880    -.0030554      .00262
                    4  |  -.0005262    .000264    -1.99   0.046    -.0010436   -8.80e-06
                    5  |   .0017617   .0002188     8.05   0.000     .0013329    .0021906
                    6  |   -.001821   .0002215    -8.22   0.000    -.0022551   -.0013869
                    8  |  -.0018612   .0003925    -4.74   0.000    -.0026304    -.001092
                    9  |  -.0024705    .000478    -5.17   0.000    -.0034074   -.0015336
                   10  |  -.0013925    .000395    -3.53   0.000    -.0021667   -.0006184
                   12  |   .0007492   .0004226     1.77   0.076     -.000079    .0015774
                   13  |   .0010488   .0003898     2.69   0.007     .0002848    .0018128
                   15  |   .0002051   .0008639     0.24   0.812    -.0014881    .0018982
                   16  |  -.0033215   .0002989   -11.11   0.000    -.0039074   -.0027357
                   17  |  -.0016999   .0001638   -10.38   0.000    -.0020209    -.001379
                   18  |  -.0006631   .0002067    -3.21   0.001    -.0010682   -.0002581
                   19  |  -.0012122   .0001109   -10.93   0.000    -.0014295   -.0009949
                   20  |  -.0016441    .000369    -4.46   0.000    -.0023673   -.0009209
                   21  |   .0005559   .0004014     1.39   0.166    -.0002307    .0013426
                   22  |  -.0024825   .0003398    -7.31   0.000    -.0031485   -.0018165
                   23  |  -.0048119   .0004619   -10.42   0.000    -.0057173   -.0039066
                   24  |  -.0003339   .0004897    -0.68   0.495    -.0012937    .0006259
                   25  |   .0006504   .0004045     1.61   0.108    -.0001424    .0014432
                   26  |   -.002681   .0001529   -17.54   0.000    -.0029806   -.0023814
                   27  |  -.0012435   .0002437    -5.10   0.000     -.001721   -.0007659
                   28  |  -.0027013    .000447    -6.04   0.000    -.0035775   -.0018251
                   29  |  -.0012331   .0002127    -5.80   0.000      -.00165   -.0008162
                   30  |  -.0023044   .0002618    -8.80   0.000    -.0028176   -.0017912
                   31  |  -.0026962   .0002079   -12.97   0.000    -.0031036   -.0022887
                   32  |  -.0007269   .0004593    -1.58   0.114    -.0016271    .0001734
                   33  |  -.0000602   .0003107    -0.19   0.846    -.0006691    .0005488
                   34  |  -.0017158   .0003741    -4.59   0.000    -.0024489   -.0009827
                   35  |   .0003067   .0004568     0.67   0.502    -.0005886     .001202
                   36  |  -.0001027   .0005236    -0.20   0.844    -.0011288    .0009235
                   37  |  -.0011671   .0003314    -3.52   0.000    -.0018166   -.0005176
                   39  |  -.0008741   .0003671    -2.38   0.017    -.0015936   -.0001547
                   40  |   .0007359   .0004954     1.49   0.137    -.0002351    .0017068
                   41  |   .0015358   .0006019     2.55   0.011      .000356    .0027156
                   42  |  -.0016836   .0003356    -5.02   0.000    -.0023413   -.0010259
                   44  |   -.001232   .0003575    -3.45   0.001    -.0019326   -.0005314
                   45  |   .0001419   .0004377     0.32   0.746     -.000716    .0009998
                   46  |  -.0039741   .0009312    -4.27   0.000    -.0057992    -.002149
                   47  |   .0006898   .0004325     1.59   0.111     -.000158    .0015376
                   48  |  -.0008588   .0002376    -3.61   0.000    -.0013245   -.0003931
                   49  |  -.0007886   .0004077    -1.93   0.053    -.0015876    .0000104
                   51  |   -.001024   .0004956    -2.07   0.039    -.0019953   -.0000526
                   53  |  -.0005743   .0004112    -1.40   0.163    -.0013802    .0002316
                   54  |  -.0010522   .0003709    -2.84   0.005    -.0017792   -.0003252
                   55  |          0  (omitted)
                       |
                 _cons |  -51.25055   47.68432    -1.07   0.282    -144.7101    42.20899
---------------------------------------------------------------------------------------
However, ideally I want to run this on state-population normalized data [variable poisonings_popstd]
that I got by
converting the number of poisonings to rates of poisonings per 100,000 persons. Population standardized estimates are better to compare (changes in) rates across states with otherwise very different population sizes
. How can I do that?

I could really appreciate your help with this.

Sincerely,
Sumedha.

correct to use*svy brr syntax with bootstrap weights and svy bootstrap syntax with brr weights?*

$
0
0
Dear Statalisters,

Is it correct to use the svy brr syntax with bootstrap weights and svy bootstrap syntax with brr weights? This 2006 post states that it is possible, but not whether it is correct.
https://www.stata.com/statalist/arch.../msg00734.html

This simple demonstration based on the Stata help files shows that the two methods yield identical standard errors up to 24 decimal places. But since there are separate syntax statements for the two methods, I wonder if there are instances where they would yield different results for the same data.
Code:
. use http://www.stata-press.com/data/r15/nhanes2brr

. svyset [pweight = finalwgt], brrweight(brr_1-brr_32) vce(brr)

      pweight: finalwgt
          VCE: brr
          MSE: off
    brrweight: brr_1 .. brr_32
  Single unit: missing
     Strata 1: <one>
         SU 1: <observations>
        FPC 1: <zero>

. svy, nodots: mean height

Survey: Mean estimation         Number of obs   =       10,351
                                Population size =  117,157,513
                                Replications    =           32
                                Design df       =           31

--------------------------------------------------------------
             |                 BRR
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
      height |   168.4599     .14663      168.1608    168.7589
--------------------------------------------------------------

. display %36.24f _se[height]
0.146629979913073582586946

. 
. svyset [pweight = finalwgt], bsrweight(brr_1-brr_32) vce(bootstrap)

      pweight: finalwgt
          VCE: bootstrap
          MSE: off
    bsrweight: brr_1 .. brr_32
  Single unit: missing
     Strata 1: <one>
         SU 1: <observations>
        FPC 1: <zero>

. svy, nodots: mean height

Survey: Mean estimation         Number of obs   =       10,351
                                Population size =  117,157,513
                                Replications    =           32

--------------------------------------------------------------
             |   Observed   Bootstrap         Normal-based
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
      height |   168.4599     .14663      168.1725    168.7473
--------------------------------------------------------------

. display %36.24f _se[height]
0.146629979913073582586946

. 
. **********************************************************************
. 
. use http://www.stata-press.com/data/r15/nmihs_bs, clear

. svyset [pweight = finwgt], brrweight(bsrw1-bsrw1000) vce(brr)

      pweight: finwgt
          VCE: brr
          MSE: off
    brrweight: bsrw1 .. bsrw1000
  Single unit: missing
     Strata 1: <one>
         SU 1: <observations>
        FPC 1: <zero>

. svy, nodots: mean birthwgt

Survey: Mean estimation           Number of obs   =      9,946
                                  Population size =  3,895,562
                                  Replications    =      1,000
                                  Design df       =        999

--------------------------------------------------------------
             |                 BRR
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
    birthwgt |   3355.452   6.520637      3342.657    3368.248
--------------------------------------------------------------

. display %36.24f _se[birthwgt]
6.520636700651118999871869


. svyset [pweight = finwgt], bsrweight(bsrw1-bsrw1000) vce(bootstrap)

      pweight: finwgt
          VCE: bootstrap
          MSE: off
    bsrweight: bsrw1 .. bsrw1000
  Single unit: missing
     Strata 1: <one>
         SU 1: <observations>
        FPC 1: <zero>

. svy, nodots: mean birthwgt

Survey: Mean estimation           Number of obs   =      9,946
                                  Population size =  3,895,562
                                  Replications    =      1,000

--------------------------------------------------------------
             |   Observed   Bootstrap         Normal-based
             |       Mean   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
    birthwgt |   3355.452   6.520637      3342.672    3368.233
--------------------------------------------------------------

. display %36.24f _se[birthwgt]
6.520636700651118999871869

Announcing power tworates_zhu: Stata module to calculate sample size or power for a two-sample test of rates (negative binomial regression)

$
0
0
Dear Statalisters,

I have just posted my program -power tworates_zhu- on SSC. It implements the equations in Zhu and Lakkis (2014), which is useful if, like me, you don’t have access to PASS Sample Size Software.
Code:
ssc install power_tworates_zhu
Zhu, H. and Lakkis, H. 2014. Sample Size Calculation for Comparing Two Negative Binomial Rates. Statistics in Medicine, Volume 33, Pages 376-387.
https://onlinelibrary.wiley.com/doi/....1002/sim.5947

PASS Sample Size Software, Chapter 438.
https://ncss-wpengine.netdna-ssl.com...mial_Rates.pdf

Best wishes, Mark

Name confusion: Heckman or Heckit

$
0
0
Hello everyone,
Regarding the Heckman two-step selection model for sample selection problem, Wooldridge (2010) says that the two step procedure (1st step:probit, 2nd step: OLS) for Heckman sample selection model is sometimes called Heckit. The heckman command in Stata allows for different options such as twostep, mle. If I use the heckman, can I say that I am using Heckit? If not, what is the options with heckman command for Heckit?
Thank you!
A,

Loops cannot capture words with space

$
0
0
Good day Statalists,

I have a panel data for hundreds countries in dozens years. Now I want to extract data of some countries in a certain year. I don't want to state a condition - if country="xx1" | country=="xx2"| .....- because it is too long and not easy for edit if I want to choose other countries. Thus, I decide to make a loops and I will explain as follow

Data set:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str48 country int year long var49
"ASIA"               2000          .
"ASIA"               2005          .
"ASIA"               2010          .
"ASIA"               2016          .
"Australia"          2000   19153000
"Australia"          2005   20394800
"Australia"          2010   22031750
"Australia"          2016   24210809
"Brazil"             2000  175287587
"Brazil"             2005  186917361
"Brazil"             2010  196796269
"Brazil"             2016  207652865
"Chile"              2000   15262754
"Chile"              2005   16147064
"Chile"              2010   16993354
"Chile"              2016   17909754
"China"              2000 1262645000
"China"              2005 1303720000
"China"              2010 1337705000
"China"              2016 1378665000
"France"             2000   60912500
"France"             2005   63179351
"France"             2010   65027507
"France"             2016   66859768
"Germany"            2000   82211508
"Germany"            2005   82469422
"Germany"            2010   81776930
"Germany"            2016   82348669
"Indonesia"          2000  211540429
"Indonesia"          2005  226712730
"Indonesia"          2010  242524123
"Indonesia"          2016  261115456
"Japan"              2000  126843000
"Japan"              2005  127773000
"Japan"              2010  128070000
"Japan"              2016  126994511
"Korea, Rep."        2000   47008111
"Korea, Rep."        2005   48184561
"Korea, Rep."        2010   49554112
"Korea, Rep."        2016   51245707
"Malaysia"           2000   23185608
"Malaysia"           2005   25659393
"Malaysia"           2010   28112289
"Malaysia"           2016   31187265
"Mexico"             2000  101719673
"Mexico"             2005  108472228
"Mexico"             2010  117318941
"Mexico"             2016  127540423
"Myanmar"            2000   46095462
"Myanmar"            2005   48482614
"Myanmar"            2010   50155896
"Myanmar"            2016   52885223
"Philippines"        2000   77991569
"Philippines"        2005   86274237
"Philippines"        2010   93726624
"Philippines"        2016  103320222
"Russian Federation" 2000  146596557
"Russian Federation" 2005  143518523
"Russian Federation" 2010  142849449
"Russian Federation" 2016  144342396
"Singapore"          2000    4027887
"Singapore"          2005    4265762
"Singapore"          2010    5076732
"Singapore"          2016    5607283
"Thailand"           2000   62958021
"Thailand"           2005   65425470
"Thailand"           2010   67208808
"Thailand"           2016   68863514
"United Kingdom"     2000   58892514
"United Kingdom"     2005   60401206
"United Kingdom"     2010   62766365
"United Kingdom"     2016   65595565
"United States"      2000  282162411
"United States"      2005  295516599
"United States"      2010  309338421
"United States"      2016  323405935
"Vietnam"            2000   80285562
"Vietnam"            2005   84308843
"Vietnam"            2010   88472512
"Vietnam"            2016   94569072
"WORLD"              2000          .
"WORLD"              2005          .
"WORLD"              2010          .
"WORLD"              2016          .
"Afghanistan"        1960    8996351
"Afghanistan"        1961    9166764
"Afghanistan"        1962    9345868
"Afghanistan"        1963    9533954
"Afghanistan"        1964    9731361
"Afghanistan"        1965    9938414
"Afghanistan"        1966   10152331
"Afghanistan"        1967   10372630
"Afghanistan"        1968   10604346
"Afghanistan"        1969   10854428
"Afghanistan"        1970   11126123
"Afghanistan"        1971   11417825
"Afghanistan"        1972   11721940
"Afghanistan"        1973   12027822
"Afghanistan"        1974   12321541
"Afghanistan"        1975   12590286
end
Command of loops:
Code:
local countries "Brazil" "Chile" "United Kingdom" "United States" "Russian Federation" "Philippines" "Malaysia" "Korea, Rep." "China" "Australia" "France" "Germany" "Indonesia" "Myanmar" "Thailand" "Vietnam" "Singapore"
local list ""
foreach i of local countries {
    local list `list' country=="`i'" |
    }
br var49 if year==2015 & (`list')
This command seems working well for countries have 1 word, but not for countries have space in its name such as "United Kingdom".
Do you have any suggestion how to solve it? Or do you have better idea in this case.

Thank you!
Viewing all 65051 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>