Sie sind auf Seite 1von 53

Forecasting

tools in Stata

Gustavo
Sanchez

Outline

Solving
models

Subcommands

Examples with
Forecasting tools in Stata
Time Series
Ex 1: regress
Ex 2: TS
operators and
identities
Ex 3: VAR -
Gustavo Sanchez
ARIMA

Examples with Senior Statistician


Panel Data
Ex 4: Panel data
StataCorp LP
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Mexico City, Mexico
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 1 / 33


Forecasting
tools in Stata

Gustavo
Sanchez

Outline

Solving
models
Outline
Subcommands

Examples with Solving models for a collection of equations


Time Series
Ex 1: regress
Ex 2: TS
Subcommands
operators and
identities
Ex 3: VAR -
Examples with time series
ARIMA

Examples with
Examples with panel data
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 2 / 33


Forecasting
tools in Stata

Gustavo
Sanchez

Outline
Solving models for a collection of equations
Solving
models
Components
Subcommands
Stochastic equations fit using estimation commands
Examples with
Time Series Identities
Ex 1: regress
Ex 2: TS
Coefficient vectors
operators and
identities
Ex 3: VAR - Solving the model
ARIMA

Examples with
Obtain static or dynamic forecasts
Panel Data Alternative forecast scenarios
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
forecast command
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 3 / 33


Forecasting
tools in Stata

Gustavo Subcommands
Sanchez
Building the model
Outline
create
Solving
models estimates
Subcommands identity
Examples with coefvector
Time Series exogenous
Ex 1: regress
Ex 2: TS
operators and Solving the model
identities
Ex 3: VAR -
ARIMA
solve
Examples with
adjust
Panel Data
Ex 4: Panel data
Utilities
Ex 4.1:
xtreg xtabond describe
Ex 4.2:
Forecast list
scenarios
Ex 4.3: clear
Coefficient
Vector drop
Questions? query

Gustavo Sanchez (StataCorp) May 3, 2013 4 / 33


Forecasting
tools in Stata

Gustavo
Sanchez

Outline

Solving
models

Subcommands

Examples with
Time Series
Ex 1: regress Examples with Time Series
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA

Examples with
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 5 / 33


Forecasting
tools in Stata Example with Time series
Gustavo
Sanchez
Variables and Notation
Outline (Quarterly macroeconomic data for Uruguay)
Solving
models
m1 : Currency and demand deposits
Subcommands

Examples with pib : Gross domestic product (GDP)


Time Series
Ex 1: regress
Ex 2: TS
tcpn : Exchange rate.
operators and
identities
Ex 3: VAR -
ARIMA
ipcp97 : Consumer price index (1997 = 100):
Examples with
Panel Data
mt : Imports
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
xt : Exports
Ex 4.2:
Forecast
scenarios ipex : Exports price index.
Ex 4.3:
Coefficient
Vector

Questions?
Note: l will be used for natural logs and d for first
difference
Source: International Monetary Fund
Gustavo Sanchez (StataCorp) May 3, 2013 6 / 33
Forecasting
tools in Stata

Gustavo
Sanchez Example 1: Time series - OLS regressions
Outline

Solving . regress dlm1 dlpib dlipcp97 if tin(1989q1,2009q4),noheader


models
dlm1 Coef. Std. Err. t P>|t| [95% Conf. Interval]
Subcommands

Examples with dlpib 1.081708 .1506757 7.18 0.000 .7818536 1.381562


Time Series dlipcp97 -.3440374 .1829109 -1.88 0.064 -.7080417 .0199669
Ex 1: regress _cons .0220782 .014986 1.47 0.145 -.0077448 .0519012
Ex 2: TS
operators and
identities . estimates store eq_m1
Ex 3: VAR -
ARIMA .
. regress dlmt dltcpn dlpib if tin(1989q1,2009q4),noheader
Examples with
Panel Data
Ex 4: Panel data
dlmt Coef. Std. Err. t P>|t| [95% Conf. Interval]
Ex 4.1:
xtreg xtabond dltcpn -.1963056 .1439482 -1.36 0.176 -.4827717 .0901604
Ex 4.2:
Forecast dlpib .675093 .1495172 4.52 0.000 .3775444 .9726417
scenarios _cons .0204891 .0123684 1.66 0.102 -.0041248 .0451029
Ex 4.3:
Coefficient
Vector . estimates store eq_mt
Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 7 / 33


Forecasting
tools in Stata

Gustavo
Sanchez Example 1: Time series - OLS regressions
Outline

Solving . regress dlm1 dlpib dlipcp97 if tin(1989q1,2009q4),noheader


models
dlm1 Coef. Std. Err. t P>|t| [95% Conf. Interval]
Subcommands

Examples with dlpib 1.081708 .1506757 7.18 0.000 .7818536 1.381562


Time Series dlipcp97 -.3440374 .1829109 -1.88 0.064 -.7080417 .0199669
Ex 1: regress _cons .0220782 .014986 1.47 0.145 -.0077448 .0519012
Ex 2: TS
operators and
identities . estimates store eq_m1
Ex 3: VAR -
ARIMA .
. regress dlmt dltcpn dlpib if tin(1989q1,2009q4),noheader
Examples with
Panel Data
Ex 4: Panel data
dlmt Coef. Std. Err. t P>|t| [95% Conf. Interval]
Ex 4.1:
xtreg xtabond dltcpn -.1963056 .1439482 -1.36 0.176 -.4827717 .0901604
Ex 4.2:
Forecast dlpib .675093 .1495172 4.52 0.000 .3775444 .9726417
scenarios _cons .0204891 .0123684 1.66 0.102 -.0041248 .0451029
Ex 4.3:
Coefficient
Vector . estimates store eq_mt
Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 7 / 33


Forecasting
tools in Stata
Example 1: Time series - OLS regressions
Gustavo Create the model
Sanchez
. forecast create myfcst1
Outline Forecast model myfcst1 started.
Solving Add equations
models

Subcommands . forecast estimates eq_m1


Added estimation results from regress.
Examples with Forecast model myfcst1 now contains 1 endogenous variable.
Time Series
. forecast estimates eq_mt
Ex 1: regress
Ex 2: TS
Added estimation results from regress.
operators and Forecast model myfcst1 now contains 2 endogenous variables.
identities
Ex 3: VAR -
ARIMA
Solve the model
Examples with . forecast solve, begin(q(2010q1))
Panel Data
Computing dynamic forecasts for model myfcst1.
Ex 4: Panel data
Ex 4.1:
xtreg xtabond Starting period: 2010q1
Ex 4.2: Ending period: 2011q2
Forecast
scenarios Forecast prefix: f_
Ex 4.3:
Coefficient 2010q1: ..............
Vector 2010q2: ..............
Questions? 2010q3: .............
2010q4: .............
2011q1: ..............
2011q2: ..............
Forecast 2 variables spanning 6 periods.
Gustavo Sanchez (StataCorp) May 3, 2013 8 / 33
Forecasting
tools in Stata
Example 1: Time series - OLS regressions
Gustavo Create the model
Sanchez
. forecast create myfcst1
Outline Forecast model myfcst1 started.
Solving Add equations
models

