Second Generation Unit Root Tests using Stata

Second Generation Unit Root Tests using Stata

Second Generation Unit Root Tests using Stata discusses the tests by Pesaran (2007) and Pesaran, Smith, and Yamagata (2009).

Watch Video

The video tutorial on Second Generation Unit Root Tests using Stata. The tests are established in Pesaran (2007) and Pesaran, Smith, and Yamagata (2009).

Second Generation Unit Root Tests using Stata

In this video tutorial, we demonstrate to find, install and run multipurt and pescadf which are commonly known as Second Generation Unit Root Tests using Stata. The tests are established in Pesaran (2007) and Pesaran, Smith, and Yamagata (2009). The tests are commonly known as second generation unit root tests because of their model specification modified the conventional approaches to unit root tests.

These are also known is first generation or conventional panel unit root tests.

Watch Video Tutorial on Second Generation Unit Root Tests ›

MultiPurt code in Stata
We can use -findit multipurt- code in Stata to search and install -multiput- code.
PesCADF using Stata
Use -findit pescadf- code to search and install the -pescadf- code to test unit root.
XTUNITROOT using Stata
Use -findit xtunitroot- code to search and read about the conventional unit root test.

Important Stata Codes for Panel Data Analysis

Describe panel data using -xtdes-
Hausman test using -hausman-
-xttab- to tabulate panel data.
Summarize panel data using -xtsum-
-xtivreg- for instrumental variable reg.
-xtregar- for -xtreg- with AR(1) errors.
Visualize panel data using -xtline-
-xtoverid- for identification restriction
-xtgls- for Panel-data models using GLS.
FE and RE Regression using -xtreg-
-xtunitroot- for panel unit root tests
-xtdpd- & -xtdpdsys- for GMM models.

Learn Panel Data Analysis With Us ›

Second Generation Unit Root Tests using Stata

The tests are commonly known as second generation unit root tests because of their model specification modified the conventional approaches to unit root tests.
In this video tutorial, we demonstrate to find, install and run multipurt and pescadf which are commonly known as Second Generation Unit Root Tests using Stata. The tests are established in Pesaran (2007) and Pesaran, Smith, and Yamagata (2009). The tests are commonly known as second generation unit root tests because of their model specification modified the conventional approaches to unit root tests. Other panel unit root tests include Levin and Lin (1992) pooled ADF test (levinlin), Im, Pesaran, and Shin (1997) averaged unit root test for heterogeneous panels (IPS) (ipshin), Maddala andWu (1999) Fisher combination test (MW) (xtfisher), Breitung (2000), Hadri (2000), Harris & Tzavalis (1999) (xtunitroot with options breitung, hadri, ht, respectively, in addition to the above tests). These are also known is first generation or conventional panel unit root tests.

Following Stata helpfile for -multipurt-, The Maddala and Wu (1999) test assumes/allows for heterogeneity in the autoregressive coefficient of the Dickey-Fuller regression and ignores cross-section dependence in the data. Building on the Fisher-principle it constructs a chi-squared statistic, whereby the p-values of country-specific (A)DF tests are transformed into logs and summed across panel members. Multiplied by -2 this sum is then distributed chi-squared with 2N degrees of freedom under the null of nonstationarity in all panel members/series. The Pesaran (2007) CIPS test allows for assumes/allows for heterogeneity in the autoregressive coefficient of the Dickey-Fuller regression and allows for the presence of a single unobserved common factor with heterogeneous factor loadings in the data. The statistic is constructed from the results of panel-member-specific (A)DF regressions where cross-section averages of the dependent and independent variables (including the lagged differences to account for serial correlation) are included in the model (referred to as CADF regressions). The averaging of the group-specific results follows the procedure in the Im, Pesaran and Shin (2003) test. Under the null of nonstationarity the test statistic has a non-standard distribution.

Stata helpfile for -pescadf mention that: pescadf runs the t-test for unit roots in heterogenous panels with cross-section dependence, proposed by Pesaran (2003). Parallel to Im, Pesaran and Shin (IPS, 2003) test, it is based on the mean of individual DF (or ADF) t-statistics of each unit in the panel. Null hypothesis assumes that all series are non-stationary. To eliminate the cross dependence, the standard DF (or ADF) regressions are augmented with the cross section averages of lagged levels and first-differences of the individual series (CADF statistics). Considered is also a truncated version of the CADF statistics which has finite first and second order moments. It allows to avoid size distortions, especially in the case of models with residual serial correlations and linear trends (Pesaran, 2003).

References for the given two second generation unit root tests are given below:

Pesaran, M. H. (2007). A simple panel unit root test in the presence of cross-section dependence. Journal of Applied Econometrics, 22(2), 265-312.
Pesaran, M. H., Smith, V., & Yamagata, T. (2009). Panel unit root tests in the presence of a multifactor error structure. (Cambridge University, unpublished working paper, September)
More Stata codes: https://sites.google.com/site/medevecon/code#TOC-xtcipsm
Data for -multipurt- can be downloaded from here: http://sites.google.com/site/medevecon/publications-and-working-papers/agri_stata9.zip

