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

Falsification test for difference and difference with panel data

$
0
0
Dears,
I have a question about model specification that I wonder if people can share their thoughts about it (by the way, apologies if this is not the place to ask this question, in that case I'll appreciate if someone can suggest me a more appropriate forum). I am estimating a difference and difference analysis using a panel data of schools. The treatment is the construction of water and sanitation project in rural districts. I have data from 2012 to 2016. However the issue with my setting is that, each school could receive treatment at different time periods and they can receive treatment many times (it is possible that many water projects could be constructed in the same district). My baseline regression is this

Y,ist = alfa,t + alfa,s + alfa,i + beta*Ds,t + epsilon,ist

Where "s" denote district , "i" denota individual and "t" year. The variable Ds,t equals one if there have been finished at least one project in district "s" in year "t"

I would like to do a falsification test to show that my results are robust. However, I wonder if I can use lead values of the treatments as long as once they have received the treatment the project remains and later on they could benefit from the project. I also have get data from 2008 to 2011. Should I estimate a regression using only data from this period and using the lead of the treatment? or I should consider the whole sample data and the leads of the treatment?.
Well, any comments about this will be appreciated!
Thanks,
Diego


capturing unit and time specific coefficients

$
0
0
Hello.
I am using Stata 16. I have an unbalanced panel data set with firm (gvkey) observations over time (fiscal_quarter). I'm running the following regression

HTML Code:
reg DV x1 x2 x3 x4 c.x1#i.gvkey c.x1#i.fiscal_quarter c.x2#i.gvkey c.x2#i.fiscal_quarter c.x3#i.gvkey c.x3#i.fiscal_quarter c.x4#i.gvkey c.x4#i.fiscal_quarter, beta nocons
and would like to generate new variables (one assoicated with x1, x2, x3, x4) akin to

HTML Code:
gen x1total = _b[x1] + _b[c.x1#gvkey] + _b[c.x1#fiscal_quarter]
for x1. In other words, I would like to capture the coefficient for x1, which can be done with

HTML Code:
gen x1coeff = _b[x1]
and will be the same for each observation.

Next, I need to capture the coefficient for for the interaction of x1 with gvkey (my firm identifier), which will be the same for all observations within a firm but vary across firms, and capture the coefficient for the interaction of x1 with fiscal_quarter (my time variable), which will be the same for each time period across firms, but varies within firms.

I have searched extensively for a code on how to capture these coefficients to no prevail. I looked into using statsby, but it appears I would have to run the regression by groups (i.e., firms and then time periods), which is not what I want.

Any suggestions are greatly appreciated.
Best,
Annette

Doubt regarding interpretation of confidence intervals after margins command

$
0
0
I have a small doubt regarding the interpretation of confidence intervals in the result I obtain using the margins command.

The results obtained are the following:


. margins i.tech_intensity, dydx(i.innovator1) pr(ha)

Average marginal effects Number of obs = 93,317
Model VCE : Robust

Expression : Predicted hazard, predict(ha)
dy/dx w.r.t. : 1.innovator1

--------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
---------------+----------------------------------------------------------------
1.innovator1 |
tech_intensity |
0 | -.00877 .0038911 -2.25 0.024 -.0163964 -.0011435
1 | -.0364327 .0111145 -3.28 0.001 -.0582167 -.0146487
--------------------------------------------------------------------------------


innovator1 is 1 for innovators and 0 for non-innovators, and tech_intensity is 1 for high-tech firms and 0 for low-tech firms.

My question is: Since the confidence intervals do overlap, is it correct to state that we cannot tell if the differences in predicted hazard between between low-tech innovators and low-tech non-innovators and between high-tech innovators and high-tech non-innovators are statistically significant?



Deriving new variable by summing a variable in a rolling time window

$
0
0
Hi Everyone,

I have a dataset that looks roughly like this:


input str8 month_year studyid edvisits

"AUG_08" 1 0
"SEP_08" 1 2
"OCT_08" 1 1
"NOV_08" 1 0
"DEC_08" 1 0
"AUG_08" 2 0
"SEP_08" 2 0
"OCT_08" 2 1
"NOV_08" 2 0
"DEC_08" 2 0
"AUG_08" 3 1
"SEP_08" 3 0
"OCT_08" 3 2
"NOV_08" 3 0
"DEC_08" 3 0
"AUG_08" 4 1
"SEP_08" 4 0
"OCT_08" 4 0
"NOV_08" 4 1
"DEC_08" 4 1

What I need to do is generate a new variable called "repeat_user" that =1 if a person has 3 or more edvisits in a 3 month period and =0 if they don't.

so the "want" dataset would look like this:

input str8 month_year studyid edvisits repeat_user

'AUG_08' 1 0 1
'SEP_08' 1 2 1
'OCT_08' 1 1 1
'NOV_08' 1 0 1
'DEC_08' 1 0 1
'AUG_08' 2 0 0
'SEP_08' 2 0 0
'OCT_08' 2 1 0
'NOV_08' 2 0 0
'DEC_08' 2 0 0
'AUG_08' 3 1 1
'SEP_08' 3 0 1
'OCT_08' 3 2 1
'NOV_08' 3 0 1
'DEC_08' 3 0 1
'AUG_08' 4 1 0
'SEP_08' 4 0 0
'OCT_08' 4 0 0
'NOV_08' 4 1 0
'DEC_08' 4 1 0

For patient 1 repeat_user = 1 because they has 3 visits in 2 months
For patient 2 repeat_user = 0 because they only had 1 visit
For patient 3 repeat_user = 1 because they had 3 visits in 3 months
For patient 4 repeat_user = 0 because even though they had 3 visits, they were not within a three month period

Month_year is currently formatted as a proper date variable.

Any help would be much appreciated!

Thanks so much.

Mike







Deleting Negative Values in a Variable

$
0
0
Stata Experts:
I am working with a dataset that has several variables. Each of these variables contain lists of numerical values. I would like to delete those values that are ==-9 as that indicates data that was "not ascertained" by the interviewer. Can I do this in one step with some kind of loop or do I need to delete these values from each individual variable . I appreciate your help.
Regards,
Pat

Merging data set

$
0
0
I have two data sets both containing variables for years and household ID when I try to merge the data sets I get an error, does anyone know any possible solution?

To clarify when I try to join the datasets by the variable wave which is the common variables between the datasets I get the error " variable wave does not uniquely identify observations in the master data"

I hope this makes sense, thank you

Extracting p-values from Kruskal-Wallis test

$
0
0
Hello,

I have ~300 continuous variables and I need to perform a kruskal-wallis test examining them across a 4-level variable. I have written a loop that simultaneously runs the test for all of them, but what I really want to do is output the p-values from all of the tables in order to easily filter them. I have tried to get the scalars from Kruskal-wallis to output the p-value, but there are only 3 listed, none of which are the p-value.

Code:
local kruskal var var2 var3 var4 var5 var6 foreach var of local kruskal {
 kwallis `var', by(sptb_cst) 
}
How would I pull the p-values out of this?
Thanks!
Clare

psmatch2 taking a long time

$
0
0
I have about 200,000 cases in my dataset. About 40,000 are in the treatment group and 160k in the control group. I am predicting the participation variable (0 or 1 values) based on about 20 demographics covariates. I do a set seed and random sort order then do psmatch2 and it displays the output regression but hangs after saying the following:

There are observations with identical propensity score values.
The sort order of the data could affect your results.
Make sure that the sort order is random before calling psmatch2.


I left it on for a few days and it was still busy.

Is it normal to be taking so long wit this many cases or is something wrong with the data? If I randomly sample like 1000 or 50 from the treatment group then run psmatch2, it is able to finish quickly.





Interpreting fixed effects for a panel

$
0
0
Hi,
I am working with a panel data set which is xtset at the district year level. With district and year fixed effects, does the interpretation amount to examining variation within districts in the same year?

Thanks.

Returning Cell Position Based on Other Variable

$
0
0
Hello,
I have the following example data set.

* Example generated by -dataex-. To install: ssc install dataex
clear
input float(case_id audc11 audc12 audc13 audc14 randomnumber)
1 0 .28 .09 .07 .795571
2 .34 .28 .33 .26 .955492
3 .56 .59 .33 .81 .018467158
4 .66 .73 .7 .81 .030028736
5 1 1 1 1 .
end


The last column has the random numbers. I have to compare the random numbers row wise, with the columns audc11- audc14 value, so that Stata returns me the value in the case_id. I have to compare each row number with their respective columns.

For example, when random number is 0.795571 (1st row), I have to compare this value with those in the 1st column of audc11. If the values of the random number is the first near or equal to value to that contained in the columns, I need the corresponding case_id value to be returned.
For example, comparing 1st row of random value (0.799571), to that of those contained in 1st column, the nearest first value to 0.799571 is 0.66. Then the return value I should get is 4, because the corresponding case_id is 4.

Again,comparing 3rd row of random value (0.018467158), to that of those contained in 3rd column, the nearest first value to 0.018467158 is 0.09. Then the return value I should get is 1, because the corresponding case_id is 1.

Any help will be very helpful.

Thank you

If function with Monthly dates

$
0
0
Hi,

I have a panel data set with dates formatted as "YM" in stata. The time period is monthly from year 2003 onwards (2003m1,2003m2.....). I want to keep or extract the observations for the entire year 2007 only (starting from 2007m1 till 2007m12). When I give code as:

Keep if Time_Period==2007m1, 2007m2....

It says invalid syntax or stata does-not recognize 2007m1....

Although my Time_period is stata formatted dates(not string), but I don't know how to refer to a particular date (monhtly in my case) with if function.

Can Somebody help please?

Regards

Confidence intervals for 5 year survival after multiple imputation

$
0
0
Hi Statalist,

I would be grateful for some help predicting IPT-weighted 5-year (60 months) survival and 95% confidence intervals by treatment group (treated vs not treated) after multiple imputation. No other variables require adjustment.

I have an imputed dataset and I have created propensity score IPT weights for each individual.

I have worked through the following thread for help in predicting 5 year survival:
https://www.statalist.org/forums/for...d-mi-predictnl

I'm just not sure how to get the confidence limits??

Code:
mi stset date_death [pweight=ipt_wt], failure(death_censor==0) origin(date_diagnosis) scale(30.4)

mi estimate, dots cmdok sav(mi_stpm2, replace): stpm2 treatment, df(5) scale(hazard) eform

gen t60

mi predictnl surv1 = predict(survival at(treatment 0) timevar(t60)) using mi_stpm2, ci(surv1_lb surv1_ub) force
mi xeq: summarize surv1

mi predictnl surv2 = predict(survival at(treatment 1) timevar(t60)) using mi_stpm2, ci(surv2_lb surv2_ub) force
mi xeq: summarize surv2




Twoway scatter plot: how to modify axis length

$
0
0
Hello,

This is my first post here so if I did something wrong I apologize.

I'm working with a dataset from Comtrade, specifically with information about trade values between Italy, Belgium, Mexico, Israel, Japan and USA. I was trying to make the same graph (Graph 1) and I almost get it. The problem is that I don't know how to put together both x axis and y axis (from the origin) in order to have no space after the beginning.

I run the following code:

twoway scatter porcentaje_com porcentaje_pib, title(" ", margin(b=1)) mlabel(reporter) mlabcolor(black) mlabv(pos) graphregion(fcolor(white)) ytitle("Porcentaje del comercio" " estadounidense con la UE", orientation(horizontal) margin(0 -35 80 0) size(small)) ylab(, ang(hor) labsize(small)) xtitle("Porcentaje del PIB de la UE", margin(0 -45 0 0) size(small)) xlab(, labsize(small)) legend(off) mcolor(ebblue) msize(small) || function y=x, range(0 25) n(2) aspect(1) lcolor(black)

And I got the Graph 2

I hope you understand my question.

Thanks!

PD: the idea is basically to force the line to touch both margins.

Local list of variables as argument of program

$
0
0
I'm trying to enter a list of variables as an argument for a program. Unfortunately, I've been running into some problem.

I made the program to have a unique argument, "outcomes", and then I insert the first argument for the code as a local containing two variables, "x" and "y".

The code only produces x_post_std instead of also producing y_post_std.

I checked the program arguments section of the help file, but it had no information about inputting a local as an argument.

Code:
cap program drop test
program test

* Arguments: components and covariates
args outcomes
{

* Step 1: Standardize variables
    foreach var in `outcomes' {
    di "`var'"
            
        * Create standardized versions
        cap drop `var'_post_std
        
        sum `var'
        gen `var'_post_mean = r(mean)
        gen `var'_post_sd = r(sd)
        gen `var'_post_std = (`var' - `var'_post_mean) / `var'_post_sd
        drop `var'_post_mean `var'_post_sd
        
}    
}
end