Subcommands . forecast estimates eq_m1


Added estimation results from regress.
Examples with Forecast model myfcst1 now contains 1 endogenous variable.
Time Series
. forecast estimates eq_mt
Ex 1: regress
Ex 2: TS
Added estimation results from regress.
operators and Forecast model myfcst1 now contains 2 endogenous variables.
identities
Ex 3: VAR -
ARIMA
Solve the model
Examples with . forecast solve, begin(q(2010q1))
Panel Data
Computing dynamic forecasts for model myfcst1.
Ex 4: Panel data
Ex 4.1:
xtreg xtabond Starting period: 2010q1
Ex 4.2: Ending period: 2011q2
Forecast
scenarios Forecast prefix: f_
Ex 4.3:
Coefficient 2010q1: ..............
Vector 2010q2: ..............
Questions? 2010q3: .............
2010q4: .............
2011q1: ..............
2011q2: ..............
Forecast 2 variables spanning 6 periods.
Gustavo Sanchez (StataCorp) May 3, 2013 8 / 33
Forecasting
tools in Stata
Example 1: Time series - OLS regressions
Gustavo Create the model
Sanchez
. forecast create myfcst1
Outline Forecast model myfcst1 started.
Solving Add equations
models

Subcommands . forecast estimates eq_m1


Added estimation results from regress.
Examples with Forecast model myfcst1 now contains 1 endogenous variable.
Time Series
. forecast estimates eq_mt
Ex 1: regress
Ex 2: TS
Added estimation results from regress.
operators and Forecast model myfcst1 now contains 2 endogenous variables.
identities
Ex 3: VAR -
ARIMA
Solve the model
Examples with . forecast solve, begin(q(2010q1))
Panel Data
Computing dynamic forecasts for model myfcst1.
Ex 4: Panel data
Ex 4.1:
xtreg xtabond Starting period: 2010q1
Ex 4.2: Ending period: 2011q2
Forecast
scenarios Forecast prefix: f_
Ex 4.3:
Coefficient 2010q1: ..............
Vector 2010q2: ..............
Questions? 2010q3: .............
2010q4: .............
2011q1: ..............
2011q2: ..............
Forecast 2 variables spanning 6 periods.
Gustavo Sanchez (StataCorp) May 3, 2013 8 / 33
Forecasting
tools in Stata

Gustavo Example 1: Time series - OLS regressions


Sanchez

Outline

Solving
models

Subcommands

Examples with
Time Series
Ex 1: regress
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA

Examples with
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 9 / 33


Forecasting
tools in Stata Example 2: Working with time series operators
Gustavo
Sanchez
Same two models but using first difference operator (D.)
Outline
. regress D.lm1 D.lpib D.lipcp97 if tin(1989q1,2009q4),noheader vsquish
Solving
models
D.lm1 Coef. Std. Err. t P>|t| [95% Conf. Interval]
Subcommands
lpib
Examples with
D1. 1.081708 .1506757 7.18 0.000 .7818536 1.381562
Time Series
lipcp97
Ex 1: regress
Ex 2: TS D1. -.3440374 .1829109 -1.88 0.064 -.7080417 .0199669
operators and _cons .0220782 .014986 1.47 0.145 -.0077448 .0519012
identities
Ex 3: VAR -
ARIMA . estimates store eq2_m1
Examples with .
Panel Data . regress D.lmt D.ltcpn D.lpib if tin(1989q1,2009q4),noheader vsquish
Ex 4: Panel data
Ex 4.1:
xtreg xtabond D.lmt Coef. Std. Err. t P>|t| [95% Conf. Interval]
Ex 4.2:
Forecast ltcpn
scenarios
Ex 4.3: D1. -.1963056 .1439482 -1.36 0.176 -.4827717 .0901604
Coefficient lpib
Vector
D1. .675093 .1495172 4.52 0.000 .3775444 .9726417
Questions? _cons .0204891 .0123684 1.66 0.102 -.0041248 .0451029

. estimates store eq2_mt

Gustavo Sanchez (StataCorp) May 3, 2013 10 / 33


Forecasting
tools in Stata Example 2: Working with time series operators
Gustavo
Sanchez
Same two models but using first difference operator (D.)
Outline
. regress D.lm1 D.lpib D.lipcp97 if tin(1989q1,2009q4),noheader vsquish
Solving
models
D.lm1 Coef. Std. Err. t P>|t| [95% Conf. Interval]
Subcommands
lpib
Examples with
D1. 1.081708 .1506757 7.18 0.000 .7818536 1.381562
Time Series
lipcp97
Ex 1: regress
Ex 2: TS D1. -.3440374 .1829109 -1.88 0.064 -.7080417 .0199669
operators and _cons .0220782 .014986 1.47 0.145 -.0077448 .0519012
identities
Ex 3: VAR -
ARIMA . estimates store eq2_m1
Examples with .
Panel Data . regress D.lmt D.ltcpn D.lpib if tin(1989q1,2009q4),noheader vsquish
Ex 4: Panel data
Ex 4.1:
xtreg xtabond D.lmt Coef. Std. Err. t P>|t| [95% Conf. Interval]
Ex 4.2:
Forecast ltcpn
scenarios
Ex 4.3: D1. -.1963056 .1439482 -1.36 0.176 -.4827717 .0901604
Coefficient lpib
Vector
D1. .675093 .1495172 4.52 0.000 .3775444 .9726417
Questions? _cons .0204891 .0123684 1.66 0.102 -.0041248 .0451029

. estimates store eq2_mt

Gustavo Sanchez (StataCorp) May 3, 2013 10 / 33


Forecasting
tools in Stata

Gustavo
Sanchez
Example 2: Working with time series operators
Outline
Include name for dependent variable
Solving
models . forecast create myfcst2
Subcommands Forecast model myfcst2 started.
. forecast estimates eq2_m1,names(Dlm1)
Examples with
Added estimation results from regress.
Time Series
Forecast model myfcst2 now contains 1 endogenous variable.
Ex 1: regress
Ex 2: TS . forecast estimates eq2_mt,names(Dlmt) advise
operators and
identities (These estimation results are no longer needed; you can drop them.)
Ex 3: VAR - Added estimation results from regress.
ARIMA Forecast model myfcst2 now contains 2 endogenous variables.
Examples with
Panel Data
Ex 4: Panel data
Add identities for log-levels
Ex 4.1:
xtreg xtabond . forecast identity lm1=L.lm1+Dlm1
Ex 4.2: Forecast model myfcst2 now contains 3 endogenous variables.
Forecast
scenarios . forecast identity lmt=L.lmt+Dlmt
Ex 4.3: Forecast model myfcst2 now contains 4 endogenous variables.
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 11 / 33