Online Course in Advanced Econometric Modeling is starting 10th September, 2017. Enroll now to learn and specialize Advanced Econometric Modeling and more about specialised contents in panel data.

Stata Features

Stata is a rich econometric software. It has covered the maximum econometric models through the menus driven clicks and get results feature. Some of the common Stata Features we see are listed below. It can be concluded that Stata is one of the biggest tools we should refer to do some econometric analysis of academic and business research. The Stata Features have been listed on http://www.stata.com/features/ to found with examples mostly through the Stata Blogs as well at http://blog.stata.com/.

Linear models

regression  •  censored outcomes  •  endogenous regressors  •  bootstrap, jackknife, and robust and cluster–robust variance  •  instrumental variables  •  three-stage least squares  •  constraints  •  quantile regression  •  GLS  •  more

Panel/longitudinal data

random and fixed effects with robust standard errors  •  linear mixed models  •  random-effects probit  •  GEE  •  random- and fixed-effects Poisson  •  dynamic panel-data models  •  instrumental variables  •  panel unit-root tests  •  more

Multilevel mixed-effects models

continuous, binary, count, and survival outcomes  •  two-, three-, and higher-level models  •  generalized linear models  •  nonlinear models  •  random intercepts  •  random slopes  •  crossed random effects  •  BLUPs of effects and fitted values  •  hierarchical models  •  residual error structures  •  DDF adjustments  •  support for survey data  •  more

Binary, count, and limited outcomes

logistic, probit, tobit  •  Poisson and negative binomial  •  conditional, multinomial, nested, ordered, rank-ordered, and stereotype logistic  •  multinomial probit  •  zero-inflated and left-truncated count models  •  selection models  •  marginal effects  •  more

Extended regression models (ERMs)

combine endogenous covariates, sample selection, and nonrandom treatment in models for continuous, interval-censored, binary, and ordinal outcomes  •  more

Generalized linear models (GLMs)

ten link functions  •  user-defined links  •  seven distributions  •  ML and IRLS estimation  •  nine variance estimators  •  seven residuals  •  more

Finite mixture models (FMMs)

fmm: prefix for 17 estimators  •  mixtures of a single estimator  •  mixtures combining multiple estimators or distributions  •  continuous, binary, count, ordinal, categorical, censored, truncated, and survival outcomes  •  more

Some further Stata Features include:

Spatial autoregressive models

spatial lags of dependent variable, independent variables, and autoregressive errors  •  fixed and random effects in panel data  •  endogenous covariates  •  analyze spillover effects  •  more

ANOVA/MANOVA

balanced and unbalanced designs  •  factorial, nested, and mixed designs  •  repeated measures  •  marginal means  •  contrasts  •  more

Exact statistics

exact logistic and Poisson regression  •  exact case–control statistics  •  binomial tests  •  Fisher’s exact test for r × c tables  •  more

Some further Stata Features include:

Linearized DSGE models

specify models algebraically  •  solve models  •  estimate parameters  •  identification diagnostics  •  policy and transition matrices  •  IRFs  •  dynamic forecasts  •  more

Tests, predictions, and effects

Wald tests  •  LR tests  •  linear and nonlinear combinations  •  predictions and generalized predictions  •  marginal means  •  least-squares means  •  adjusted means  •  marginal and partial effects  •  forecast models  •  Hausman tests  •  more

Contrasts, pairwise comparisons, and margins

compare means, intercepts, or slopes  •  compare with reference category, adjacent category, grand mean, etc.  •  orthogonal polynomials  •  multiple-comparison adjustments  •  graph estimated means and contrasts  •  interaction plots  •  more

Simple maximum likelihood

specify likelihood using simple expressions  •  no programming required  •  survey data  •  standard, robust, bootstrap, and jackknife SEs  •  matrix estimators  •  more

Programmable maximum likelihood

user-specified functions  •  NR, DFP, BFGS, BHHH  •  OIM, OPG, robust, bootstrap, and jackknife SEs  •  Wald tests  •  survey data  •  numeric or analytic derivatives  •  more

Resampling and simulation methods

bootstrap  •  jackknife  •  Monte Carlo simulation  •  permutation tests  •  more

Time series

ARIMA  •  ARFIMA  •  ARCH/GARCH  •  VAR  •  VECM  •  multivariate GARCH  •  unobserved-components model  •  dynamic factors  •  state-space models  •  Markov-switching models  •  business calendars  •  tests for structural breaks  •  threshold regression  •  forecasts  •  impulse–response functions  •  unit-root tests  •  filters and smoothers  •  rolling and recursive estimation  •  more

Survival analysis