clear
set obs 20
gen x = rnormal()
gen y = rnormal()

local variables "x y"

test `variables'

Help with gravity equation estimated using PPML (Stata 14.2)

$
0
0
Good evening, everyone!

The following is a snippet of my database( I have data of Brazil's exports and imports flow with 122 countries, from 2009 to 2014):

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input str3(ID_EXP ID_IMP) int(ID_NUM ANO) double(EXP_NRB DIST SCO_EXP SCO_IMP) byte(FRO LIN COL)
"BRA" "AGO"  1 2009  152903849 6391.615 .6991869918699187   .8211382113821139 0 1 0
"BRA" "AGO"  1 2010   60699279 6391.615 .4796747967479675   .7317073170731707 0 1 0
"BRA" "AGO"  1 2011   61883975 6391.615 .5934959349593496   .5528455284552846 0 1 0
"BRA" "AGO"  1 2012   64203369 6391.615 .3821138211382114   .5528455284552846 0 1 0
"BRA" "AGO"  1 2013   75264517 6391.615 .3821138211382114   .8373983739837398 0 1 0
"BRA" "AGO"  1 2014   85859091 6391.615 .2845528455284553   .4959349593495935 0 1 0
"BRA" "ALB"  2 2009      40668 9313.151 .6991869918699187   .8943089430894309 0 0 0
"BRA" "ALB"  2 2010      64360 9313.151 .4796747967479675    .959349593495935 0 0 0
"BRA" "ALB"  2 2011       1467 9313.151 .5934959349593496   .5447154471544715 0 0 0
"BRA" "ALB"  2 2012        451 9313.151 .3821138211382114                   1 0 0 0
"BRA" "ALB"  2 2013         54 9313.151 .3821138211382114   .3902439024390244 0 0 0
"BRA" "ALB"  2 2014       1387 9313.151 .2845528455284553   .7154471544715447 0 0 0
"BRA" "ARE"  3 2009   83546921 11809.98 .6991869918699187   .4065040650406504 0 0 0
"BRA" "ARE"  3 2010   23600914 11809.98 .4796747967479675   .3170731707317073 0 0 0
"BRA" "ARE"  3 2011   68742508 11809.98 .5934959349593496  .42276422764227645 0 0 0
"BRA" "ARE"  3 2012   45312701 11809.98 .3821138211382114  .13821138211382114 0 0 0
"BRA" "ARE"  3 2013   58465966 11809.98 .3821138211382114  .45528455284552843 0 0 0
"BRA" "ARE"  3 2014  176933670 11809.98 .2845528455284553   .5691056910569106 0 0 0
"BRA" "ARG"  4 2009 1199662929 2089.281 .6991869918699187   .5691056910569106 1 0 0
"BRA" "ARG"  4 2010 1575475673 2089.281 .4796747967479675   .8292682926829268 1 0 0
"BRA" "ARG"  4 2011 1850370799 2089.281 .5934959349593496   .6747967479674797 1 0 0
"BRA" "ARG"  4 2012 1641368735 2089.281 .3821138211382114  .35772357723577236 1 0 0
"BRA" "ARG"  4 2013 1328340316 2089.281 .3821138211382114   .3170731707317073 1 0 0
"BRA" "ARG"  4 2014 1133068766 2089.281 .2845528455284553  .17886178861788618 1 0 0
"BRA" "ARM"  5 2009         49  11214.9 .6991869918699187   .3252032520325203 0 0 0
"BRA" "ARM"  5 2010      35856  11214.9 .4796747967479675   .7398373983739838 0 0 0
"BRA" "ARM"  5 2011         24  11214.9 .5934959349593496  .12195121951219512 0 0 0
"BRA" "ARM"  5 2012       6590  11214.9 .3821138211382114   .0975609756097561 0 0 0
"BRA" "ARM"  5 2013         49  11214.9 .3821138211382114   .6016260162601627 0 0 0
"BRA" "ARM"  5 2014        244  11214.9 .2845528455284553   .3252032520325203 0 0 0
"BRA" "AUS"  6 2009   22302246 13983.36 .6991869918699187   .3008130081300813 0 0 0
"BRA" "AUS"  6 2010   20209779 13983.36 .4796747967479675   .4959349593495935 0 0 0
"BRA" "AUS"  6 2011   22328151 13983.36 .5934959349593496   .3170731707317073 0 0 0
"BRA" "AUS"  6 2012   23223800 13983.36 .3821138211382114   .6991869918699187 0 0 0
"BRA" "AUS"  6 2013   17347535 13983.36 .3821138211382114   .4878048780487805 0 0 0
"BRA" "AUS"  6 2014   30864179 13983.36 .2845528455284553   .5528455284552846 0 0 0
"BRA" "AUT"  7 2009    5313013 9395.406 .6991869918699187   .7235772357723578 0 0 0
"BRA" "AUT"  7 2010    6330983 9395.406 .4796747967479675  .35772357723577236 0 0 0
"BRA" "AUT"  7 2011    5698958 9395.406 .5934959349593496   .8455284552845529 0 0 0
"BRA" "AUT"  7 2012    1664144 9395.406 .3821138211382114   .7073170731707317 0 0 0
"BRA" "AUT"  7 2013    1395217 9395.406 .3821138211382114   .4634146341463415 0 0 0
"BRA" "AUT"  7 2014   16199355 9395.406 .2845528455284553   .8699186991869918 0 0 0
"BRA" "AZE"  8 2009      63514 11569.65 .6991869918699187   .7804878048780488 0 0 0
"BRA" "AZE"  8 2010          0 11569.65 .4796747967479675    .967479674796748 0 0 0
"BRA" "AZE"  8 2011        602 11569.65 .5934959349593496  .34959349593495936 0 0 0
"BRA" "AZE"  8 2012       2265 11569.65 .3821138211382114   .3008130081300813 0 0 0
"BRA" "AZE"  8 2013     219612 11569.65 .3821138211382114   .7804878048780488 0 0 0
"BRA" "AZE"  8 2014      51436 11569.65 .2845528455284553   .4146341463414634 0 0 0
"BRA" "BEL"  9 2009  117516351 8977.309 .6991869918699187   .3983739837398374 0 0 0
"BRA" "BEL"  9 2010  111740378 8977.309 .4796747967479675  .14634146341463414 0 0 0
"BRA" "BEL"  9 2011  188609683 8977.309 .5934959349593496   .7317073170731707 0 0 0
"BRA" "BEL"  9 2012  164059354 8977.309 .3821138211382114   .7479674796747967 0 0 0
"BRA" "BEL"  9 2013  114426142 8977.309 .3821138211382114  .15447154471544716 0 0 0
"BRA" "BEL"  9 2014  125515938 8977.309 .2845528455284553   .7560975609756098 0 0 0
"BRA" "BEN" 10 2009   16094862 5893.825 .6991869918699187   .0975609756097561 0 0 0
"BRA" "BEN" 10 2010    4151754 5893.825 .4796747967479675  .07317073170731707 0 0 0
"BRA" "BEN" 10 2011    9704038 5893.825 .5934959349593496   .0975609756097561 0 0 0
"BRA" "BEN" 10 2012    1780809 5893.825 .3821138211382114  .14634146341463414 0 0 0
"BRA" "BEN" 10 2013    4600869 5893.825 .3821138211382114   .2032520325203252 0 0 0
"BRA" "BEN" 10 2014     280249 5893.825 .2845528455284553  .13008130081300814 0 0 0
"BRA" "BGD" 11 2009    6610295 15292.22 .6991869918699187   .8617886178861789 0 0 0
"BRA" "BGD" 11 2010    3745866 15292.22 .4796747967479675   .5853658536585366 0 0 0
"BRA" "BGD" 11 2011    2797106 15292.22 .5934959349593496   .7398373983739838 0 0 0
"BRA" "BGD" 11 2012     423424 15292.22 .3821138211382114   .8780487804878049 0 0 0
"BRA" "BGD" 11 2013     887481 15292.22 .3821138211382114   .7967479674796748 0 0 0
"BRA" "BGD" 11 2014    2398781 15292.22 .2845528455284553   .7642276422764228 0 0 0
"BRA" "BGR" 12 2009     618688 9768.308 .6991869918699187  .25203252032520324 0 0 0
"BRA" "BGR" 12 2010     673776 9768.308 .4796747967479675  .25203252032520324 0 0 0
"BRA" "BGR" 12 2011     192542 9768.308 .5934959349593496  .06504065040650407 0 0 0
"BRA" "BGR" 12 2012     270882 9768.308 .3821138211382114   .5609756097560976 0 0 0
"BRA" "BGR" 12 2013     206898 9768.308 .3821138211382114   .6422764227642277 0 0 0
"BRA" "BGR" 12 2014     255623 9768.308 .2845528455284553  .08130081300813008 0 0 0
"BRA" "BHR" 13 2009     449527 11384.75 .6991869918699187  .06504065040650407 0 0 0
"BRA" "BHR" 13 2010     406267 11384.75 .4796747967479675  .21138211382113822 0 0 0
"BRA" "BHR" 13 2011     856167 11384.75 .5934959349593496  .17886178861788618 0 0 0
"BRA" "BHR" 13 2012   10449143 11384.75 .3821138211382114   .3983739837398374 0 0 0
"BRA" "BHR" 13 2013     209478 11384.75 .3821138211382114 .008130081300813009 0 0 0
"BRA" "BHR" 13 2014     194060 11384.75 .2845528455284553  .12195121951219512 0 0 0
"BRA" "BIH" 14 2009     323008 9351.396 .6991869918699187   .2032520325203252 0 0 0
"BRA" "BIH" 14 2010     559483 9351.396 .4796747967479675  .11382113821138211 0 0 0
"BRA" "BIH" 14 2011     416766 9351.396 .5934959349593496  .04065040650406504 0 0 0
"BRA" "BIH" 14 2012        929 9351.396 .3821138211382114   .5772357723577236 0 0 0
"BRA" "BIH" 14 2013      58609 9351.396 .3821138211382114   .5121951219512195 0 0 0
"BRA" "BIH" 14 2014      98829 9351.396 .2845528455284553 .008130081300813009 0 0 0
"BRA" "BLR" 15 2009     196491 10486.81 .6991869918699187  .18699186991869918 0 0 0
"BRA" "BLR" 15 2010     200535 10486.81 .4796747967479675   .5121951219512195 0 0 0
"BRA" "BLR" 15 2011     341227 10486.81 .5934959349593496  .10569105691056911 0 0 0
"BRA" "BLR" 15 2012     477479 10486.81 .3821138211382114  .04065040650406504 0 0 0
"BRA" "BLR" 15 2013     391021 10486.81 .3821138211382114   .6504065040650406 0 0 0
"BRA" "BLR" 15 2014     171054 10486.81 .2845528455284553  .14634146341463414 0 0 0
"BRA" "BOL" 16 2009  212279880 2266.878 .6991869918699187   .4959349593495935 1 0 0
"BRA" "BOL" 16 2010  275644036 2266.878 .4796747967479675   .2032520325203252 1 0 0
"BRA" "BOL" 16 2011  318939530 2266.878 .5934959349593496   .2926829268292683 1 0 0
"BRA" "BOL" 16 2012  319023235 2266.878 .3821138211382114  .06504065040650407 1 0 0
"BRA" "BOL" 16 2013  347332761 2266.878 .3821138211382114   .6747967479674797 1 0 0
"BRA" "BOL" 16 2014  359426904 2266.878 .2845528455284553  .21138211382113822 1 0 0
"BRA" "BRN" 17 2009      51951 17221.85 .6991869918699187   .6341463414634146 0 0 0
"BRA" "BRN" 17 2010      39346 17221.85 .4796747967479675   .3902439024390244 0 0 0
"BRA" "BRN" 17 2011      49940 17221.85 .5934959349593496  .16260162601626016 0 0 0
"BRA" "BRN" 17 2012       1876 17221.85 .3821138211382114   .5853658536585366 0 0 0
end
format %ty ANO
where:

ID_EXP: ISO code for exporter
ID_IMP: ISO code for importer
ID_NUM: numerical id for ID_IMP
EXP_NRB: the value of non-resource based exports
DIST: the distance between ID_EXP and ID_IMP
SCO_EXP, SCO_IMP: score of the strictness of environmental regulation for ID_EXP and ID_IMP respectively
FRO, LIN, COL: equal to 1 if ID_EXP has a border with ID_IMP, speak the same language and have colonial ties respectively, 0 otherwise

The commands I am running are the following:

Code:
tsset ID_NUM ANO, yearly
qui tab ID_NUM, gen(fe_ID_NUM)
ppml EXP_NRB DIST SCO_EXP SCO_IMP FRO LIN COL fe_ID_NUM*, cluster(DIST)
The result of my regression is (I've omitted the dummies for clarity):

Code:
Exports “NRB” 
(1)
.
DIST -0.00***
(0.00)
SCO_EXP -0.59
(0.38)
SCO_IMP 0.52**
(0.24)
FRO -0.13**
(0.06)
LIN -0.39***
(0.03)
Constant 20.33***
(0.10)
Observations 714
R2 0.894
Standard errors in parentheses * p < 0.10, ** p < 0.05, *** p < 0.01
I have a couple of questions:

1) Is the way I estimated my model correct? Because I have a 1xN model, I only estimated the importer fixed effects. Also, I clustered my errors based on the distance (should I use ln(distance)?). Is this correct?
2) Regarding the creation of ID_NUM, I simply assigned a sequence {1,2,3,...,n} of values to the column of importers, in such a way that AGO = 1, ALB = 2, etc. Is this correct?
3) Assuming the approach is correct, why would FRO and LIN be negative? In theory, countries that share a common border and/or language should trade more with each other, not less.

I appreciate immensely any help.

Kind regards,
Pedro

*ppml is a third-party command. You can install it using the following command:
Code:
 ssc install ppml

Analyzing two time points

$
0
0
I am analyzing data with the mental health component score (measured 0-100) for 4500 individuals. This score was measured at baseline and then 30 days following an intervention. Is there any way to identify the number of individuals whose score decreased, increased, or had no change?

Error in Asdoc tables by two groups

$
0
0
I want to make a summary table by two groups.

Code:
asdoc sum ln_assets ln_sales r_change p_change cash profit leverage if year>2012, stat(mean N) by(rec_inc_dum demon_dummy)
I get the following error

number of variables in varlist must equal number of variables in generate(newvarlist)
The varlist however does have equal number of variables in both the groups. Does asdoc allow summary by two groups?

R 503 Conformability Issue | Help Please!!!

$
0
0
Hi, I am trying to estimate marginal effects after running a logistic model. The logistic model is fine but the post-estimation is giving me quite the headache. I am getting an error message saying that there is a conformability error. (I believe that means that there is a mismatch of the unit between my continuous income variable and the binary variable of trust.) I got this when running the following:

logit mammogramadherent i.race_r i.age i.education2 i.employment c.income i.family i.married i.citizenship i.obesity i.insurance i.
> provider i.safety i.trust i.placeofresidence i.produce i.racerxsafety i.racerxtrust i.racerxproduce


.
. mgen, at( income=(.5(5)60) trust=0) atmean stub(Some Trust) ///
> predlabel( Some Trust)
conformability error
r(503);

So, trying to troubleshot and fix the conformability error, I recoded the income continuous variable to a binary variable, e.g. income2.

I then received the following error message:


. estimates restore blm
(results blm are active now)

.
. mgen, at( income2=(.5(5)60) trust=0) atmean stub(Some Trust) ///
> predlabel( Some Trust)
at values for factor income2 do not sum to 1


Can someone please help me fix this conformability issue?

Loop - Forvalues - works in different order

$
0
0
Hi Forum,

I have tried this loop (see below) ten thousand times and something really strange happens. The loop is bigger than shown, but I think it is sufficient to formulate my question.
After the number 2., I have a esttab where I can see my regression results where the two scalars marked in bold are shown. However, my problem is that only one scalar appears in my excel sheet, and the other in blank, and it is always the first one in order. So, when I change the order of the two scalars (e.g. I put number 2. first and then 1.), I get the first scalar result on my regression sheet and the other in blank. I have no idea why this happens, but it would be great if someone has any suggestions for this problem.


local i = 0
forval i = 1/${_`sgm'_ct}{