Forecasting
tools in Stata

Gustavo
Sanchez
Example 2: Working with time series operators
Outline
Include name for dependent variable
Solving
models . forecast create myfcst2
Subcommands Forecast model myfcst2 started.
. forecast estimates eq2_m1,names(Dlm1)
Examples with
Added estimation results from regress.
Time Series
Forecast model myfcst2 now contains 1 endogenous variable.
Ex 1: regress
Ex 2: TS . forecast estimates eq2_mt,names(Dlmt) advise
operators and
identities (These estimation results are no longer needed; you can drop them.)
Ex 3: VAR - Added estimation results from regress.
ARIMA Forecast model myfcst2 now contains 2 endogenous variables.
Examples with
Panel Data
Ex 4: Panel data
Add identities for log-levels
Ex 4.1:
xtreg xtabond . forecast identity lm1=L.lm1+Dlm1
Ex 4.2: Forecast model myfcst2 now contains 3 endogenous variables.
Forecast
scenarios . forecast identity lmt=L.lmt+Dlmt
Ex 4.3: Forecast model myfcst2 now contains 4 endogenous variables.
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 11 / 33


Forecasting
tools in Stata

Gustavo
Sanchez
Example 2: Working with time series operators
Outline
Add identities for the levels of the dependent variable
Solving . forecast identity m1 = exp(lm1)
models Forecast model myfcst2 now contains 5 endogenous variables.
Subcommands . forecast identity mt = exp(lmt)
Forecast model myfcst2 now contains 6 endogenous variables.
Examples with
Time Series
Ex 1: regress . forecast solve, begin(q(2010q1)) prefix(f2_)
Ex 2: TS Computing dynamic forecasts for model myfcst2.
operators and
identities
Ex 3: VAR - Starting period: 2010q1
ARIMA
Ending period: 2011q2
Examples with Forecast prefix: f2_
Panel Data
2010q1: ..............
Ex 4: Panel data
Ex 4.1:
2010q2: ..............
xtreg xtabond 2010q3: .............
Ex 4.2: 2010q4: ..............
Forecast
scenarios 2011q1: ..............
Ex 4.3: 2011q2: ..............
Coefficient
Vector Forecast 6 variables spanning 6 periods.
Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 12 / 33


Forecasting
tools in Stata

Gustavo
Sanchez
Example 2: Working with time series operators
Outline
Add identities for the levels of the dependent variable
Solving . forecast identity m1 = exp(lm1)
models Forecast model myfcst2 now contains 5 endogenous variables.
Subcommands . forecast identity mt = exp(lmt)
Forecast model myfcst2 now contains 6 endogenous variables.
Examples with
Time Series
Ex 1: regress . forecast solve, begin(q(2010q1)) prefix(f2_)
Ex 2: TS Computing dynamic forecasts for model myfcst2.
operators and
identities
Ex 3: VAR - Starting period: 2010q1
ARIMA
Ending period: 2011q2
Examples with Forecast prefix: f2_
Panel Data
2010q1: ..............
Ex 4: Panel data
Ex 4.1:
2010q2: ..............
xtreg xtabond 2010q3: .............
Ex 4.2: 2010q4: ..............
Forecast
scenarios 2011q1: ..............
Ex 4.3: 2011q2: ..............
Coefficient
Vector Forecast 6 variables spanning 6 periods.
Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 12 / 33


Forecasting
tools in Stata

Gustavo Example 2: Working with time series operators


Sanchez

Outline

Solving
models

Subcommands

Examples with
Time Series
Ex 1: regress
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA

Examples with
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 13 / 33


Forecasting
tools in Stata
Example 3.1: Systems of equations (VAR) and ARIMA
Gustavo
Sanchez . var dlpib dlxt if tin(1989q1,2009q4),lags(1) exog(dlipex) vsquish noconstant
Vector autoregression
Outline Sample: 1989q3 - 2009q4 No. of obs = 82
Solving Log likelihood = 202.7663 AIC = -4.799178
models FPE = .0000282 HQIC = -4.728476
Det(Sigma_ml) = .0000244 SBIC = -4.623077
Subcommands
Equation Parms RMSE R-sq chi2 P>chi2
Examples with
Time Series dlpib 3 .065405 0.1882 19.01206 0.0003
Ex 1: regress dlxt 3 .078392 0.5244 90.42973 0.0000
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA Coef. Std. Err. z P>|z| [95% Conf. Interval]
Examples with dlpib
Panel Data
dlpib
Ex 4: Panel data
Ex 4.1:
L1. -.4349428 .1037079 -4.19 0.000 -.6382065 -.231679
xtreg xtabond dlxt
Ex 4.2: L1. -.1074271 .0657059 -1.63 0.102 -.2362082 .021354
Forecast
scenarios dlipex .4569253 .3233219 1.41 0.158 -.176774 1.090625
Ex 4.3:
Coefficient
Vector dlxt
dlpib
Questions? L1. .9716131 .1243015 7.82 0.000 .7279866 1.21524
dlxt
L1. -.2507243 .0787533 -3.18 0.001 -.4050779 -.0963707
dlipex .4622208 .3875249 1.19 0.233 -.2973142 1.221756

Gustavo Sanchez (StataCorp) May 3, 2013 14 / 33


Forecasting
tools in Stata
Example 3.1: Systems of equations (VAR) and ARIMA
Gustavo
Sanchez . var dlpib dlxt if tin(1989q1,2009q4),lags(1) exog(dlipex) vsquish noconstant
Vector autoregression
Outline Sample: 1989q3 - 2009q4 No. of obs = 82
Solving Log likelihood = 202.7663 AIC = -4.799178
models FPE = .0000282 HQIC = -4.728476
Det(Sigma_ml) = .0000244 SBIC = -4.623077
Subcommands
Equation Parms RMSE R-sq chi2 P>chi2
Examples with
Time Series dlpib 3 .065405 0.1882 19.01206 0.0003
Ex 1: regress dlxt 3 .078392 0.5244 90.42973 0.0000
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA Coef. Std. Err. z P>|z| [95% Conf. Interval]
Examples with dlpib
Panel Data
dlpib
Ex 4: Panel data
Ex 4.1:
L1. -.4349428 .1037079 -4.19 0.000 -.6382065 -.231679
xtreg xtabond dlxt
Ex 4.2: L1. -.1074271 .0657059 -1.63 0.102 -.2362082 .021354
Forecast
scenarios dlipex .4569253 .3233219 1.41 0.158 -.176774 1.090625
Ex 4.3:
Coefficient
Vector dlxt
dlpib
Questions? L1. .9716131 .1243015 7.82 0.000 .7279866 1.21524
dlxt
L1. -.2507243 .0787533 -3.18 0.001 -.4050779 -.0963707
dlipex .4622208 .3875249 1.19 0.233 -.2973142 1.221756