Kaplan–Meier and Nelson–Aalen estimators,  •  Cox regression (frailty)  •  parametric models (frailty, random effects)  •  competing risks  •  hazards  •  time-varying covariates  •  left-, right-, and interval-censoring  •  Weibull, exponential, and Gompertz models  •  more

Bayesian analysis

thousands of built-in models  •  univariate and multivariate models  •  linear and nonlinear models  •  multilevel models  •  continuous, binary, ordinal, and count outcomes  •  bayes: prefix for 45 estimation commands  •  continuous univariate, multivariate, and discrete priors  •  add your own models  •  convergence diagnostics  •  posterior summaries  •  hypothesis testing  •  model comparison  •  more

Power and sample size

power  •  sample size  •  effect size  •  minimum detectable effect  •  means  •  proportions  •  variances  •  correlations  •  ANOVA  •  regression  •  cluster randomized designs  •  case–control studies  •  cohort studies  •  contingency tables  •  survival analysis  •  balanced or unbalanced designs  •  results in tables or graphs  •  more

Treatment effects/Causal inference

inverse probability weight (IPW)  •  doubly robust methods  •  propensity-score matching  •  regression adjustment  •  covariate matching  •  multilevel treatments  •  endogenous treatments  •  average treatment effects (ATEs)  •  ATEs on the treated (ATETs)  •  potential-outcome means (POMs)  •  continuous, binary, count, fractional, and survival outcomes  •  more

SEM (structural equation modeling)

graphical path diagram builder  •  standardized and unstandardized estimates  •  modification indices  •  direct and indirect effects  •  continuous, binary, count, ordinal, and survival outcomes  •  multilevel models  •  random slopes and intercepts  •  factor scores, empirical Bayes, and other predictions  •  groups and tests of invariance  •  goodness of fit  •  handles MAR data by FIML  •  correlated data  •  survey data  •  more

Latent class analysis

binary, ordinal, continuous, count, categorical, fractional, and survival items  •  add covariates to model class membership  •  combine with SEM path models  •  expected class proportions  •  goodness of fit  •  predictions of class membership  •  more

Multiple imputation

nine univariate imputation methods  •  multivariate normal imputation  •  chained equations  •  explore pattern of missingness  •  manage imputed datasets  •  fit model and pool results  •  transform parameters  •  joint tests of parameter estimates  •  predictions  •  more

Some further Stata Features include:

Survey methods

multistage designs  •  bootstrap, BRR, jackknife, linearized, and SDR variance estimation  •  poststratification  •  DEFF  •  predictive margins  •  means, proportions, ratios, totals  •  summary tables  •  almost all estimators supported  •  more

Cluster analysis

hierarchical clustering  •  kmeans and kmedian nonhierarchical clustering  •  dendrograms  •  stopping rules  •  user-extensible analyses  •  more

IRT (item response theory)

binary (1PL, 2PL, 3PL), ordinal, and categorical response models  •  item characteristic curves  •  test characteristic curves  •  item information functions  •  test information functions  •  differential item functioning (DIF)  •  more

Multivariate methods

factor analysis  •  principal components  •  discriminant analysis  •  rotation  •  multidimensional scaling  •  Procrustean analysis  •  correspondence analysis  •  biplots  •  dendrograms  •  user-extensible analyses  •  more

Data management

data transformations  •  match-merge  •  import/export data  •  ODBC  •  SQL  •  Unicode  •  by-group processing  •  append files  •  sort  •  row–column transposition  •  labeling  •  save results  •  more

Graphics

lines  •  bars  •  areas  •  ranges  •  contours  •  confidence intervals  •  interaction plots  •  survival plots  •  publication quality  •  customize anything  •  Graph Editor  •  more

Graphical user interface

menus and dialogs for all features  •  Data Editor  •  Variables Manager  •  Graph Editor  •  Project Manager  •  Do-file Editor  •  Clipboard Preview Tool  •  multiple preference sets  •  more

Documentation

27 manuals  •  14,000+ pages  •  seamless navigation  •  thousands of worked examples  •  quick starts  •  methods and formulas  •  references  •  more

Basic statistics

summaries  •  cross-tabulations  •  correlations  •  z and t tests  •  equality-of-variance tests  •  tests of proportions  •  confidence intervals  •  factor variables  •  more

Nonparametric methods

nonparametric regression  •  Wilcoxon–Mann–Whitney, Wilcoxon signed ranks, and Kruskal–Wallis tests  •  Spearman and Kendall correlations  •  Kolmogorov–Smirnov tests  •  exact binomial CIs  •  survival data  •  ROC analysis  •  smoothing  •  bootstrapping  •  more

Epidemiology

standardization of rates  •  case–control  •  cohort  •  matched case–control  •  Mantel–Haenszel  •  pharmacokinetics  •  ROC analysis  •  ICD-10  •  more

GMM and nonlinear regression

