Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Gravity model - HS6 product level - missing values !matching! no interpolation

    Hi there,

    As I am estimating a disaggregated gravity model, it inherently contains many missing values simply because countries do not trade the same product category every year. As an example I have appended an excerpt of my data beneath. I would like to fill MOST of these missing values, as they are known in other observations if that makes sense. For example: I have variables for GDP which is known for each year and is allready filled out in observations with other HS6 codes. In essence, what I would like to do is fill this variables in the newly created (tsfill, full) observations.

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
     year origin destination hs6digit export  import
    2011 ""    ""         .        .         .
    2012 ""    ""         .        .         .
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 "rus" "abw" 210500        0  10672.34
    2016 ""    ""         .        .         .
    2017 ""    ""         .        .         .
    2011 ""    ""         .        .         .
    2012 ""    ""         .        .         .
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 "rus" "abw" 240220    74130         0
    2017 ""    ""         .        .         .
    2011 ""    ""         .        .         .
    2012 ""    ""         .        .         .
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 ""    ""         .        .         .
    2017 "rus" "abw" 270900  3530132         0
    2011 ""    ""         .        .         .
    2012 ""    ""         .        .         .
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 "rus" "abw" 271000 21536285         0
    2017 ""    ""         .        .         .
    2011 ""    ""         .        .         .
    2012 ""    ""         .        .         .
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 ""    ""         .        .         .
    2017 "rus" "abw" 292212     5308         0
    2011 ""    ""         .        .         .
    2012 "rus" "abw" 847330        0      9988
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 ""    ""         .        .         .
    2017 ""    ""         .        .         .
    2011 ""    ""         .        .         .
    2012 "rus" "abw" 851762        0      8949
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 ""    ""         .        .         .
    2017 ""    ""         .        .         .
    2011 ""    ""         .        .         .
    2012 "rus" "afg"  40210    15432         0
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 ""    ""         .        .         .
    2017 ""    ""         .        .         .
    2011 ""    ""         .        .         .
    2012 ""    ""         .        .         .
    2013 "rus" "afg"  40299     3555         0
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 ""    ""         .        .         .
    2017 ""    ""         .        .         .
    2011 ""    ""         .        .         .
    2012 "rus" "afg"  40390    20644         0
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 ""    ""         .        .         .
    2017 ""    ""         .        .         .
    2011 ""    ""         .        .         .
    2012 ""    ""         .        .         .
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 "rus" "afg"  40900    40110         0
    2016 ""    ""         .        .         .
    2017 ""    ""         .        .         .
    2011 "rus" "afg"  50400    51260         0
    2012 ""    ""         .        .         .
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 ""    ""         .        .         .
    2017 ""    ""         .        .         .
    2011 "rus" "afg"  70190        0   9803998
    2012 ""    ""         .        .         .
    2013 "rus" "afg"  70190        0 1840135.6
    2014 "rus" "afg"  70190        0  61082.65
    2015 ""    ""         .        .         .
    2016 ""    ""         .        .         .
    2017 ""    ""         .        .         .
    2011 "rus" "afg"  70310        0  65259.25
    2012 ""    ""         .        .         .
    2013 ""    ""         .        .         .
    2014 ""    ""         .        .         .
    2015 ""    ""         .        .         .
    2016 ""    ""         .        .         .
    2017 "rus" "afg"  70310    13475         0
    2011 "rus" "afg"  70690        0  32443.64
    2012 ""    ""         .        .         .
    end
    ------------------ copy up to and including the previous line ------------------

    Listed 100 out of 1648360 observations


    I hope someone is able to assist me with this issue.

    Kind regards,

    Tim

  • #2
    Hi Again,

    I still hope to obtain help with this matter.

    In terms of clarification, I think I can get the job done using merge. Yet, the question remains how?

    Below I have appended an excerpt of a representative case in my data.

    Click image for larger version

Name:	excerpt.png
Views:	1
Size:	10.4 KB
ID:	1498965


    As a unique identifier, I have productpairid on the left hand side. In essence I think the most straightforward way to fill the gaps by merging it with my old dataset without the use of tsfill. I believe that, in order for this to work, I first would have to fill the first 8 columns. The export and import variables should then remain 0 I presume (which they should be!) and, hopefully, the rest will be filled since those values are knownfor these years and productpairids.

    Would this be a correct procedure and could someone help me in terms of commands?

    Kind regards,

    Tim

    Comment

    Working...
    X