Gustavo Sanchez (StataCorp) May 3, 2013 14 / 33


Forecasting
tools in Stata
Example 3.1: Systems of equations (VAR) and ARIMA
Gustavo
Sanchez
. arima dlipex if tin(1989q1,2009q4),arima(4,0,0) nolog vsquish
Outline ARIMA regression
Solving Sample: 1989q1 - 2009q4 Number of obs = 84
models Wald chi2(4) = 829.23
Log likelihood = 295.3648 Prob > chi2 = 0.0000
Subcommands

Examples with OPG


Time Series dlipex Coef. Std. Err. z P>|z| [95% Conf. Interval]
Ex 1: regress
Ex 2: TS dlipex
operators and
identities _cons .0041001 .0048688 0.84 0.400 -.0054427 .0136428
Ex 3: VAR -
ARIMA
ARMA
Examples with ar
Panel Data L1. 1.969244 .1136402 17.33 0.000 1.746513 2.191975
Ex 4: Panel data L2. -1.922958 .1900391 -10.12 0.000 -2.295428 -1.550489
Ex 4.1:
xtreg xtabond L3. 1.053276 .1576608 6.68 0.000 .7442666 1.362286
Ex 4.2: L4. -.2896628 .0892802 -3.24 0.001 -.4646488 -.1146769
Forecast
scenarios
Ex 4.3: /sigma .0070179 .0004398 15.96 0.000 .0061559 .0078799
Coefficient
Vector
Note: The test of the variance against zero is one sided, and the two-sided
Questions? confidence interval is truncated at zero.
. estimates store eq_ar1

Gustavo Sanchez (StataCorp) May 3, 2013 15 / 33


Forecasting
tools in Stata Example 3.1: Systems of equations (VAR) and ARIMA
Gustavo
Sanchez Create and solve the model
Outline . forecast create myfcst3
Forecast model myfcst3 started.
Solving
models . forecast estimates eq_var
Added estimation results from var.
Subcommands Forecast model myfcst3 now contains 2 endogenous variables.
Examples with . forecast estimates eq_ar1
Time Series Added estimation results from arima.
Ex 1: regress Forecast model myfcst3 now contains 3 endogenous variables.
Ex 2: TS
operators and .
identities . forecast solve, begin(tq(2010q1)) prefix(f3_)
Ex 3: VAR -
ARIMA Computing dynamic forecasts for model myfcst3.
Examples with
Panel Data Starting period: 2010q1
Ex 4: Panel data Ending period: 2011q2
Ex 4.1: Forecast prefix: f3_
xtreg xtabond
Ex 4.2: 2010q1: ...............
Forecast 2010q2: ..............
scenarios
Ex 4.3:
2010q3: ...............
Coefficient 2010q4: ..............
Vector
2011q1: ..............
Questions? 2011q2: .............
Forecast 3 variables spanning 6 periods.

Gustavo Sanchez (StataCorp) May 3, 2013 16 / 33


Forecasting
tools in Stata

Gustavo Example 3.1: Systems of equations (VAR) and ARIMA


Sanchez

Outline

Solving
models

Subcommands

Examples with
Time Series
Ex 1: regress
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA

Examples with
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 17 / 33


Forecasting
tools in Stata

Gustavo
Sanchez
Example 3.2: Simulations
Outline
Solve model (dlpib, dlxt, dlipex) including simulations
Solving . forecast solve, begin(tq(2010q1)) prefix(fs_) log(off) ///
models > simulate(betas, statistic(stddev, prefix(sd_)) reps(100))
Subcommands Computing dynamic forecasts for model myfcst3.

Examples with Starting period: 2010q1


Time Series Ending period: 2011q2
Ex 1: regress Forecast prefix: fs_
Ex 2: TS
operators and Performing simulations (100)
identities
Ex 3: VAR -
1 2 3 4 5
ARIMA .................................................. 50
.................................................. 100
Examples with
Panel Data Forecast 3 variables spanning 6 periods.
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Compute limits for confidence intervals
Forecast
scenarios . foreach x of varlist dlpib dlxt dlipex {
Ex 4.3: 2. quietly gen fs_`x_ul = fs_`x + invnormal(0.975)*sd_`x
Coefficient
Vector 3. quietly gen fs_`x_ll = fs_`x + invnormal(0.025)*sd_`x
Questions? 4. }

Gustavo Sanchez (StataCorp) May 3, 2013 18 / 33


Forecasting
tools in Stata

Gustavo
Sanchez
Example 3.2: Simulations
Outline
Solve model (dlpib, dlxt, dlipex) including simulations
Solving . forecast solve, begin(tq(2010q1)) prefix(fs_) log(off) ///
models > simulate(betas, statistic(stddev, prefix(sd_)) reps(100))
Subcommands Computing dynamic forecasts for model myfcst3.

Examples with Starting period: 2010q1


Time Series Ending period: 2011q2
Ex 1: regress Forecast prefix: fs_
Ex 2: TS
operators and Performing simulations (100)
identities
Ex 3: VAR -
1 2 3 4 5
ARIMA .................................................. 50
.................................................. 100
Examples with
Panel Data Forecast 3 variables spanning 6 periods.
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Compute limits for confidence intervals
Forecast
scenarios . foreach x of varlist dlpib dlxt dlipex {
Ex 4.3: 2. quietly gen fs_`x_ul = fs_`x + invnormal(0.975)*sd_`x
Coefficient
Vector 3. quietly gen fs_`x_ll = fs_`x + invnormal(0.025)*sd_`x
Questions? 4. }

Gustavo Sanchez (StataCorp) May 3, 2013 18 / 33


Forecasting
tools in Stata

Gustavo
Sanchez
Example 3.2: Simulations
Outline
Solve model (dlpib, dlxt, dlipex) including simulations
Solving . forecast solve, begin(tq(2010q1)) prefix(fs_) log(off) ///
models > simulate(betas, statistic(stddev, prefix(sd_)) reps(100))
Subcommands Computing dynamic forecasts for model myfcst3.

Examples with Starting period: 2010q1


Time Series Ending period: 2011q2
Ex 1: regress Forecast prefix: fs_
Ex 2: TS
operators and Performing simulations (100)
identities
Ex 3: VAR -
1 2 3 4 5
ARIMA .................................................. 50
.................................................. 100
Examples with
Panel Data Forecast 3 variables spanning 6 periods.
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Compute limits for confidence intervals
Forecast
scenarios . foreach x of varlist dlpib dlxt dlipex {
Ex 4.3: 2. quietly gen fs_`x_ul = fs_`x + invnormal(0.975)*sd_`x
Coefficient
Vector 3. quietly gen fs_`x_ll = fs_`x + invnormal(0.025)*sd_`x
Questions? 4. }

