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
Two sample Kolmogorov-Smirnov test resultsHello everybody, I would like to ask a question concerning the interpretation of a two sample Kolmo…
Coding LoopsHi all, I've recently moved to STATA from more point-and-click interfaces (i.e. SPSS), and am havin…
conformability error r(503) when looping matrixHello statalists, I'm trying to loop some basic descriptive stats of age according to sex. Right no…
mixlpred command after mixlogitDear Stata Users, I run a mixed logit model (-mixlogit-) to identify preferences in a choice experi…
Hosmer Lemeshow test in StataHave anyone noticed that the results from the Hosmer Lemeshow test (for evaluating calibration in pr…
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