Hello every one, I am currently estimating a model in Stata 15, and I have a dataset in which I have the dependent Variable as trade exports divided in 3 categories Margins of export.
but when i run the command: xtset pairid StartYear
it says: repeated time values within panel
that is because I have 3 categories of margins for each year, so I have the repetition of each year 3 times. As you can see in a representation of my dataset i made below
--------------------------------------------------------------------------------------------DVmagins-c1 ----DVmargins-c2------ Independent variable X1
country-1 country-2 Category 1 - Increase margins- year = 2000 -------4332 ----------- 434----------------------90
country-1 country-2 Category 2- decrease margins - year = 2000 --------3445---------------3344 ------------------90
country-1 country-2 Category 3- Extinct margins - year = 2000 -----------44545----------- 2343 --------------------90
country-1 country-2 Category 1 - Increase margins- year = 2001--------- 1335------------- 865 ---------------------88
country-1 country-2 Category 2 - decrease margins year = 2001----------- 345-------------- 98---------------------- 88
country-1 country-2 Category 3- Extinct margins year = 2001--------------- 245 -------------105 ----------------------88
So as you can see, each one of the 3 categories has a different value for each year, therefore, I have 3 observation of my DV variable for each year .
but when comes to my independet variables, I have one single observation per year, but I had to repeat each IV observation 3 times.
So thinking about the solution I thought in making my Dependent variable a mean of the three categories so , the observations can become one for each year, and therefore, the years do not duplicates. like that my IVs will also stay one single observation per year without repeating.
and becomes like this> --------------DVmagins-c1 DVmargins-c2 Independent variable X1
country-1 country-2 year = 2000 ------4332 -------------434-------------------- 90
country-1 country-2 year = 2001 ------1335 -------------865 --------------------88
So how I can make these 3 categories become one, like a mean of all of them, so that instead I have each year repeated three times, I have one mean for one year repeated only once?
I have tried like this>
egen Margins =rowmean(DV_MarginsC2 DV_MarginsC1)
egen Margins =rowmean(Category 1 category 2 Category 3)
I have used collapse command like this
collapse DV_MarginsC1 DV_MarginsC2, by(COUNTRY_C1 COUNTRY_C2 StartYear
I do not know what else to do. Could you guys give a help?
An option would be go to excel again and make the mean of the categories, so that it gets one observation per year, that represents all the categories but it seems costly I would like to try a solution through Stata. Thank you
Related Posts with How to make the mean of my DV variable in order to run panel without year values repeated
Post hoc test after Fisher Exact testDear users, I am new to the Stata world, and I am not an expert statistician at all. In my master's…
Marginsplot errorDear Stata users, I am trying to use the marginsplot command, but I keep getting an error. My code…
graph barHi Stata users, I was wondering if someone can help with ideas in graphing a bar with options -over…
A buggy explanation in the help for -monthly-. -monthly- fails where according to help is supposed to work,and succeeds where it is not clear it should. I obtain the following strange results using the date…
error in biprobit commandHi. I am trying to estimate the impact of migration on child education using survey data. My depende…
Subscribe to:
Post Comments (Atom)
0 Response to How to make the mean of my DV variable in order to run panel without year values repeated
Post a Comment