Gustavo Sanchez (StataCorp) May 3, 2013 18 / 33


Forecasting
tools in Stata
Example 3.2: Simulations
Gustavo
Sanchez
Confidence intervals based on simulations
Outline

Solving
models

Subcommands

Examples with
Time Series
Ex 1: regress
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA

Examples with
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 19 / 33


Forecasting
tools in Stata

Gustavo
Sanchez

Outline

Solving
models

Subcommands

Examples with
Time Series
Ex 1: regress Examples with Panel Data
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA

Examples with
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 20 / 33


Forecasting
tools in Stata

Gustavo
Sanchez
Examples with Panel data
Outline Model for aggregate consumption
Solving
models consumoit = +pibit 1 +pibit1 2 +irateit 3 +i +it
Subcommands

Examples with Data


Time Series
Ex 1: regress World Bank public online data on:
Ex 2: TS
operators and
identities consumo: Final consumption expenditure (Y2000=100)
Ex 3: VAR -
ARIMA pib: Gross domestic product (Y2000=100)
Examples with irate deposit interest rate
Panel Data
Ex 4: Panel data Period: 2000-2010 for 112-116 countries :
Ex 4.1:
xtreg xtabond Source:http://databank.worldbank.org/data/Home.aspx
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 21 / 33


Forecasting
tools in Stata

Gustavo
Sanchez
Examples with Panel data
Outline Model for aggregate consumption
Solving
models consumoit = +pibit 1 +pibit1 2 +irateit 3 +i +it
Subcommands

Examples with Data


Time Series
Ex 1: regress World Bank public online data on:
Ex 2: TS
operators and
identities consumo: Final consumption expenditure (Y2000=100)
Ex 3: VAR -
ARIMA pib: Gross domestic product (Y2000=100)
Examples with irate deposit interest rate
Panel Data
Ex 4: Panel data Period: 2000-2010 for 112-116 countries :
Ex 4.1:
xtreg xtabond Source:http://databank.worldbank.org/data/Home.aspx
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 21 / 33


Forecasting
tools in Stata Example 4.1: xtreg xtabond
Gustavo
Sanchez Fixed effects model for consumption
Outline
. xtreg lconsumo L(0/1).lpib lirate if year<2007,fe vsquish
Solving
models Fixed-effects (within) regression Number of obs = 654
Group variable: country Number of groups = 116
Subcommands R-sq: within = 0.7738 Obs per group: min = 1
Examples with between = 0.9935 avg = 5.6
Time Series overall = 0.9924 max = 6
Ex 1: regress F(3,535) = 610.19
Ex 2: TS corr(u_i, Xb) = 0.7688 Prob > F = 0.0000
operators and
identities
Ex 3: VAR -
ARIMA lconsumo Coef. Std. Err. t P>|t| [95% Conf. Interval]
Examples with
lpib
Panel Data
--. .7191382 .0751612 9.57 0.000 .571491 .8667855
Ex 4: Panel data
Ex 4.1:
L1. .1410591 .0815228 1.73 0.084 -.0190849 .301203
xtreg xtabond lirate -.0138219 .0052345 -2.64 0.009 -.0241045 -.0035393
Ex 4.2: _cons 3.137966 .5386802 5.83 0.000 2.079778 4.196153
Forecast
scenarios
Ex 4.3: sigma_u .2614921
Coefficient
Vector sigma_e .05014561
rho .96452975 (fraction of variance due to u_i)
Questions?
F test that all u_i=0: F(115, 535) = 55.01 Prob > F = 0.0000
. estimates store eq_con

Gustavo Sanchez (StataCorp) May 3, 2013 22 / 33


Forecasting
tools in Stata Example 4.1: xtreg xtabond
Gustavo
Sanchez Fixed effects model for consumption
Outline
. xtreg lconsumo L(0/1).lpib lirate if year<2007,fe vsquish
Solving
models Fixed-effects (within) regression Number of obs = 654
Group variable: country Number of groups = 116
Subcommands R-sq: within = 0.7738 Obs per group: min = 1
Examples with between = 0.9935 avg = 5.6
Time Series overall = 0.9924 max = 6
Ex 1: regress F(3,535) = 610.19
Ex 2: TS corr(u_i, Xb) = 0.7688 Prob > F = 0.0000
operators and
identities
Ex 3: VAR -
ARIMA lconsumo Coef. Std. Err. t P>|t| [95% Conf. Interval]
Examples with
lpib
Panel Data
--. .7191382 .0751612 9.57 0.000 .571491 .8667855
Ex 4: Panel data
Ex 4.1:
L1. .1410591 .0815228 1.73 0.084 -.0190849 .301203
xtreg xtabond lirate -.0138219 .0052345 -2.64 0.009 -.0241045 -.0035393
Ex 4.2: _cons 3.137966 .5386802 5.83 0.000 2.079778 4.196153
Forecast
scenarios
Ex 4.3: sigma_u .2614921
Coefficient
Vector sigma_e .05014561
rho .96452975 (fraction of variance due to u_i)
Questions?
F test that all u_i=0: F(115, 535) = 55.01 Prob > F = 0.0000
. estimates store eq_con

Gustavo Sanchez (StataCorp) May 3, 2013 22 / 33


Forecasting
tools in Stata Example 4.1: xtreg xtabond
Gustavo
Sanchez Dynamic model for GDP
Outline
. xtabond lpib trend if year<2007,lags(1) vsquish
Solving Arellano-Bond dynamic panel-data estimation Number of obs = 538
models Group variable: country Number of groups = 115
Subcommands Time variable: year
Obs per group: min = 1
Examples with avg = 4.678261
Time Series max = 5
Ex 1: regress
Ex 2: TS Number of instruments = 17 Wald chi2(2) = 7682.64
operators and Prob > chi2 = 0.0000
identities
Ex 3: VAR -
One-step results
ARIMA

Examples with
lpib Coef. Std. Err. z P>|z| [95% Conf. Interval]
Panel Data
Ex 4: Panel data lpib
Ex 4.1: L1. .8500304 .038387 22.14 0.000 .7747932 .9252675
xtreg xtabond trend .0125958 .0017827 7.07 0.000 .0091019 .0160897
Ex 4.2:
Forecast _cons 3.549008 .9035604 3.93 0.000 1.778062 5.319954
scenarios
Ex 4.3:
Coefficient Instruments for differenced equation
Vector GMM-type: L(2/.).lpib
Questions? Standard: D.trend
Instruments for level equation
Standard: _cons
. estimates store eq_lpib

Gustavo Sanchez (StataCorp) May 3, 2013 23 / 33


