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
Using a codebook generated by "describe, replace" to label another datasetHi I have built a readable codebook using the describe command as follows: Code: use "$mastData/D…
Hayashi C statisticHi- anyone knows how this test [Hayashi C test] be done on Stata. …
Missing value generated after predicting standardized residualHello, When I predict standardized residuals after a regression (including a dummy where only 1 obs…
Question about panel dataDear all, I am currently working on my MSc thesis in Finance and I use data from Orbis. I need to co…
Between estimation Robust and Cluster robust Standard errors not optional?Dear all, Can some explain me why there is no 'cluster(id)' or 'robust' option for the following be…
Subscribe to:
Post Comments (Atom)
0 Response to Problem with using margins code and creating a dummy variable on command box
Post a Comment