forval j = 1/$controls_ct {
forval t = 1/$r {

*1. Compute lower bound
cap gen x_`i'_`j'_`t' = (((invttail(e(df_r),0.05)* _se[flag] * flag)*NumberOfProducts_`i'_`j'_`t')/TotalSales_`i'_`j'_`t')*100
su x_`i'_`j'_`t' if e(sample) & flag_ == 1
estadd scalar x = r(mean)

*2. Compute and test
cap gen y_`i'_`j'_`t' = (((flag_ * _b[flag])*NumberOfProducts_`i'_`j'_`t')/TotalSales_`i'_`j'_`t')*100
su y_`i'_`j'_`t' if e(sample) & flag_== 1
estadd scalar y = r(mean)

}
}
}

Many thanks in advance!
Best regards,


Lena

how to calculate age count..

$
0
0
I am trying to calculate age count.. please let me know if the below command is correct..

bys ScheduleNo: egen Age_0_14 = count(B2Q1) if Age<=14
bys ScheduleNo: egen count_Age_0_14= max(Age_0_14)
bys ScheduleNo: egen Age_15_24 = count(B2Q1) if Age>=15 & Age<=24
bys ScheduleNo: egen count_Age_15_24= max(Age_15_24)
bys ScheduleNo: egen Age_25_34 = count(B2Q1) if Age>=25 & Age<=34
bys ScheduleNo: egen count_Age_25_34= max(Age_25_34)
bys ScheduleNo: egen Age_35_44 = count((B2Q1)) if Age>=35 & Age<=44
bys ScheduleNo: egen count_Age_35_44= max(Age_35_44)
bys ScheduleNo: egen Age_45_59 = count(B2Q1) if Age>=45& Age<=59
bys ScheduleNo: egen count_Age_45_59= max(Age_45_59)
bys ScheduleNo: egen Age_60_120 = count(B2Q1) if Age>=60& Age<=120
bys ScheduleNo: egen count_Age_60_120= max(Age_60_120)
recode count_* (.= 0)
Viewing all 72820 articles
Browse latest View live


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