generalized method of moments (GMM)  •  nonlinear regression  •  more

Other statistical methods

kappa measure of interrater agreement  •  Cronbach's alpha  •  stepwise regression  •  tests of normality  •  more

Functions

statistical  •  random-number  •  mathematical  •  string  •  date and time  •  more

Internet capabilities

ability to install new commands  •  web updating  •  web file sharing  •  latest Stata news  •  more

User-written commands

user-written commands for meta-analysis, data management, survival, econometrics, more

Some further Stata Features include:

Programming features

adding new commands  •  command scripting  •  object-oriented programming  •  menu and dialog-box programming  •  dynamic documents  •  Markdown  •  Project Manager  •  plugins  •  more

Matrix programming—Mata

interactive sessions  •  large-scale development projects  •  optimization  •  matrix inversions  •  decompositions  •  eigenvalues and eigenvectors  •  LAPACK engine  •  real and complex numbers  •  string matrices  •  interface to Stata datasets and matrices  •  numerical derivatives  •  object-oriented programming  •  more

Embedded statistical computations

Numerics by Stata

Installation Qualification

IQ report for regulatory agencies such as the FDA  •  installation verification

Accessibility

Section 508 compliance, accessibility for persons with disabilities

Sample session

A sample session of Stata for Mac, Unix, or Windows.

To learn more about Stata Features, we can how rapidly it has evolved over the time to cover many econometric methods compared to other softwares like SPSS or Eviews. These Stata Features has been one of the key determinants of selecting Stata is one of the best econometric softwares by Economists and academics in other professions like Finance and Social Sciences.

New in Stata 15—Latent class analysis  •  Bayes prefix  •  Combine endogenous regressors, treatment effects, and selection  •  Spatial autoregressive models  •  Finite mixture models (FMM)  •  Markdown—create web pages with intermixed text, Stata output, and graphs  •  DSGE models  •  Nonlinear multilevel and panel-data models  •  Mixed logit choice models  •  Multilevel Bayesian analysis  •  Nonparametric regression  •  Interval-censored survival models

We will cover these methods in our future video series. You can stay tuned for our courses with such video tutorials on Courses tab here.

Regression Model using Ratio Dependent Variable

Running Regression Model using Ratio dependent variable in Stata is possible through the code -betareg- which allows us to have estimates the parameters of a beta regression model. This model accommodates dependent variables that are greater than 0 and less than 1, such as rates, proportions, and fractional data. Most of the times, using softwares other than Stata, we employ simple ordinary least squares approach to estimate regression model using ratio dependent variables, which might involve a little complexity for inferences. Therefore, we employ -betareg- using Stata to draw legitimate inferences about ratio dependent variables and their determinants.

1. To run regression model using ratio dependent variable, the following steps should be employed.

2. Read the help manual for -betareg using the Stata code: help betareg.

Using your own data to run the following example of codes to see the working of -betareg-.

3. Simple Beta regression on ratio dependent variable can be run using
betareg ratiodv otherivs

4. We can add categorical independent variables as well using factor-variable syntax
betareg ratiodv otherivs i.categoricalvars

5. if we had any covariates for scale, we can use the following code to analyse ratio dependent variables
betareg ratiodv otherivs i.categoricalvars, scale(covariate1 covariate2)

6. If we had to employ complex models involving link involving conditional mean and square-root link for conditional scale, we can use the following structure of the code:
betareg ratiodv otherivs i.categoricalvars, scale(covariate1 covariate2) link(probit) slink(root)

7. Also, Beta regression model involving ratio dependent variable  with robust standard errors can be run as:
betareg ratiodv otherivs, vce(robust)

Beta Regression Model using Ratio Dependent Variable can be run for other types of dependent variables like rates, proportions, and fractional data which is commonly involved when we have growth rates and percentages data. The interpretation of the coefficients of IV which shows the effect of IV on Ratio Dependent Variable can be done through -margins command.

Need to learn Advanced Econometric Theory and Application? Enroll for a course here.

Some recommended research material related to theory and application of -betareg- can be found here:

  1. Basu, A., and A. Manca. 2012. Regression estimators for generic health-related quality of life and quality-adjusted life years. Medical Decision Making 32: 56–69.
  2. Cameron, A. C., and P. K. Trivedi. 2005. Microeconometrics: Methods and Applications. New York: Cambridge
    University Press.
  3. Castellani, M., P. Pattitoni, and A. E. Scorcu. 2012. Visual artist price heterogeneity. Economics and Business Letters 1(3): 16–22.
  4. Ferrari, S. L. P., and F. Cribari-Neto. 2004. Beta regression for modelling rates and proportions. Journal of Applied Statistics 31: 799–815.
  5. Hubben, G. A. A., D. Bishai, P. Pechlivanoglou, A. M. Cattelan, R. Grisetti, C. Facchin, F. A. Compostella, J. M.
    Bos, M. J. Postma, and A. Tramarin. 2008. The societal burden of HIV/AIDS in Northern Italy: An analysis of
    costs and quality of life. AIDS Care: Psychological and Socio-medical Aspects of AIDS/HIV 20: 449–455.
  6. Paolino, P. 2001. Maximum likelihood estimation of models with beta-distributed dependent variables. Political Analysis 9: 325–346.
  7. Smithson, M., S. Deady, and L. Gracik. 2007. Guilty, not guilty, or : : : ? Multiple options in jury verdict choices. Journal of Behavioral Decision Making 20: 481–498.
  8. Smithson, M., and J. Verkuilen. 2006. A better lemon squeezer? Maximum-likelihood regression with beta-distributed dependent variables. Psychological Methods 11: 54–71.

