Announcement

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

  • Sophie Gebers
    started a topic Generating a trend line for time series data

    Generating a trend line for time series data

    Dear all

    I am trying to estimate the effect that the civil conflict in Mozambique and Rwanda have had on the GDP per capita growth in the long run.
    This was done by making a conflict dummy (= 1 if the conflict occurred - i.e. the years of the conflict, and zero otherwise) and a dynamic time series regression analysis was conducted.
    The aim is to study how the post-conflict economies have differed since the 1990s.

    I am now trying to generate a graph to show how to the GDP per capita trend line would have continued if the conflict had not occurred. My supervisor has requested that i overlay this with the observed empirical data (which shows a drastic drop in GDP per capita growth over the conflict years).

    I am at a loss at what command to use and how i would show GDP per capita growth over the years if the dummy = 0. Basically, i want to predict the growth prior to the onset of the conflict to see how it would have continued.

    Kind regards
    Sophie

  • Sophie Gebers
    replied
    Thank you so much! this worked brilliantly

    Leave a comment:


  • Andrew Musau
    replied
    a dynamic time series regression analysis was conducted
    You should be able to predict GDP based on this regression. The following uses linear regression, but the principle is the same. Data is from the Penn World Table (PWT), Version 9.0.

    Code:
    clear
    use "D:\Penn World Table\pwt90.dta"
    keep countrycode country year rgdpe
    keep if inlist(countrycode, "RWA", "MOZ")
    *CONSIDER SAMPLE PERIOD 1960-2000
    keep if inrange(year, 1960,2000)
    dataex
    This gives me the following data set.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str3 countrycode str34 country int year float rgdpe
    "MOZ" "Mozambique" 1960  3867.715
    "MOZ" "Mozambique" 1961  3932.929
    "MOZ" "Mozambique" 1962  4274.524
    "MOZ" "Mozambique" 1963  4409.609
    "MOZ" "Mozambique" 1964  4595.819
    "MOZ" "Mozambique" 1965 4656.6484
    "MOZ" "Mozambique" 1966 4775.0757
    "MOZ" "Mozambique" 1967  5264.314
    "MOZ" "Mozambique" 1968  5605.844
    "MOZ" "Mozambique" 1969  5945.903
    "MOZ" "Mozambique" 1970   5886.53
    "MOZ" "Mozambique" 1971  6331.288
    "MOZ" "Mozambique" 1972   6646.14
    "MOZ" "Mozambique" 1973  6963.463
    "MOZ" "Mozambique" 1974  7392.874
    "MOZ" "Mozambique" 1975   7550.58
    "MOZ" "Mozambique" 1976  7986.316
    "MOZ" "Mozambique" 1977  7942.489
    "MOZ" "Mozambique" 1978  8059.265
    "MOZ" "Mozambique" 1979  8322.702
    "MOZ" "Mozambique" 1980  8531.938
    "MOZ" "Mozambique" 1981  8853.324
    "MOZ" "Mozambique" 1982  8489.965
    "MOZ" "Mozambique" 1983    7531.2
    "MOZ" "Mozambique" 1984   8018.53
    "MOZ" "Mozambique" 1985  7469.196
    "MOZ" "Mozambique" 1986  7653.674
    "MOZ" "Mozambique" 1987  6746.971
    "MOZ" "Mozambique" 1988   6502.01
    "MOZ" "Mozambique" 1989   7034.37
    "MOZ" "Mozambique" 1990  6958.745
    "MOZ" "Mozambique" 1991  7200.976
    "MOZ" "Mozambique" 1992  6209.826
    "MOZ" "Mozambique" 1993  6647.679
    "MOZ" "Mozambique" 1994  7359.988
    "MOZ" "Mozambique" 1995  6723.377
    "MOZ" "Mozambique" 1996  8570.316
    "MOZ" "Mozambique" 1997 10067.857
    "MOZ" "Mozambique" 1998 10914.943
    "MOZ" "Mozambique" 1999 10778.104
    "MOZ" "Mozambique" 2000  11768.17
    "RWA" "Rwanda"     1960   2907.04
    "RWA" "Rwanda"     1961  2779.208
    "RWA" "Rwanda"     1962 3058.9595
    "RWA" "Rwanda"     1963  2742.219
    "RWA" "Rwanda"     1964 2429.9443
    "RWA" "Rwanda"     1965 2570.9075
    "RWA" "Rwanda"     1966 2747.6755
    "RWA" "Rwanda"     1967  2955.911
    "RWA" "Rwanda"     1968 3144.6426
    "RWA" "Rwanda"     1969 3490.9436
    "RWA" "Rwanda"     1970  3729.725
    "RWA" "Rwanda"     1971  3764.731
    "RWA" "Rwanda"     1972  3908.712
    "RWA" "Rwanda"     1973 4070.0564
    "RWA" "Rwanda"     1974  4146.804
    "RWA" "Rwanda"     1975 4196.1416
    "RWA" "Rwanda"     1976  4930.653
    "RWA" "Rwanda"     1977  5260.436
    "RWA" "Rwanda"     1978  5275.527
    "RWA" "Rwanda"     1979  6033.643
    "RWA" "Rwanda"     1980  5914.005
    "RWA" "Rwanda"     1981  6773.521
    "RWA" "Rwanda"     1982  6607.071
    "RWA" "Rwanda"     1983  7028.359
    "RWA" "Rwanda"     1984  6834.581
    "RWA" "Rwanda"     1985  7179.453
    "RWA" "Rwanda"     1986  7548.521
    "RWA" "Rwanda"     1987    7236.6
    "RWA" "Rwanda"     1988  7342.398
    "RWA" "Rwanda"     1989  7898.195
    "RWA" "Rwanda"     1990  7616.388
    "RWA" "Rwanda"     1991  6695.044
    "RWA" "Rwanda"     1992  7019.048
    "RWA" "Rwanda"     1993  6427.501
    "RWA" "Rwanda"     1994  2976.832
    "RWA" "Rwanda"     1995  3651.788
    "RWA" "Rwanda"     1996 4164.0347
    "RWA" "Rwanda"     1997  4977.287
    "RWA" "Rwanda"     1998  5379.086
    "RWA" "Rwanda"     1999  5504.029
    "RWA" "Rwanda"     2000  6154.195
    end
    The linear regression model is

    $$\text{GDP}_{t}=\beta_{0}+ \beta_{1}\text{t}+u_{t} $$

    Code:
    encode countrycode, gen(ccode)
    *GEN CONFLICT DUMMY
    gen conflict=countrycode=="RWA"& inrange(year, 1990, 1994)
    replace conflict=1 if countrycode=="MOZ"& inrange(year, 1977, 1992)
    *RUN REGRESSION AND PREDICT DV
    regress rgdpe year if countrycode=="RWA"& year<1990
    predict rgdpehatr if countrycode=="RWA", xb
    regress rgdpe year if countrycode=="MOZ"& year<1977
    predict rgdpehatm if countrycode=="MOZ", xb
    *REPLACE PREDICTED DV WITH ACTUAL VALUES PRE CONFLICT
    replace rgdpehatr= rgdpe if countrycode=="RWA"& year<1990
    replace rgdpehatm= rgdpe if countrycode=="MOZ"& year<1977
    gen predicted= cond(countrycode=="RWA", rgdpehatr, rgdpehatm)
    *GRAPH ACTUAL AND PREDICTED
    xtset ccode year
    xtline predicted rgdpe, legend(order(2 "Actual GDP" 1 "Pre-Conflict Linear Prediction"))

    Res.:

    Click image for larger version

Name:	Graph.png
Views:	1
Size:	85.8 KB
ID:	1521198

    Last edited by Andrew Musau; 20 Oct 2019, 07:48.

    Leave a comment:

Working...
X