Forecasting
tools in Stata Example 4.1: xtreg xtabond
Gustavo
Sanchez
Dynamic model for interest rate
Outline
. xtabond lirate if year<2007,lags(2) vsquish
Solving
models Arellano-Bond dynamic panel-data estimation Number of obs = 423
Group variable: country Number of groups = 112
Subcommands Time variable: year
Examples with Obs per group: min = 1
Time Series avg = 3.776786
Ex 1: regress max = 4
Ex 2: TS Number of instruments = 15 Wald chi2(2) = 211.52
operators and
identities Prob > chi2 = 0.0000
Ex 3: VAR - One-step results
ARIMA

Examples with lirate Coef. Std. Err. z P>|z| [95% Conf. Interval]
Panel Data
Ex 4: Panel data lirate
Ex 4.1:
xtreg xtabond L1. .8837478 .0643112 13.74 0.000 .7577002 1.009795
Ex 4.2: L2. -.4333317 .044075 -9.83 0.000 -.519717 -.3469463
Forecast _cons .8355917 .099475 8.40 0.000 .6406244 1.030559
scenarios
Ex 4.3:
Coefficient Instruments for differenced equation
Vector
GMM-type: L(2/.).lirate
Questions? Instruments for level equation
Standard: _cons
. estimates store eq_lirate

Gustavo Sanchez (StataCorp) May 3, 2013 24 / 33


Forecasting
tools in Stata

Gustavo
Example 4.1: xtreg xtabond
Sanchez
Create and solve the model
Outline
. quietly forecast create xtfcst
Solving
models
. quietly forecast estimates eq_con
. forecast estimates eq_lpib
Subcommands forecast will use the default type of prediction for xtabond. Verify this
Examples with is appropriate; see xtabond postestimation. Use the predict() option with
Time Series forecast estimates to override the default.
Ex 1: regress Added estimation results from xtabond.
Ex 2: TS Forecast model xtfcst now contains 2 endogenous variables.
operators and
identities
Ex 3: VAR -
ARIMA . forecast estimates eq_lirate
forecast will use the default type of prediction for xtabond. Verify this
Examples with
Panel Data
is appropriate; see xtabond postestimation. Use the predict() option with
Ex 4: Panel data
forecast estimates to override the default.
Ex 4.1: Added estimation results from xtabond.
xtreg xtabond
Ex 4.2:
Forecast model xtfcst now contains 3 endogenous variables.
Forecast
scenarios
Ex 4.3: . capture noisily forecast solve
Coefficient must have strongly balanced panel data
Vector

Questions?
Oops! Unbalanced panels... Use tsfill

Gustavo Sanchez (StataCorp) May 3, 2013 25 / 33


Forecasting
tools in Stata

Gustavo
Example 4.1: xtreg xtabond
Sanchez
Create and solve the model
Outline
. quietly forecast create xtfcst
Solving
models
. quietly forecast estimates eq_con
. forecast estimates eq_lpib
Subcommands forecast will use the default type of prediction for xtabond. Verify this
Examples with is appropriate; see xtabond postestimation. Use the predict() option with
Time Series forecast estimates to override the default.
Ex 1: regress Added estimation results from xtabond.
Ex 2: TS Forecast model xtfcst now contains 2 endogenous variables.
operators and
identities
Ex 3: VAR -
ARIMA . forecast estimates eq_lirate
forecast will use the default type of prediction for xtabond. Verify this
Examples with
Panel Data
is appropriate; see xtabond postestimation. Use the predict() option with
Ex 4: Panel data
forecast estimates to override the default.
Ex 4.1: Added estimation results from xtabond.
xtreg xtabond
Ex 4.2:
Forecast model xtfcst now contains 3 endogenous variables.
Forecast
scenarios
Ex 4.3: . capture noisily forecast solve
Coefficient must have strongly balanced panel data
Vector

Questions?
Oops! Unbalanced panels... Use tsfill

Gustavo Sanchez (StataCorp) May 3, 2013 25 / 33


Forecasting
tools in Stata

Gustavo
Example 4.1: xtreg xtabond
Sanchez
Create and solve the model
Outline
. quietly forecast create xtfcst
Solving
models
. quietly forecast estimates eq_con
. forecast estimates eq_lpib
Subcommands forecast will use the default type of prediction for xtabond. Verify this
Examples with is appropriate; see xtabond postestimation. Use the predict() option with
Time Series forecast estimates to override the default.
Ex 1: regress Added estimation results from xtabond.
Ex 2: TS Forecast model xtfcst now contains 2 endogenous variables.
operators and
identities
Ex 3: VAR -
ARIMA . forecast estimates eq_lirate
forecast will use the default type of prediction for xtabond. Verify this
Examples with
Panel Data
is appropriate; see xtabond postestimation. Use the predict() option with
Ex 4: Panel data
forecast estimates to override the default.
Ex 4.1: Added estimation results from xtabond.
xtreg xtabond
Ex 4.2:
Forecast model xtfcst now contains 3 endogenous variables.
Forecast
scenarios
Ex 4.3: . capture noisily forecast solve
Coefficient must have strongly balanced panel data
Vector

Questions?
Oops! Unbalanced panels... Use tsfill

Gustavo Sanchez (StataCorp) May 3, 2013 25 / 33


Forecasting
tools in Stata

Gustavo
Example 4.1: xtreg xtabond
Sanchez
Create and solve the model
Outline
. quietly forecast create xtfcst
Solving
models
. quietly forecast estimates eq_con
. forecast estimates eq_lpib
Subcommands forecast will use the default type of prediction for xtabond. Verify this
Examples with is appropriate; see xtabond postestimation. Use the predict() option with
Time Series forecast estimates to override the default.
Ex 1: regress Added estimation results from xtabond.
Ex 2: TS Forecast model xtfcst now contains 2 endogenous variables.
operators and
identities
Ex 3: VAR -
ARIMA . forecast estimates eq_lirate
forecast will use the default type of prediction for xtabond. Verify this
Examples with
Panel Data
is appropriate; see xtabond postestimation. Use the predict() option with
Ex 4: Panel data
forecast estimates to override the default.
Ex 4.1: Added estimation results from xtabond.
xtreg xtabond
Ex 4.2:
Forecast model xtfcst now contains 3 endogenous variables.
Forecast
scenarios
Ex 4.3: . capture noisily forecast solve
Coefficient must have strongly balanced panel data
Vector

Questions?
Oops! Unbalanced panels... Use tsfill

Gustavo Sanchez (StataCorp) May 3, 2013 25 / 33


Forecasting
tools in Stata Example 4.1: xtreg xtabond
Gustavo
Sanchez
Create and solve the model
. tsfill,full
Outline

Solving
models . capture noisily forecast solve, begin(2007) end(2009)
Computing dynamic forecasts for model xtfcst.
Subcommands

Examples with Starting period: 2007