See a small vidoe tutorial on Beta Regression using Ratio Dependent Variable

Time Series Graphs using Stata

In this video tutorial, we would demonstrate on how to use the built in menu of Stata for Time Series Graphs. The Time Series Graphs using Stata is intuitive and more closely looking to the graphs seen on Economist. We will not show the details of customising the graphs to look exactly as we don on Economist but this will help us produce the graphs at this early stage of learning about Time Series Graphs using Stata. Simple Graph Editor of Stata can be used to modify the graphs to the look one needs.

Time Series Graphs using Stata

Using the Stata menu, Graphics and clicking on the time-series graphs, we get a few options specific to Time Series Graphs. In this simple text tutorial and following video tutorial, we can demonstrate the production of some important time series graphs for inclusion in research reports and thesis.

Note, that the use of relevant Time Series Graphs using Stata is very important. The Stata has given us many options to produce a statistically relevant graphs for inclusion into reports like simple linear charts with a variable on y-axis and time on x-axis, periodogram, correlogram (ac) and partial correlogram (pac).

As we will produce some graphs in this tutorial, it can be seen that Stata will produce a related command as well. For future, we will be able to reproduce these charts by simple clicking on these codes from the review pane. Also, these commands can be used in a loop by making suitable do file involving -foreach var- in Stata.

The important graphs that we can build using the menu is Time Series Graphs using Stata for Bartlett's periodogram-based test for white noise. This is commonly not observed in literature but is very important test as well as graphic tool. I personally, recommend, Bartlett's periodogram-based test for white noise for high definition data involving stock prices and exchange rates that needs volatility models.

The following video shows the steps for Time Series Graphs using Stata using the menu. Also, we produce the codes created directly by Stata from these clicks and the data we used for replication of the graphs.

cumsp open, generate(normal_open) addplot((spike open year))
twoway (tsline open) (tsline agri) (tsline manuf)
twoway (tsline open) (tsline gdplc)
wntestb open
pergram open
twoway (tsline open)
ac open
pac open
xcorr gdplc open
wntestb open, table
wntestb open, addplot((spike open gdplc))
xcorr gdplc open

There are different options to learn Stata in private and instructor led courses from our AnEc Center for Econometrics Research and earn a verifiable certificate.

Time Series Graphs using Stata Video

Free Sample Freelance Project Proposal

Dear Client,
Before you verify my following resumed profile from any source online, I can attest these through a trial before you decide and buy my proposal. Send me your data and I will create a proposed solution based on the structure of your data. Once you review this solution, I am sure, the following profile will be verifiable from AnEconomist or LinkedIn as well.
I would be happy help you get a 100% satisfaction through the following process of our working:
1. You send your data and objectives.
2. I create a proposed solution for verification of my candidacy.
3. You buy my proposal and I begin the work.
4. I submit regular progress report on each step of the work and you review it before final submission.
5. I modify the previous and future work according to your interim review.
6. I finish the analytics, reports, interpretation and you once again review everything.
7. You get a 100% satisfaction through quick communication
(yes, I got a delay in a project due to an emergency but see, the details, the clienty verify my skills are excellent).
Now more about me:
As a member of Data Science Central (DSC), American Economic Association (AES), Royal Economic Society (RES), International Health Economics Association (iHEA) and The Econometrics Society, I have been working closely with top academics in Economics, Econometrics, Statistics and Research Methods. Also, I am providing supervision in Applied Econometrics and Statistics to PhD candidates in Project Management, Business Management, Finance, Corporate Governance and Social Sciences.
I am professionally trained and the highly recogized online course provider in Stata, Eviews, SPSS, Nvivo10/11, WinRATS, SAS, GAUSS, Gretl, Minitab, C++, JavaScript and Python. I helped more than 300 clients from around the world in applied econometrics and statistics for corporate governance, financial performance, economics research, business evaluation, Value at Risk, Options Pricing, Stock Evaluation, Pairs Trading and Backtesting through the use of above statistical softwares. It is backed by my education in economics, statistics and econometrics from The University of Sheffield, UK.
I have a teaching and academic research experience of more than 11 years at a QS Ranked University. I teach modules in Economics, Statistics, Econometrics and Quantitative Analysis. Key themes and topics of my teaching are Qualitative Data Analysis, Factor Analysis, Principle Component Analysis, Power and Sample Size determination for Survival Studies, Analysis of Open ended surveys and interviews, Multivariate Time Series techniques in VAR/VECM, VARX, SVAR, Multivariate GARCH, ARDL and Bayesian Multivariate Time Series Methods. So far, more than 70 PhD and MS/MRes candidates completed their courses in Applied Econometrics and Applied Statistics under my supervision.
I welcome you to explore the above factors of my skills and experience from Econometricians Club and AnEconomist. I would also like a free demo in any course in the list, a proposed solution for your project using your own data and I will ensure you get the best outcome for your course or project on freelance terms and conditions.
Regards
Muhammad Anees
Assistant Professor
Founder Econometricians Club
Founder AnEconomist
Founder Stata Pro Help

