Announcement

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

  • Gravity Model- Panel Data- infrastructure investment, transport costs and Trade- Problem with Creating variables for regression-

    Hi,

    I am New to this site as well as new to Stata. I am doing my Mater degree research by using gravity model on Impact of infrastructure investment on Trade, as an empirical investigation for Sri Lanka. I am Using 30 years data of ten major Exporters of Sri Lanka and I am using panel data.

    Sri Lanka`s Export values to those countries are the dependent variable of my model and GDP of Sri lanaka and trade Partner countries, Capital stock data of Sri lanaka and trade Partner countries, and distance between two capital cities are the independent variables.

    my main regression model is as follow.

    log (X 1j,t ) = α + β1 log(Y 1,t ) + β2 log(Y j,t ) + β3 log(GG 1,t ) + β4 log(GG j,t ) + β5 (D1j ) + U1jt


    Where X 1j,t are exports from country 1 (Sri Lanka) to country j (trading partner) at time t, Y 1,t and Y j,t are the GDPs of country 1 (Sri Lanka)and j, (trading partner) respectively, at time t, GG 1j,t are General Government capital stock of country 1 (Sri Lanka) and j, (trading partner) respectively, at time t and D1j is the distance between the capital cities of the two countries.

    Further, I have to check following regressions as well:

    2. Regression with country fixed effect:
    log (X 1j,t ) = α + β1 log(Y 1,t ) + β2 log(Y j,t ) + β3 log(GG 1,t ) + β4 log(GG j,t ) +δj + U1jt

    3. Regression with time fixed effect:
    log (X 1j,t ) = γ +η1 log(Y j,t ) + η2 log(GG j,t ) + η3 (D1j ) + δt + V1jt

    4. Regression with country and time fixed effects:

    log (X 1j,t ) = γ +η1 log(Y j,t ) + η2 log(GG j,t ) +δj + δt + V1jt


    my problems:

    1. How can I incorporate distance data to my main data set. ( I have already combined GDP, Capital stock Data and Export values in Stata format and ran basic commands and got summary of my data other than distance data) please see the attachments do_research.do combined.csv

    2. What kind of variables should i create to get output for the above regression? what should be the my final dta data file?


    Therefore it is grateful and much appreciated if you could instruct me how can I run my regression and get output with distance data as well please. further, can I see a sample of final dta file (datafile) which has this kind of regression?

    kind regards

    Kuloja

  • #2
    Welcome to Statalist.

    Before going further, let me suggest that to make the most effective use of Statalist, you should begin by reviewing the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    With that said, here is some technique for creating your X, Y, and GG variables using a small extract of your sample data.
    Code:
    // read in sample data - using shorter variable names
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int year str20 country float(gdp cap exp)
    2011 "Netherlands"  850.3043 535.09644 198
    2012 "Netherlands"  841.3163   542.436 159
    2013 "Netherlands"   839.715  547.0718 191
    2014 "Netherlands"  851.6363  550.3263 243
    2015 "Netherlands"  870.8897  552.5249 220
    2011 "Sri Lanka"     61.4934  63.86497   .
    2012 "Sri Lanka"    67.11671  68.70191   .
    2013 "Sri Lanka"     69.3958   74.7403   .
    2014 "Sri Lanka"   72.838326  81.48411   .
    2015 "Sri Lanka"    76.36251  88.54515   .
    2011 "Turkey"       857.6593   708.062 151
    2012 "Turkey"       898.7407  726.5873 139
    2013 "Turkey"       975.0555  748.7488 192
    2014 "Turkey"      1025.4336   781.408 260
    2015 "Turkey"      1087.8403  807.9203 180
    end
    save master, replace
    // the work starts here
    // create a dataset with the Sri Lanka data only
    use master, clear
    keep if country=="Sri Lanka"
    drop exp
    rename gdp gdp_sl
    rename cap cap_sl
    drop country
    tempfile sl
    save `sl'
    // read the master dataset and delete the Sri Lanka observations
    use master, clear
    drop if country=="Sri Lanka"
    // merge the data for Sri Lanka on the observations for other countries
    merge m:1 year using `sl'
    sort country year
    list
    // rename variables
    drop _merge
    rename exp X
    rename gdp Y
    rename cap GG
    rename gdp_sl Y1
    rename cap_sl GG1
    list
    Code:
    . // the work starts here
    . // create a dataset with the Sri Lanka data only
    . use master, clear
    
    . keep if country=="Sri Lanka"
    (10 observations deleted)
    
    . drop exp
    
    . rename gdp gdp_sl
    
    . rename cap cap_sl
    
    . drop country
    
    . tempfile sl
    
    . save `sl'
    file /var/folders/xr/lm5ccr996k7dspxs35yqzyt80000gp/T//S_04416.000002 saved
    
    . // read the master dataset and delete the Sri Lanka observations
    . use master, clear
    
    . drop if country=="Sri Lanka"
    (5 observations deleted)
    
    . // merge the data for Sri Lanka on the observations for other countries
    . merge m:1 year using `sl'
    
        Result                           # of obs.
        -----------------------------------------
        not matched                             0
        matched                                10  (_merge==3)
        -----------------------------------------
    
    . sort country year
    
    . list
    
         +------------------------------------------------------------------------------------+
         | year       country        gdp        cap   exp     gdp_sl     cap_sl        _merge |
         |------------------------------------------------------------------------------------|
      1. | 2011   Netherlands   850.3043   535.0964   198    61.4934   63.86497   matched (3) |
      2. | 2012   Netherlands   841.3163    542.436   159   67.11671   68.70191   matched (3) |
      3. | 2013   Netherlands    839.715   547.0718   191    69.3958    74.7403   matched (3) |
      4. | 2014   Netherlands   851.6363   550.3263   243   72.83833   81.48411   matched (3) |
      5. | 2015   Netherlands   870.8897   552.5249   220   76.36251   88.54515   matched (3) |
         |------------------------------------------------------------------------------------|
      6. | 2011        Turkey   857.6593    708.062   151    61.4934   63.86497   matched (3) |
      7. | 2012        Turkey   898.7407   726.5873   139   67.11671   68.70191   matched (3) |
      8. | 2013        Turkey   975.0555   748.7488   192    69.3958    74.7403   matched (3) |
      9. | 2014        Turkey   1025.434    781.408   260   72.83833   81.48411   matched (3) |
     10. | 2015        Turkey    1087.84   807.9203   180   76.36251   88.54515   matched (3) |
         +------------------------------------------------------------------------------------+
    
    . // rename variables
    . drop _merge
    
    . rename exp X
    
    . rename gdp Y
    
    . rename cap GG
    
    . rename gdp_sl Y1
    
    . rename cap_sl GG1
    
    . list
    
         +----------------------------------------------------------------------+
         | year       country          Y         GG     X         Y1        GG1 |
         |----------------------------------------------------------------------|
      1. | 2011   Netherlands   850.3043   535.0964   198    61.4934   63.86497 |
      2. | 2012   Netherlands   841.3163    542.436   159   67.11671   68.70191 |
      3. | 2013   Netherlands    839.715   547.0718   191    69.3958    74.7403 |
      4. | 2014   Netherlands   851.6363   550.3263   243   72.83833   81.48411 |
      5. | 2015   Netherlands   870.8897   552.5249   220   76.36251   88.54515 |
         |----------------------------------------------------------------------|
      6. | 2011        Turkey   857.6593    708.062   151    61.4934   63.86497 |
      7. | 2012        Turkey   898.7407   726.5873   139   67.11671   68.70191 |
      8. | 2013        Turkey   975.0555   748.7488   192    69.3958    74.7403 |
      9. | 2014        Turkey   1025.434    781.408   260   72.83833   81.48411 |
     10. | 2015        Turkey    1087.84   807.9203   180   76.36251   88.54515 |
         +----------------------------------------------------------------------+

    Comment


    • #3
      Dear William Lisowski

      Thank you very much for your kind reply and I will try the way you have explained in the reply. If I found any difficulties i will post here again.

      Thank you againg

      Kind regards

      Kuloja

      Comment


      • #4
        Dear William Lisowski



        Thank you for your kind guidance and I ran my data and got following results accordingly..pls see the attachment: Output.docx

        now I have following problem:

        1. According to the results, it shows negative relationship between Capital stock - both of my country as well as trading partner - GG1 and GGj (Infrastructure Investment) and exports - X. But I am expecting to have positive relationship between these two variables. so, what kind of changes should I do for this? Do I need to add control variables? if so How can i include them please?

        2. As per my adviser, I should run my benchmark regression as well as I should try to run it with time fixed effect and country fixed effect as well. Accordingly I have to run following regressions too. Can you please kindly advice me how to include these two fixed effects and what are the stata codes for them please.

        Regression with country fixed effect:

        log (X 1j,t ) = α + β1 log(Y 1,t ) + β2 log(Y j,t ) + β3 log(GG 1,t ) + β4 log(GG j,t ) +δj + U1jt

        δj= country fixed effect

        Regression with time fixed effect:

        log (X 1j,t ) = γ + η1 log(Y j,t ) + η2 log(GG j,t ) + η3 (D1j ) + δt + V1jt

        δt = time fixed effect

        Regression with country and time fixed effects:

        log (X 1j,t ) = γ + η1 log(Y j,t ) + η2 log(GG j,t ) +δj + δt + V1jt

        Your kind instructions are greatly appreciated

        Kind regards



        Attached Files

        Comment


        • #5
          At this point I have to bow out: I'm good for Stata code, not so for methodology in your field, which is not one I work in. The only gravity model I know of was introduced by Isaac Newton in 1687.

          Comment


          • #6
            Dear William Lisowski

            Thank you very much for your reply. sorry for bothering you this much, but if you can could you please provide me the

            stata codes for time fixed effect and country fixed effect please?

            I try for country fixed effect with following code, is that correct?

            . xtreg X Y1 Yj GG1 GGj D1j, fe

            If it is correct can you please tell me the stata code time fixed effect as well?

            Kind regards

            Kuloja

            Comment

            Working...
            X