Time Series Ending period: 2009
Ex 1: regress Number of panels: 117
Ex 2: TS Forecast prefix: f_
operators and
identities Solving panel 1
Ex 3: VAR - Solving panel 2
ARIMA
Solving panel 3
Examples with Solving panel 4
Panel Data Solving panel 5
Ex 4: Panel data
Solving panel 6
Ex 4.1:
xtreg xtabond Solving panel 7
Ex 4.2: Solving panel 8
Forecast
scenarios Solving panel 9
Ex 4.3: missing values encountered
Coefficient
Vector Missing values were encountered while attempting to solve the model at
time 2009 in panel 18. Variable lpib evaluates to missing.
Questions?

Oops! missing data... Drop panels with missing data


Gustavo Sanchez (StataCorp) May 3, 2013 26 / 33
Forecasting
tools in Stata Example 4.1: xtreg xtabond
Gustavo
Sanchez
Create and solve the model
. tsfill,full
Outline

Solving
models . capture noisily forecast solve, begin(2007) end(2009)
Computing dynamic forecasts for model xtfcst.
Subcommands

Examples with Starting period: 2007


Time Series Ending period: 2009
Ex 1: regress Number of panels: 117
Ex 2: TS Forecast prefix: f_
operators and
identities Solving panel 1
Ex 3: VAR - Solving panel 2
ARIMA
Solving panel 3
Examples with Solving panel 4
Panel Data Solving panel 5
Ex 4: Panel data
Solving panel 6
Ex 4.1:
xtreg xtabond Solving panel 7
Ex 4.2: Solving panel 8
Forecast
scenarios Solving panel 9
Ex 4.3: missing values encountered
Coefficient
Vector Missing values were encountered while attempting to solve the model at
time 2009 in panel 18. Variable lpib evaluates to missing.
Questions?

Oops! missing data... Drop panels with missing data


Gustavo Sanchez (StataCorp) May 3, 2013 26 / 33
Forecasting
tools in Stata

Gustavo
Sanchez Example 4.1: xtreg xtabond
Outline Keep panels with full (required) data for forecast period
Solving
. /* Balanced panels for forecasting period
models
> egen nomiss=rownonmiss(lconsumo lpib lirate)
Subcommands > by country: generate mycount=nomiss==3 if year>=2005
> keep if mycount==1
Examples with > xtset country year
Time Series
> keep country year consumo pib irate lconsumo lpib lirate trend
Ex 1: regress
Ex 2: TS
> by country:keep if _N==6
operators and > xtset country year
identities
Ex 3: VAR -
> */
ARIMA

Examples with . forecast solve, begin(2007) end(2010) log(off)


Panel Data Computing dynamic forecasts for model xtfcst.
Ex 4: Panel data
Ex 4.1:
xtreg xtabond Starting period: 2007
Ex 4.2: Ending period: 2010
Forecast
scenarios Number of panels: 78
Ex 4.3: Forecast prefix: f_
Coefficient
Vector Forecast 3 variables spanning 4 periods for 78 panels.
Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 27 / 33


Forecasting
tools in Stata

Gustavo
Sanchez Example 4.1: xtreg xtabond
Outline Keep panels with full (required) data for forecast period
Solving
. /* Balanced panels for forecasting period
models
> egen nomiss=rownonmiss(lconsumo lpib lirate)
Subcommands > by country: generate mycount=nomiss==3 if year>=2005
> keep if mycount==1
Examples with > xtset country year
Time Series
> keep country year consumo pib irate lconsumo lpib lirate trend
Ex 1: regress
Ex 2: TS
> by country:keep if _N==6
operators and > xtset country year
identities
Ex 3: VAR -
> */
ARIMA

Examples with . forecast solve, begin(2007) end(2010) log(off)


Panel Data Computing dynamic forecasts for model xtfcst.
Ex 4: Panel data
Ex 4.1:
xtreg xtabond Starting period: 2007
Ex 4.2: Ending period: 2010
Forecast
scenarios Number of panels: 78
Ex 4.3: Forecast prefix: f_
Coefficient
Vector Forecast 3 variables spanning 4 periods for 78 panels.
Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 27 / 33


Forecasting
tools in Stata

Gustavo Example 4.1: xtreg xtabond


Sanchez

Outline

Solving
models

Subcommands

Examples with
Time Series
Ex 1: regress
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA

Examples with
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 28 / 33


Forecasting
tools in Stata Example 4.2: Panel Data - Forecast scenarios
Gustavo
Sanchez Scenarios for GDP (PIB) and interest rate
Outline . forecast adjust lpib = ln(pib*1.2) if tin(2007,2008) ///
> & (country==146 | country==241)
Solving Endogenous variable lpib now has 1 adjustment.
models
. forecast adjust lpib = ln(pib*.8) if tin(2007,2008) ///
Subcommands > & (country==9 | country==44)
Examples with
Endogenous variable lpib now has 2 adjustments.
Time Series
Ex 1: regress . forecast adjust lirate = ln(irate-3) if tin(2007,2010) ///
Ex 2: TS
operators and > & (country==9 | country==44 | country==241)
identities Endogenous variable lirate now has 1 adjustment.
Ex 3: VAR -
ARIMA . forecast adjust lirate = ln(irate-1) if tin(2007,2010) ///
> & country==146
Examples with
Panel Data Endogenous variable lirate now has 2 adjustments.
Ex 4: Panel data
Ex 4.1: . forecast solve, begin(2007) end(2010) log(off) prefix(fa_)
xtreg xtabond
Ex 4.2: Computing dynamic forecasts for model xtfcst.
Forecast
scenarios
Ex 4.3: Starting period: 2007
Coefficient Ending period: 2010
Vector
Number of panels: 78
Questions? Forecast prefix: fa_
Forecast 3 variables spanning 4 periods for 78 panels.

Gustavo Sanchez (StataCorp) May 3, 2013 29 / 33


Forecasting
tools in Stata Example 4.2: Panel Data - Forecast scenarios
Gustavo
Sanchez Scenarios for GDP (PIB) and interest rate
Outline . forecast adjust lpib = ln(pib*1.2) if tin(2007,2008) ///
> & (country==146 | country==241)
Solving Endogenous variable lpib now has 1 adjustment.
models
. forecast adjust lpib = ln(pib*.8) if tin(2007,2008) ///
Subcommands > & (country==9 | country==44)
Examples with
Endogenous variable lpib now has 2 adjustments.
Time Series
Ex 1: regress . forecast adjust lirate = ln(irate-3) if tin(2007,2010) ///
Ex 2: TS
operators and > & (country==9 | country==44 | country==241)
identities Endogenous variable lirate now has 1 adjustment.
Ex 3: VAR -
ARIMA . forecast adjust lirate = ln(irate-1) if tin(2007,2010) ///
> & country==146
Examples with
Panel Data Endogenous variable lirate now has 2 adjustments.
Ex 4: Panel data
Ex 4.1: . forecast solve, begin(2007) end(2010) log(off) prefix(fa_)
xtreg xtabond
Ex 4.2: Computing dynamic forecasts for model xtfcst.
Forecast
scenarios
Ex 4.3: Starting period: 2007
Coefficient Ending period: 2010
Vector
Number of panels: 78
Questions? Forecast prefix: fa_
Forecast 3 variables spanning 4 periods for 78 panels.

