7/26/2019 Time Sereis Analysis Using Stata
1/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
TIME SEREIS ANALYSIS USING STATA
How to run regression using stata
Step #1:
Import data into STATA
Setp#2:
At first step, always set time otherwise u may get error, set time with the help of following
command
tsset years, yearly
step#3:
If u need to see summary of variables type in stata command bar
summarize CO2 GDP OIL fdi PP or simpley write sum (CO2 GDP OIL fdi PP
these are my variables)
For detail of data give this command
describe or list or br (these are three different commands)
step #4:
If u wishes to run correlation test then u may run by typing following command
correlate CO2 GDP OIL fdi
step#5:
If u wishes to run regression then u can with the help of following command
regress CO2 GDP OIL fdi {note: CO2 GDP OIL fdi are my variables first I
wrote my dependent variable then all Independent variables}
step#6
If u wants to check normality then u has to perform two steps after regression means runtwo commands consecutively
predict myResiduals, r sktest myResiduals
PLEASE DONT EDIT THIS FILE
OR MY NAME , THANKS. if you want tdownload this file search following link.
https://drive.google.com/open?
id=0B5lNKqneWZwhYWlUQy04NFRKNXc
7/26/2019 Time Sereis Analysis Using Stata
2/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
step#7
If u have run regression now, if u wish to check serial correlation then apply following
command
dwstat or estat bgodfrey
step#7
Suppose now u want to test heteroskedasticity
estat hettest, fstat or estat hettest
step#8
Suppose u now want to test multicollenearity
estat vif
Setep#8
Suppose now u want to see either model is miss specified or not /either we have omitted
variables or not/Ramsey RESET test
estat ovtest
Note all diagnostic tests can be run from post estimation option (statistics-----post
estimation)
How to test about structural breaks in data?
Statistics > Postestimation
Step#1
At first step run simple regression, normally we check structural break individually in each
variable, so run one by one regression like this, suppose I want to check structural breaks
in my dependent variable co2. So first I should run simple regression with only co2
regress co2
step#2
Now set time with following command
tsset year (if u have monthly data then write month )
step#3
Run following command to know about structural breaks.
7/26/2019 Time Sereis Analysis Using Stata
3/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
estat sbsingle
Few old commands with new names
Out-of-date commands
These commands continue to work but are out-of-date as of Stata 9. Their replacements
are
Old command New command
------------------------------
hettest estat hottest for HSK(HETEROSCADESTICITY)
imtest estat imtest (meron & Trivedi's decomposition of IM-test)ovtest estat ovtest (Ramsey RESET test using powers of the fitted values of CO2
Ho: model has no omitted variables)
szroeter estat szroeter
vif estat vif
------------------------------
See regress postestimation.
Old command New command
------------------------------
archlm estat archlm
bgodfrey estat bgodfreydurbina estat durbinalt (FOR SERIAL CORRELATION ALTERNATIVE TO
DURBINWATSON TEST)
dwstat estat dwatson (DURBINWATSON TEST FOR S.C)
------------------------------
How to run time series ARDL MODEL?
Step#1
Import data into stata
Step#2 set times first otherwise u will get error message for time write the following
command.(if u have annually data otherwise u can change frequency like monthly etc.
tsset years, yearly
7/26/2019 Time Sereis Analysis Using Stata
4/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Step#2 First install following package
net install ardl, from(http://www.kripfganz.de/stata/)
Write following command into command barardl P YU EX HE, lag(1 1 2 3) ec
(not p,yu ex and he I have my variable first p is dependent variable while remaining are
independent variables , further I have space between all variables, and after comma I have
also space and after bracket close I have also space good luck,,, lags 1,1,2,3 indicating for
dependent variable there must be one lag and after dependendent variable for the first
independent variable also must be lag 1 and so one )
Step#4
If u wants to conform long run relationship to the help of bound test then write following
command in command box.
estat btest
.
_cons 3314510 169730.1 19.53 0.000 2960459 3668561
L2D. .0003703 .0015138 0.24 0.809 -.0027874 .003528
LD. -.0027493 .002675 -1.03 0.316 -.0083294 .0028307
D1. -.0011703 .0065507 -0.18 0.860 -.0148348 .0124942 HE
LD. -.0002417 .0000773 -3.13 0.005 -.000403 -.0000804
D1. -.0001549 .0000722 -2.14 0.045 -.0003056 -4.17e-06
EX
D1. 30.83755 26.00734 1.19 0.250 -23.41281 85.08792
YU
SR
HE .6086697 1.082744 0.56 0.580 -1.649894 2.867234
EX .0646155 .0122439 5.28 0.000 .0390751 .0901558
YU 1797.459 14701.89 0.12 0.904 -28870.14 32465.06
LR
L1. -.0059958 .0017579 -3.41 0.003 -.0096627 -.0023289
P
ADJ
D.P Coef. Std. Err. t P>|t| [95% Conf. Interval]
Root MSE = 83070.046
Adj R-squared = .87452691
R-squared = .91635127
Log likelihood = -388.34477
Number of obs = 31
Sample: 1983 - 2013
Model: ec
ARDL regression
. ardl P YU EX HE, lag(1 1 2 3) ec
This is error
correction term
Long run results
Short run results
7/26/2019 Time Sereis Analysis Using Stata
5/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
second method of running ardl model
step#1 import data into STATA
Step#2ardl CO2 GDP OIL fdi , lags(. . . 3) maxlag(3 3 3 3) (note: here co2 is my dependent
variable while other are independent variables, while lags(. . . 3) is showing that for the
first three variables means one dependent and other two independent variables I am
saying to stata that ,its all up to stata ,program itself can select optimal lags but 3
indicating that for last independent variable Im limiting program that there must be lag 3
for last variable,maxlag (3 3 3 3) showing we can add maximum lags 3333 for all variables
but it is ignorable
Step#3
If want to see how stata chose optimal lags then run following command
matrix list e(lags)
step#4
Suppose now you want to see error correction term, long run as well as short run results
then apply follow owing command
ardl CO2 GDP OIL fdi , ec
now you want to see bound test,
estat btest
Third Method of running ARDL in STATA
Step#1 first of all install package again command is here
net install ardl, from(http://www.kripfganz.de/stata/)
Step#2 or search ARDL package through stata command box using
help ardl or findit ardl
Setp#3 here we are going to run simple ardl like in eviews we get ardl results before bounds
tests and long run and short run , run following command in comamd bar first write yourdependent variable then all independent variables
ardl co2 he pop , aic
Step#3 As before going to long run and short run we go for bound tests valuesto conform long run cointegration.
http://www.kripfganz.de/stata/http://www.kripfganz.de/stata/http://www.kripfganz.de/stata/http://www.kripfganz.de/stata/7/26/2019 Time Sereis Analysis Using Stata
6/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
ardl, noctable btest
Step#4 as in step 3 we conform about long run cointegration now we aregoing to run long run and short run results with error correction term(ADJ)
here first I wrote my dependent variables then all independent .
ardl co2 he pop , aic ec regstore(ecreg)
Step#5 as now we have generate all results but we have need now ofdiagnostic test for the store your step#4 results with this command estimates
restore ecreg
Step#6 after restoring your results in step 5 ,,, now run regres commandyou will see your step 4 results will appear and after this you may runfollowing diagnostic test,
Step#7 Frequently ask question about ARDL USING STATA , it is acknowledge that i havecopied this post from Aymen Ammaritime line
estat dwatson (Durbin Watson statistics, at 1st order autocorrelation).
estat archlm (ARCH LM test for higher order autocorrelation)
estat bgodfrey (Breusch Godfrey LM test for higher order autocorrelation)
estat hottest (Breusch Pagan Heteroscedasticity test)
estat ovtest (Ramsey RESET test)
estat vif (Test for the Multicollinearity)
And finally run after ARDL for the parameters stability .CUSUM TEST
Now If you want to run cusum test (parameters stability test) then run following command
first install this package ssc install cusum6 (note: internet is necessary forinstallation)
now type this command cusum6 variable1 variable2 variable3,cs(cusum) lw(lower)uw(upper)
How to select optimal lags
Statistics > Multivariate time series > VAR diagnostics and tests > Lag-order selection
statistics (preestimation)
Or select optimal lags through following command
varsoc LOGFDI LOGGDP LOGDD LOGINF LOGEXCHRT, maxlag(8)
7/26/2019 Time Sereis Analysis Using Stata
7/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
OrStep#1
Step#2
Exogenous: _cons
Endogenous: LOGFDIGDP LOGGDP LOGDD LOGINF LOGEXCHRT
8 3354.19 113.04* 25 0.000 . -294.927* -293.642* -289.471*
7 3297.68 -78.245 25 . . -289.789 -288.504 -284.333
6 3336.8 200.88 25 0.000 . -293.345 -292.06 -287.89
5 3236.36 3065.7 25 0.000 . -284.214 -282.929 -278.759
4 1703.49 3269.3 25 0.000 5.6e-66* -145.318 -144.091 -140.11
3 68.8475 169.66 25 0.000 .000013 1.01387 1.94847 4.98129
2 -15.9819 75.413 25 0.000 .000715 6.4529 7.09544 9.1805
1 -53.6883 224.04 25 0.000 .001488 7.60803 7.95851 9.09582
0 -165.706 3.77983 15.5187 15.5772 15.7667
lag LL LR df p FPE AIC HQIC SBIC
Sample: 1992 - 2013 Number of obs = 22
Selection-order criteria
. varsoc LOGFDIGDP LOGGDP LOGDD LOGINF LOGEXCHRT, maxlag(8)
delta: 1 year
time variable: year, 1984 to 2013
. tsset year, yearly
7/26/2019 Time Sereis Analysis Using Stata
8/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
How to test cointegration
Statistics > Multivariate time series > Cointegrating rank of a VECM
Step#1
Set time first otherwise u
may get error
Write ur all variables
Chose maximum lags
Normally use in between
5-10 and keep all thing
unchan ed
7/26/2019 Time Sereis Analysis Using Stata
9/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Step#2
Write ur variables, like first
dependent then all indep
Chose optimal lags, which u
deicide form lag length
criteria and ok
7/26/2019 Time Sereis Analysis Using Stata
10/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
How to run VECM MODEL?
Statistics > Multivariate time series > Vector error-correction model (VECM)
Step#1
Step#2
And ok
7/26/2019 Time Sereis Analysis Using Stata
11/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Step#3
Step#4
_cons -164710.4 57151.86 -2.88 0.004 -276726 -52694.85
L3D. .0005969 .0003585 1.67 0.096 -.0001057 .0012996
L2D. .0011455 .0005591 2.05 0.040 .0000496 .0022414
LD. .0032082 .0011028 2.91 0.004 .0010467 .0053698
HE
L3D. .0000111 9.78e-06 1.13 0.257 -8.09e-06 .0000303
L2D. -1.80e-06 9.17e-06 -0.20 0.845 -.0000198 .0000162
LD. -4.32e-06 9.15e-06 -0.47 0.637 -.0000222 .0000136
EX
L3D. -2.692897 1.817526 -1.48 0.138 -6.255183 .8693891
L2D. -10.78266 4.202071 -2.57 0.010 -19.01857 -2.546755
LD. -17.44365 6.310434 -2.76 0.006 -29.81187 -5.075422
YU
L3D. 1.00195 .1026645 9.76 0.000 .8007314 1.203169
L2D. -2.631597 .1808343 -14.55 0.000 -2.986025 -2.277168
LD. 2.641314 .0914989 28.87 0.000 2.46198 2.820649
P
L1. -.0002116 .0000693 -3.05 0.002 -.0003474 -.0000758
_ce1
D_P
Coef. Std. Err. z P>|z| [95% Conf. Interval]
Write your variabels,firstdependent then all
independent variables
Write here number of
cointegration
equations which u finds
from Johansson test
but I would like to
suggest u add all the
time 1 for simplisticity
Add here
maximum
lags or
optimal
Long run causality value must be
negative and in between 0-
1..which indicate error
correction term ,speed of
adjustment
Short run causality
7/26/2019 Time Sereis Analysis Using Stata
12/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Wald test for short run causalities if you want to see jointly impact of lags variabels on
dependent variables
Go to statistics----post estimation---test, contrast, and comparison of parameters,---linear
test of parameters
How to run IMPULSE RESPONSE FUNTION
If u want to run through MANU,, follow these steps
Statistics > Multivariate time series > IRF and FEVD analysis > Graphs by impulse or
response
Step#1 (actually impulse response functions used after VAR models)
Run VECM model
Step#2
Then use irf create to estimate the IRFs and FEVDs and save them in a file, and finally use irf
graph or any of the other irf analysis commands to examine results:, like run following command
irf create order1, step(10) set(myirf1)
Step#3 now I want to see impulse response function, the following function will show over all
impulse response function results
irf graph irf, irf(order1)
step#4
suppose you are not interest in all variables response function ,I mean to say I just want to see
only independent variables shocks effect on dependent then apply following command.
irf graph irf, irf(order1) impulse(GDP OIL fdi) response(CO2) (note here GDP,OIL and fdi
are my independent variables and co2 dependent .
How to run var model?
Statistics > Multivariate time series > Vector autoregression (VAR)
Step#1
7/26/2019 Time Sereis Analysis Using Stata
13/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Step#2
7/26/2019 Time Sereis Analysis Using Stata
14/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Step#3
Step#4 for short run granger causality/wald test
Statistics > Multivariate time series > VAR diagnostics and tests > Granger causality tests
_cons 477355 214606.1 2.22 0.026 56734.76 897975.3
L2. -.0078436 .0040739 -1.93 0.054 -.0158283 .000141
L1. -.0013774 .0007436 -1.85 0.064 -.0028348 .00008
HE
L2. -13216.11 7908.145 -1.67 0.095 -28715.79 2283.57
L1. 10483.9 7579.004 1.38 0.167 -4370.678 25338.47
HDI
L2. .0000507 .0000366 1.39 0.166 -.000021 .0001223
L1. .0000743 .0000315 2.36 0.018 .0000125 .000136
EX
L2. .6010501 6.50086 0.09 0.926 -12.1404 13.3425
L1. 4.900434 11.82905 0.41 0.679 -18.28407 28.08494
YU
L2. -.8601668 .0746806 -11.52 0.000 -1.006538 -.7137955
L1. 1.859308 .0743769 25.00 0.000 1.713532 2.005084
P
P
Coef. Std. Err. z P>|z| [95% Conf. Interval]
HE 11 9.9e+06 0.3616 18.12447 0.0529
HDI 11 1.01628 0.9989 6665.462 0.0000
EX 11 2.3e+08 0.9691 1003.692 0.0000
YU 11 580.764 0.7792 112.9032 0.0000
P 11 43425.6 1.0000 2.14e+07 0.0000
Equation Parms RMSE R-sq chi2 P>chi2
7/26/2019 Time Sereis Analysis Using Stata
15/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Setp#
U have no need to
change anything just
click ok
7/26/2019 Time Sereis Analysis Using Stata
16/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Step#6 and finally granger causality test
Panel data ModelsHow to take panel unit root
Statistics > Longitudinal/panel data > Li near models > Linear regression (F E, RE, PA, BE)
Setep#1
Give fi rst id with following command..
egen countr y1=group( country) (note: i f you have countr ies data)
egen Company1=group( Company) (note: i f you have companies data) means declare data
panel
HDI ALL 1346.5 8 0.000
HDI HE 1042.9 2 0.000
HDI EX 7.3963 2 0.025
HDI YU 3.519 2 0.172
HDI P 12.807 2 0.002
EX ALL 15.527 8 0.050
EX HE 5.1576 2 0.076
EX HDI 4.4102 2 0.110
EX YU 1.4657 2 0.481
EX P 8.7329 2 0.013
YU ALL 93.069 8 0.000
YU HE 51.299 2 0.000
YU HDI 3.3333 2 0.189
YU EX 8.8705 2 0.012
YU P 9.9949 2 0.007
P ALL 40.749 8 0.000
P HE 5.7897 2 0.055
P HDI 5.4149 2 0.067
P EX 21.011 2 0.000
P YU .17274 2 0.917
Equation Excluded chi2 df Prob > chi2
Granger causality Wald tests
. vargranger
Here results showing that P is
dependent variables while YU,EX, HDI
ETC INDEPENDNET VARIAELS,
IN THE SECOND ROW OF RIGTHT SIDE
FIRST COLUM, SHOWING THT EX
JOINTLY GRANGER CUSE P IN SHORT
RUN . AS NULL HYPOTHESIS WAS NO
GRANGER CASUE AS PROBABLITY VALUE
IS LEST THAN 5% SO I CAN SAY HERE
THAT I HAVE TO ACCEPT ALTERNATIVE
HYPOTHESIS
7/26/2019 Time Sereis Analysis Using Stata
17/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Step#2
Click on unit root test
Select test type
Select variables to which u
want to take unit root
Set time and give panel
id to cross sections
Select optimal lags ,suppose
one
Select if u
need
suppose u
want to add
time trend
the check
first option
7/26/2019 Time Sereis Analysis Using Stata
18/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Panel data analysis from star t to end..
Poll ed, random ,f ixed effect ,hausman test.
1.import your data fi le into stata
2.now create a pool or simple stata give codes to each cross section or enti ty l ike if you have
dif ferent countr ies data or companies the u have to give specif ic code all countr ies or
companies, fu rther i f you have assign code by your self suppose u did not wr i te company name
like nestles but you indicated nestle with 111 now u see you have already given the code but
i f you have simple right the name of company then u need to give also code
egen countr y1=group( country) (note: i f you have countr ies data)
egen Company1=group( Company) (note: if you have companies data)
3.now set time which is most important
xtset Company1 year, yearly (note: hear I have yearl y data and company1 is new variable
which I genrate in step 2)
4.now look at descri ptive statistics
Xtsum variable1 variabel2
xtsum ENVC EPS ROA ROE ROC
4.1 suppose u want to make a graph
xtline CO2 energy gdp gi
4.2 for description of data
xtdescribe
5. Now run fixed effect model
Xtreg dependent variable1 independent variable 1234456,fe
xtreg ENVC EPS ROA ROE,fe
Now store result of fixed effect from this command
6.estimate store fe ( if u want to run by Manu Statistics > Postestimation )
7. Now run random effect model
xtreg dep indep1 indep2 indep3, re (replace with your variables name)
7/26/2019 Time Sereis Analysis Using Stata
19/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
now store result of fixed effect from this command
8. estimate store re
9. now the last thing what model is suitable random effect or fixed effect for this run Housman
test(note if you do not restore results of random effect and fixed effect may u face error prob)
hausman fe re
how to run pooled regression in stata
reg dep indep indep
10. Further u can double check either random /fixed effect /or polled appropriate. But note,
suppose hausaman verified random effect is appropriate, so we can double check for step 9,
suppose hausman test verified random effect model is appropriates so in step ten we willconform either really random effect is appropriate or not so we will run test and verify
hypothesis between polled model and random effect actually we have already done with fixedeffect using hausman test.stepsstatisticslongitudinal /panel data---linear model---
langrangian multiplier and null hypothesis is polled is appropriate. And alternative hypothesis is
random effect is appropriate.
How to run 2sls two stage least squareStatistics > Endogenous covariates > Single-equation instrumental-variables regression
Step#1
ivregress 2sls consumtion remetence (income = investment)
(note here income is my endogenous and investment instrumental is my instrumental
variables)
Step#2
As I have run 2sls model but now I have to conform that either in reality really endogeniety
problem was exist or not
estat endog
if probability value comes more than 5% then we say there is no endogeniety but if prob valuecomes less than in this case we say there is endogeniety prob,, which is desirable;
setp#3
Now I have I have conform either endogeniety problem exist or not now I want to know either
my instruments are weak or strong
estat firststage
7/26/2019 Time Sereis Analysis Using Stata
20/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
step#4
Now I want to know either my instruments are over identified or not?
estat overid{ sargan and basman test is used to know about the over identification if probability value
comes of thesis test more than5% we say model is correct specified
Null hypothesis for over identified instruments: instrument set is valid and the model is correct
specified}
PANEL ARDL USING STATA
1) First of all install this package to run PANEL ARDL ssc install xtpmg, replace
2) Suppose you think you have installed this package but still you are not sure then type incommand bar type xtpmg
3) If u see message of no found then install otherwise you have already install it. here we shall Run MG (average):
xtpmg d.CO2 d.energy d.gdp , lr(l.CO2 energy gdp ) ec(ECT) replace mg
here we shall Run MG (individual):
(It allows for all coefficients to vary and be heterogeneous in the long-run and short-run.However, the necessary condition for the consistency and validity of this approach is to
have a sufficiently large time-series dimension of the data.)
xtpmg d.CO2 d.energy d.gdp , lr(l.CO2 energy gdp ) ec(ECT) replace full mg
here we shall Run PMG (average):
xtpmg d.CO2 d.energy d.gdp , lr(l.CO2 energy gdp ) ec(ECT) replace pmg here we shall Run PMG (individual):
(The main characteristic of PMG is that it allows short-run coefficients, including theintercepts, the speed of adjustment to the long-run equilibrium values, and error
variances to be heterogeneous country by country, while the long-run slope coefficients
are restricted to be homogeneous across countries.)
xtpmg d.CO2 d.energy d.gdp , lr(l.CO2 energy gdp ) ec(ECT) replace full pmg
here we shall Run Hausman test to choose between MG and PMG:hausman mg pmg, sigmamorenow if our probability value comes more than 5% we run PMG
if our probability value comes less than 5% we run MG
Running DFE:xtpmg d.CO2 d.energy d.gdp , lr(l.CO2 energy gdp ) ec(ECT) replace dfe
* Running Hausman test to choose between MG and DFE:
hausman mg DFE, sigmamore
Note:
7/26/2019 Time Sereis Analysis Using Stata
21/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Suppose you want to run all these tests on your data, so simple just import your data intostata and copy command from here into stata command bar and replace my variables
name with yours.
Good luck.
PANEL ARDL
Pooled Mean Group (PMG) model
The main characteristic of PMG is that it allows short-run coefficients, including the intercepts, the
speed of adjustment to the long-run equilibrium values, and error variances to be heterogeneous
country by country, while the long-run slope coefficients are restricted to be homogeneous across
countries. This is particularly useful when there are reasons to expect that the long-run equilibrium
relationship between the variables is similar across countries or, at least, a sub-set of them. The
shortrun adjustment is allowed to be country-specific, due to the widely different impact of thevulnerability to financial crises and external shocks, stabilization policies, monetary policy and so on.
However, there are several requirements for the validity, consistency and efficiency of this
methodology. First, the existence of a long-run relationship among the variables of interest requires the
coefficient on the errorcorrection term to be negative and not lower than -2. Second, an important
assumption for the consistency of the ARDL model is that the resulting residual of the error-correction
model be serially uncorrelated and the explanatory variables can be treated as exogenous. Such
conditions can be fulfilled by including the ARDL (p,q) lags for the dependent (p) and independent
variables (q) in error correction form. Third, the relative size of T and N is crucial, since when both of
them are large this allows us to use the dynamic panel technique, which helps to avoid the bias in the
average estimators and resolves the issue of heterogeneity. Eberhardt and Teal (2010) argue that the
treatment of heterogeneity is central to understanding the growth process. Therefore, failing to fulfil
these conditions will produce inconsistent estimation in PMG.
The PMG estimator constrains the long term coefficients to be the same across countries and allows
only the short-term coefficients to vary.
Mean Group (MG) estimator
The second technique (MG) introduced by Pesaran and Smith, (1995) calls for estimating separate
regressions for each country and calculating the coefficients as unweight means of the estimated
coefficients for the individual countries. This does not impose any restrictions. It allows for all
coefficients to vary and be heterogeneous in the long-run and short-run. However, the necessary
condition for the consistency and validity of this approach is to have a sufficiently large time-series
dimension of the data. The cross-country dimension should also be large (to include about 20 to 30
countries). Additionally, for small N the average estimators (MG) in this approach are quite sensitive to
outliers and small model permutations (see Favara, 2003).
7/26/2019 Time Sereis Analysis Using Stata
22/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Dynamic Fixed Effects (DFE) model
Finally, the dynamic fixed effects estimator (DFE) is very similar to the PMG estimator and imposes
restrictions on the slope coefficient and error variances to be equal across all countries in the long run.
The DFE model further restricts the speed of adjustment coefficient and the short-run coefficient to be
equal too. However, the model features country-specific intercepts. DFE has cluster option to estimate
intra-group correlation with the standard error (Blackburne and Frank, 2007). Nevertheless, Baltagi, Gri,
and Xiong (2000) point out that this model is subject to a simultaneous equation bias due to the
endogeneity between the error term and the lagged dependent variable in case of small sample size.
How to run DOLS model
Setpe# import data
Step#2 install following package
ssc install ltimbimata, replace
Step#3 Before beginning the estimations, we use the set more off instruction to tell Stata not to
pause when displaying the output.
set more off
Step#4 now run dols model, we regress iskr (dependent variable) on the regressors (gdskr
irxmap1 defigd2 ltinflcd opins2 totwdct ltdgdpd).
xtdolshm iskr gdskr irxmap1 defigd2 ltinflcd opins2 totwdct ltdgdpd
Step#5 if you want to increase lags and leads
xtdolshm iskr gdskr irxmap1 defigd2 ltinflcd opins2 totwdct, nla(3) nle(4)
step#6 if you want estimation at 10 % level of significance
xtdolshm iskr gdskr irxmap1 defigd2 ltinflcd opins2 totwdct, nla(3) nle(4) level(90)
7/26/2019 Time Sereis Analysis Using Stata
23/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
Primary data analysis
Step#1
Suppose I want to see descriptive statistics of my variables
summarize cs1 cs2 cs3 cs4 (cs1,2,3 and 4 are my variables)
step#2
*suppose you want to know about correlation among variables
correlate cs1 cs2 cs3 cs4 (cs1,2,3 and 4 are my variables)
step#3
*now you want to check reliability(cronbach alpha values) of items ,so first write alpha then all
items with space
alpha cs1 cs2 cs3 cs4 ( cs1 cs2 cs3 cs4 are my items)
Step#4
*now we are going to run PCA and want to see egen values /component means from the items
how much component we can create
pca cs1 cs2 cs3 cs4 ( cs1 cs2 cs3 cs4 are my items)
step#5
Now i also want to know about the KMO value of PCA
estat kmo, novar
step#6
*now i want to make a construct/variables from (4 items)cs1 cs2 cs3 cs4 and suppose i give
name to this new single variable like saeed1
7/26/2019 Time Sereis Analysis Using Stata
24/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
predict saeed1, score
Step#6
Actually I have converted my all items into variables now I want to run regressions between
these variables
regress cs1 cs2 cs3 cs4 (suppose cs1,2,3 and 4 are my variables which are made after
PCA)
Last tips and tricks
Finally how to generate new variables
1. Suppose you want to generate a series of square of any variable
gen cs1sqrt=sqrt( cs1) (note cs1 is my variabel)
2. Suppose you want to take log
gen cs1log=log( cs1)
3. Suppose u want to add two variables
gen cs1pluscs3 = cs1+cs3
4. Suppose you want to generate series with first difference5. generate fdpop = d.pop
How to get help from stataSuppose you are running any test but at some points you got confused/ stuck so how u canprecede now, suppose I was running panel unit root but I was not sure about null hypothesis
of different test how I can precede now? So to get rid of this problem see following pics and
enjoy.
7/26/2019 Time Sereis Analysis Using Stata
25/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC
TECHNIQUES [email protected]
In this you can see description about the null hypothesis of all tests so u can get rid of any
problem just click on help button
7/26/2019 Time Sereis Analysis Using Stata
26/26
Welcome to meo school of research
WWW.SAEEDMEO.BLOGSPOT.COM
Muhammad saeed AAS Khan Meo, Superior university Lahore Pakistan
PRAY FOR MY TEACHERS AND FAMILY VISIT MY BLOG FOR RESEAR TIPS AND ECONOMETRIC