Dear statalist
I have a problem using margins on stata command.
I'm doing some research related to the effect of election on corporate investment.
I generated control variables called victory (which is defined as the numbers of vote that the winner got from the election. code: gen victory= max(voteparty1, voteparty2)) and difofvote (vote difference between the winner and the runner-up. For exmaple, if voteparty1> voteparty2, then the difofvote would be voteparty1-voteparty2)
Then I got two variables, 1. difofvote 2. victory.
I want to use the vote difference (difofvote ) between two major political parties to see if it is below the 25th percentile of victory margin distribution. But I'm not pretty sure what is margin distribution. I got this idea from previous studies.
Then I want to generate a dummy variable "Close" sets to one if difovote is below the 25th percentile of victory margin distribution (victorymargin). I'm new to use margins, so I'm not sure.
I found that I needed to conduct a regression before I could use the "margins" code, so I done a simple regression as follow:
reg difofvote victory, allbaselevels
After that, I wrote a code as follow:
margins, dydx(victory) at((p25) victory)
After I ran it on Stata, I found that I'm still not sure how to use this to create "Close" dummy.
So I asked my professor for help and he sent me codes as follow:
egen victorymargin_25=pctile(victorymargin), p(25)
gen Close=1 if victorymargin<=victorymargin_25 & victorymargin!=.
replace Close=0 if victorymargin>victorymargin_25 & victorymargin!=.
But they are not working and I don't think these codes are doing what I wanted to do.
So I think maybe I need to ask for some advice.
Can anyone here help me please.
Thank you!
Related Posts with Problem with using margins code and creating a dummy variable on command box
Collapsing a dataset with categorical variablesHi all, I have a dataset with indiviudal-level data that I would like to collapse into household-le…
Post-test estimations with imputed data using stcrregDear all, I am using Fine & Gray proportional subhazard models to calculate the effect of some …
How to group time datahello I need your help if I want to organize my data and group it by week. for example, I want to ca…
Local Average Treatment Effect after BiprobitHi all, I would like to know how to compute LATE after a biprobit model with endogenous binary regr…
Can the log-rank test be used to compare cumulative incidence curves where the temporal order of events is known but not the actual times?I'm using Stata 15 on 64-bit W10 and I used dataex to provide sample data below. I have about one h…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with using margins code and creating a dummy variable on command box
Post a Comment