Tests for Autocorrelated Errors

In ordinary least square regression model, we specify the equation as
y = b0 + b1 x1 + b2 x2 + b3 x3 + b4 x4 + ut
and we can test the assumption of autocorrelation or we can test whether the disturbances are autocorrelated.
To test the autocorrelation, we can follow the steps below:
(i) Estimate the regression model above using ordinary least square approach/OLS:
sysuse auto, clear
gen t=_n
tsset t
reg price rep78 trunk length
. reg price rep78 trunk length
Source |       SS           df       MS      Number of obs   =        69
-------------+----------------------------------   F(3, 65)        =      6.42
Model |   131790806         3  43930268.8   Prob > F        =    0.0007
Residual |   445006152        65   6846248.5   R-squared       =    0.2285
-------------+----------------------------------   Adj R-squared   =    0.1929
Total |   576796959        68  8482308.22   Root MSE        =    2616.5
------------------------------------------------------------------------------
price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
rep78 |   578.7949   348.6211     1.66   0.102    -117.4495    1275.039
trunk |  -31.78264   108.8869    -0.29   0.771    -249.2447    185.6794
length |   70.17701   22.01136     3.19   0.002     26.21729    114.1367
_cons |  -8596.181   3840.351    -2.24   0.029    -16265.89   -926.4697
------------------------------------------------------------------------------

(ii)  Now calculate the residuals from the above regression:
predict errors, res
(iii)  Run another regression by inserting lagged residuals or the lag values of error terms, (errors) as predicted from above regression model into a regression model of the residuals as a dependent variable. Our regression model will be estimated through the following regression code in Stata: reg errors rep78 trunk length l.errors. We can consider this regression as auxiliary regression. The results from this auxiliary regression is given below
. reg errors rep78 trunk length l.errors
Source |       SS           df       MS      Number of obs   =        63
-------------+----------------------------------   F(4, 58)        =      4.66
Model |   104717963         4  26179490.9   Prob > F        =    0.0025
Residual |   325759819        58   5616548.6   R-squared       =    0.2433
-------------+----------------------------------   Adj R-squared   =    0.1911
Total |   430477782        62  6943190.04   Root MSE        =    2369.9
------------------------------------------------------------------------------
errors |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
rep78 |  -47.23696   332.1243    -0.14   0.887    -712.0559     617.582
trunk |   62.68025   103.8779     0.60   0.549    -145.2539    270.6144
length |   9.373147   20.97416     0.45   0.657     -32.6112    51.35749
|
errors |
L1. |   .5273932   .1225638     4.30   0.000      .282055    .7727313
|
_cons |  -2375.671   3741.339    -0.63   0.528    -9864.774    5113.432
------------------------------------------------------------------------------

(iv) Using the estimated results from auxiliary regression above, note the the R-squared value and multiply it by the number of included observations:
scalar N=_result(1)
scalar R2=_result(7)
scalar NR2= N*R2
scalar list N  R2  NR2
N =         63
R2 =  .24325986
NR2 =  15.325371

(v)  Now, the null hypothesis of BP test is that there is no autocorrelation, we can use the standard Chi-Square distribution to find the tabulated values of the Chi-Square to check if the null hypothesis of no autocorrelation needs to be rejected. According to theory, the Chi-Square statistic calculated using the NRSquare approach above, the test statistic NR2 converges asymptotically where degrees of freedom for the test is s which the number of lags of the residuals included in the auxiliary regression and we have included 1 lagged value of errors/residuals so degrees of freedom in this case is 1. We can use Stata conventional functions for distribution to determine the tabulated values at 5% level of significance using the following code:
scalar chi151=invchi2tail(1, .05)
scalar list chi151
chi15 =  3.8414598
We got from the above tutorial in tests for autocorrelation, NR2 = 15.325371 > 3.84 = Chi-Square (1, 5%). As the calculated value of Chi2 is greater than tabulated values of Chi2, so we reject the null hypothesis of no autocorrelation on the disturbances.