Gustavo Sanchez (StataCorp) May 3, 2013 29 / 33


Forecasting
tools in Stata Example 4.2: Panel Data - Forecast scenarios
Gustavo
Sanchez Scenarios for GDP (PIB) and interest rate
Outline . forecast adjust lpib = ln(pib*1.2) if tin(2007,2008) ///
> & (country==146 | country==241)
Solving Endogenous variable lpib now has 1 adjustment.
models
. forecast adjust lpib = ln(pib*.8) if tin(2007,2008) ///
Subcommands > & (country==9 | country==44)
Examples with
Endogenous variable lpib now has 2 adjustments.
Time Series
Ex 1: regress . forecast adjust lirate = ln(irate-3) if tin(2007,2010) ///
Ex 2: TS
operators and > & (country==9 | country==44 | country==241)
identities Endogenous variable lirate now has 1 adjustment.
Ex 3: VAR -
ARIMA . forecast adjust lirate = ln(irate-1) if tin(2007,2010) ///
> & country==146
Examples with
Panel Data Endogenous variable lirate now has 2 adjustments.
Ex 4: Panel data
Ex 4.1: . forecast solve, begin(2007) end(2010) log(off) prefix(fa_)
xtreg xtabond
Ex 4.2: Computing dynamic forecasts for model xtfcst.
Forecast
scenarios
Ex 4.3: Starting period: 2007
Coefficient Ending period: 2010
Vector
Number of panels: 78
Questions? Forecast prefix: fa_
Forecast 3 variables spanning 4 periods for 78 panels.

Gustavo Sanchez (StataCorp) May 3, 2013 29 / 33


Forecasting
tools in Stata

Gustavo Example 4.2: Panel Data - Forecast scenarios


Sanchez

Outline

Solving
models

Subcommands

Examples with
Time Series
Ex 1: regress
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA

Examples with
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 30 / 33


Forecasting
tools in Stata Example 4.3: Panel Data - Coefficient Vector
Gustavo
Sanchez Coefficient vector for lincome
Outline . matrix lincome = (.96, -.06, 2.6)
. matrix coleq lincome = lincome:L.lincome ///
Solving
> lincome:L2.lincome ///
models
> lincome:_cons
Subcommands . matrix list lincome
Examples with lincome[1,3]
Time Series lincome: lincome: lincome:
Ex 1: regress L. L2.
Ex 2: TS lincome lincome _cons
operators and
identities r1 .96 -.06 2.6
Ex 3: VAR -
ARIMA

Examples with . forecast coefvector lincome


Panel Data Forecast model xtfcst now contains 4 endogenous variables.
Ex 4: Panel data
Ex 4.1: . forecast solve, begin(2007) end(2010) prefix(fcv_) log(off)
xtreg xtabond
Ex 4.2: Computing dynamic forecasts for model xtfcst.
Forecast
scenarios
Ex 4.3: Starting period: 2007
Coefficient
Vector Ending period: 2010
Number of panels: 74
Questions? Forecast prefix: fcv_
Forecast 4 variables spanning 4 periods for 74 panels.

Gustavo Sanchez (StataCorp) May 3, 2013 31 / 33


Forecasting
tools in Stata Example 4.3: Panel Data - Coefficient Vector
Gustavo
Sanchez Coefficient vector for lincome
Outline . matrix lincome = (.96, -.06, 2.6)
. matrix coleq lincome = lincome:L.lincome ///
Solving
> lincome:L2.lincome ///
models
> lincome:_cons
Subcommands . matrix list lincome
Examples with lincome[1,3]
Time Series lincome: lincome: lincome:
Ex 1: regress L. L2.
Ex 2: TS lincome lincome _cons
operators and
identities r1 .96 -.06 2.6
Ex 3: VAR -
ARIMA

Examples with . forecast coefvector lincome


Panel Data Forecast model xtfcst now contains 4 endogenous variables.
Ex 4: Panel data
Ex 4.1: . forecast solve, begin(2007) end(2010) prefix(fcv_) log(off)
xtreg xtabond
Ex 4.2: Computing dynamic forecasts for model xtfcst.
Forecast
scenarios
Ex 4.3: Starting period: 2007
Coefficient
Vector Ending period: 2010
Number of panels: 74
Questions? Forecast prefix: fcv_
Forecast 4 variables spanning 4 periods for 74 panels.

Gustavo Sanchez (StataCorp) May 3, 2013 31 / 33


Forecasting
tools in Stata Example 4.3: Panel Data - Coefficient Vector
Gustavo
Sanchez Coefficient vector for lincome
Outline . matrix lincome = (.96, -.06, 2.6)
. matrix coleq lincome = lincome:L.lincome ///
Solving
> lincome:L2.lincome ///
models
> lincome:_cons
Subcommands . matrix list lincome
Examples with lincome[1,3]
Time Series lincome: lincome: lincome:
Ex 1: regress L. L2.
Ex 2: TS lincome lincome _cons
operators and
identities r1 .96 -.06 2.6
Ex 3: VAR -
ARIMA

Examples with . forecast coefvector lincome


Panel Data Forecast model xtfcst now contains 4 endogenous variables.
Ex 4: Panel data
Ex 4.1: . forecast solve, begin(2007) end(2010) prefix(fcv_) log(off)
xtreg xtabond
Ex 4.2: Computing dynamic forecasts for model xtfcst.
Forecast
scenarios
Ex 4.3: Starting period: 2007
Coefficient
Vector Ending period: 2010
Number of panels: 74
Questions? Forecast prefix: fcv_
Forecast 4 variables spanning 4 periods for 74 panels.

Gustavo Sanchez (StataCorp) May 3, 2013 31 / 33


Forecasting
tools in Stata

Gustavo
Example 4.3: Panel Data - Coefficient Vector
Sanchez
Coefficient vector for lincome
Outline

Solving
models

Subcommands

Examples with
Time Series
Ex 1: regress
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA

Examples with
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 32 / 33


Forecasting
tools in Stata

Gustavo
Sanchez

Outline

Solving
models

Subcommands

Examples with
Time Series
Ex 1: regress Questions?
Ex 2: TS
operators and
identities
Ex 3: VAR -
ARIMA

Examples with
Panel Data
Ex 4: Panel data
Ex 4.1:
xtreg xtabond
Ex 4.2:
Forecast
scenarios
Ex 4.3:
Coefficient
Vector

Questions?

Gustavo Sanchez (StataCorp) May 3, 2013 33 / 33