Applied Statistics for Business and Management

Statistics for Business and Management professionals and academic researchers is of critical importance. Although there are specialized courses in Statistics for the students of Business and Management but none of the courses offer specialization in either, Stata, Eviews or SPSS and other computer packages. The current course introduces the application of Stata, Eviews and SPSS and other computer application while emphasis is laid on the development of theoretical background of the learners as well as with strong application of the techniques in Statistics for Business. The contents of the course offered to students include (but are not limited) to:
Basic Data Management and Presentation
Hypothesis Testing and Research Problems
Causal Relationships, Regression Analysis and Applications
Qualitative Data Analysis for Binary and Multi-chotomous variables

Also the students of the course would be provided additional support via other mediums like phone, SMS, email beside the traditional and favorite WizIQ!
This course will benefit the students of MBA, BBA and Doctorate students in Business and Management courses have to study and develop the skills of Quantitative Data Analysis. This course will master these students in their Statistical courses.
Course Highlights
Apply Statistical Techniques to real world data
Apply Data Analysis to relevant research problems
Wide range of contents which are usually required in broader contexts

The course package:
15 LIVE online classes
Duration: Two to Four Weeks (Negotiable)
All Days: 0500 PM to 1000 PM GMT (1000 PM to 0200 AM Pakistan Times)
The course outline:
Deterministic Data and Random Data
Multivariate Tables, Scatter Plots and D Plots
Measures of Association for Continuous Variables
Measures of Association for Ordinal Variables
Measures of Association for Nominal Variables
Estimating Data Parameters
Parametric Tests of Hypotheses
Non-Parametric Tests of Hypotheses
Statistical Classification
Multiple Regression
General Linear Regression Model
General Linear Regression in Matrix Terms
Multiple Correlation
Inferences on Regression Parameters
ANOVA and Extra Sums of Squares
Polynomial Regression and Other Models
Building and Evaluating the Regression Model
Principal Components
Dimensional Reduction
Principal Components of Correlation Matrices
Factor Analysis
Survival Analysis
The Exponential Model
The Weibull Model
The Cox Regression Model

Recommended books for this course:
Probability and Statistics, Fourth Edition by Morris H. DeGroot & Mark J. Schervish
SPSS for Introductory Statistics Second Edition by Morgan et al
A First Course in Business Statistics, Eight Edition by JAMES T. McCLAVE, P. GEORGE BENSON & TERRYSlNClCH
Note: Students must purchase these books themselves. These are not available as part of the course. Discount coupons may be asked from the teacher who would be happy to share if any available right now.

Unit Root Tests, Publication Style Tables in Stata

There is commonly a question on many forums as to how can one test unit root of several variables and export the results of all these tests into a single file in Word or Excel sheet. To demonstrate in this tutorials, we will use Unit Root Tests, Publication Style Tables in Stata.
To help these querries, I have written the following simplest do file which you can use after modifiying for the relevant places like file_paths and variables_names. The code will do the job to test the variable for unit root or stationarity and compile the results from all the individual tests into a single table and export it to your desired format like MS Word or MS Excel sheet for further use and modifications. The steps in this tutorial will help you extend this do file to include many other tests like summary statistics to be exported into the same files.

***Step 1. Load the data, I have used the example location folder and files. You can change the path to your desired detination of the file/folder where your data exists.
use "E:\Dropbox\data.dta", clear

***Step 2. Now create a temporary files using
tempname anees_uroot
tempfile unitroots

***Step 3. Then you need to write to the temporary files as to what should be the names of the headers of the table. Also you need to specify which file to use and what to add to the file as headers.
postfile `anees_uroot' str12 name dfuller_statistic dfuller_pvalue dfuller_lags perron_statistic pperron_rho pperron_pvalue pperron_lags using `unitroots'

***Step 4. Load the variables. You can add as many variables as you wish or that you would like to use in reports. Replace the var_i with your real variables here.
foreach var of varlist var_1 var_2 var_3 var_4 {

***Step 5. This section conducts the tests. I have added simple ADF and PP tests for unit root. Please note, you should make sure the tests stores the r() to be exported.
dfuller `var'
local dfuller_statistic = r(Zt)
dfuller `var'
local dfuller_pvalue = r(p)
dfuller `var'
local dfuller_lags = r(lags)
pperron `var'
local perron_statistic = r(Zt)
pperron `var'
local pperron_rho = r(Zrho)
pperron `var'
local pperron_pvalue = r(p)
pperron `var'
local pperron_lags = r(lags)

***Step 6. Write theresults into the temporary files and close the section code.
post `anees_uroot' ("`var'") (`dfuller_statistic') (`dfuller_pvalue') (`dfuller_lags') (`perron_statistic') (`pperron_rho') (`pperron_pvalue') (`pperron_lags')
}

***Step 7. Close the post file as started above. You can now see the produced results in a tabular format to be copied right from Stata output window or use the next line of code to export the stored results into Excel etc.
postclose `anees_uroot'
clear
use `unitroots'

***Step 8. Export the results to Excel and keep the the stored names for tests_values as variables headers. The first column named; Name will contain variable names.
export excel using "E:\Dropbox\Stata Unit Root Tests.xls", firstrow(variables) replace
***Step 9 Optional. Use the list command in Stata to see the results produced by above tutorial.
list

The full code should look like the following.
This tutorial was written for a online course in Time Series Econometrics. I have edited just the names of the variables from the output and codes. You can book your aneconomist.com and get your Stata code as neat and clean as it should be possible.

Econometric Models Selection

In this simple outline on the issue of commonly raised douts on how to select an economic model, I would like to sum the issue in this 300 words article. Econometric Models Selection is one key problem for all. The model selection is based on the type of data and type of variables. Here, we mention an order following which helps an econometric model strategy development for us. We assume to use Panel data to develop econometric model selection strategy. Initially, to determine the right set of models, the nature of data structure for the panel data follows like this: A. Check data structure. 1. if N>T, then follows B series of steps. 2. If T>N, then follow the steps in C series.

If we assume the panel data has N sufficiently greater than T, then simple panel data or instrumental/GMM models for panel data can be achieved using the following order. This helps in Econometric Models selection looking into the key steps of the econometric analysis of the given panel data.

For Case 1, follow these steps.
B1. The first stepOLS
B2. RE/FE
B3. Hausman
B4. Assumptions of RE or FE from B3.
B5. Endogeneity Tests
B6. Instrumental Regression
B7. GMM if seens dynamics/autocorrelation in B4.

If the data at hands is such that T is sufficiently larger than N, the panel time series structure will be evidenced and hence our econometric models selection strategy will follow the following procedures. The unit roots and cointegration is for panel time series data which are also sometimes considered as longer time panel data or longer panel data. In such cases, the time series properties in estimators are heavily observed and hence the steps to select an econometric models selection strategy will include these.
For Case 2, follow these steps
C1. Unit Root
C2. Cointegration
C3. VECM


Event Analysis using Stata

Advanced Econometrics using Stata training workshop and tutorial. The following Stata code computes simple t-test to test the hypothesis that the variables are different between two time periods. The time periods have been defined based on pre-event and post-event time periods. Thus, we can employ this method to test an event impact on a few variables in a single script of the Stata code which also produces a single table ready for publication or inserting into a word document.

****Open the data file using the following code.
use "E:\Dropbox\Advanced Econometrics using Stata Trainings\data12.dta", clear

****The following two lines of codes creates a few temprary files in Stata to create and save the results in our analysis. The results will be available to call into Stata from the same temprary files.
tempname econometrics_ttest
tempfile ttests
postfile `econometrics_ttest' str12 name t_statistic swilk rankstat pearson fisher using `ttests'

****Now, loop over the given variables to be used for testing the hypothesis. These are the variables which will make the hypothesis to be tested on using Stata and following the simple t-test to verify the post-event variable values has equal greater average than the pre-event time period sample of the same variable.
foreach var of varlist  y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 {

****t-test is used to test the null hypothesis that the variable has equal means between post-event and pre-event samples for the variables. The -local-command saves the given statistics saved under the Stata routine r().
ttest `var', by(event)
local tstat = r(t)

****Shapiro Wilk test can be employed and produced results can be saved using the following code.
swilk `var'
local swilk = r(W)

****RankSum test is applied using the following code.
ranksum `var', by(event)
local rankstat = r(z)

****Chi-square tests can be employed using the following code.
median `var', by(event)
local pearson = r(chi2)
median `var', by(event) exact
local fisher = r(chi2_cc)

****The following code writes the produced and saved results in -local-s to the given variables defined under -postfile-.
post `econometrics_ttest' ("`var'") (`tstat') (`swilk') (`rankstat') (`pearson') (`fisher')
}

****These lines of the code closes the above temprary files, calculations and saving the results.
postclose `econometrics_ttest'
clear

****Call in the results to see the output of the above code.
use `ttests'

****Change any variable, their labels or create further statisticals.
label var t_statistic "Unequal Variance type t-Statistic"
rename name variable_name
label var variable_name "Variable Tested for Different in Mean Post minus Pre event"

****Now export the table which is already saved in form of a Stata file. This can be a simple table in a standard format.
export excel using "E:\Dropbox\Advanced Econometrics using Stata Trainings\tables_econometrics_research.xls", firstrow(variables) replace

****See the results.
list


Event Study Stata is one of the most interesting area that we can help you with. You can request a freelance project from our top freelancers in Stata to help you complete the event study even for a complex study. We handle Event Study using Stata for all kinds of data from cross sectional, panel data and time series. You can request a Event Study Stata help from our freelancers in econometrics and Stata using the following proforma.