Sunday, January 31, 2021

Some Important Codes in R (Applied Econometrics)

 ■ Some codes in R

Note: Dep var = Dependent Variable.

           Ind var = Independent Variable.

           Var 1 = Variable 1

           Var 2 = Variable 2

a) Taking log values

lvar1 <- log(var1, base = 10)


b) Correlation Test

#install.packages (corTest)

library (corTest)

cor.test(var1, var2)


c) Unit Roots Test (without deseaonalisation)

# install.packages(fUnitRoots)

library(fUnitRoots)


d) Testing Unit Root at Level (ADF)

adfTest (lvar1, lags = 0, type = "c")

e) Taking 1st difference

d.var1 <-diff (var1)

f) Lag selection criteria

#install.packages (vars)

library (vars)

Say, 

kk <-cbind (lvar1, lvar2, ... lvarn)

VARselect (kk) $selection

g) Co Integration  (Johannessen)

Say,

JC1 <- ca.jo (kk, type = "trace", ecdet = "none", K =3)

h) Eigen Value Stat

JC1 <- ca.jo (kk, type = "eigen", ecdet = "none", k = 3)

i) VECM (in p - 1 lags)

Say, 

model1 = VECM (data.frame (vars), lag = n, r = m, estim = "ML")

where, r = no. of co integrating relationship (will discuss later)

j) Impulse Response Function

plot (irf (model1, n.ahead=10))

for 10 periods.


To be contd...

Aditya Pokhrel 

MBA, MA Economics, MPA 

Saturday, January 30, 2021

Quantile Regression Intro - with reference to Eviews and R (Applied Econometrics)

 ■ Quantile Regression

Basically, Quantile regression is an extension of linear regression. It's used when the conditions of linear regressions are not met like linearity, homoscedasticity, normality.

The Quantile regression has no strong distributional assumptions.

Let's state Hypotheses.

Null (Ho): There's no significant impact on dependent variable due to independent variables.

Say that, the natural log of one of the independent variables is statisically significant, since p values is less than 0.05. If there's an increase in 1% median value of independent variables will inceease by 1.13% in the median value.

And in addition, remaining independent variable is not significant since p value is greater than 0.05.

■ Quantile regression's Goodness of Fit

The Pseudo R ^ 2 is 31 % (assume). The adjusted R ^ 2 say, is 28 %. So 28 % variation in conditional median in the dependent variable is due to the one of the independent variables.

The Quasi LR statistic value is say (29.3) and the p value is less than 0.05 that indicates that the model is stable.

■ The process of Quantile Regression (E views - with reference with R will be discussed in the next part of this blog)

1st run the linear regression and test for the serial correlations, normality and homoscedasticity. Make sure these three are insignificant. Thus, with these assumption we go for the Quantile Regression.

Estimate Eqn ➡ Method ➡ Quant Reg ➡Click ok

Choose the Quantile to estimate ➡ Select the value from 0 to 1 then Click OK.

Note: In linear regression its mean and in quantile regression its median.

We shall run the results and see results and interpreted.

For the results, Go to View ➡ Quantile Regression ➡ Process Coefficients ➡ Table ➡ Set Quantile 10 ➡ Click OK.

The result will be intrepreted in next blog.

To be contd...

Thank You

Aditya Pokhrel

MBA, MA Economics, MPA 

Friday, January 29, 2021

Meta Analysis - Basics - Part I (with reference to STATA codes)-(Applied Econometrics)

 ■ Meta Analysis basics (Source: Self made notes: Lectures from ANU, Australia) 

Generally, Meta Analysis is a statistical procedure to combine data from the multiple studies and thus study them.

In actual sense, to conduct a meta analysis it requires a huge costs and knowledge as well that are to be dealt in complex issues such as increasing precision and providing external validity.

● So why Meta Analysis then ? 

♢ Sometimes research might be biased.

♢ The studies are often underpowered.

♢ The studies might be partaially informative about each other.

● How to do it ? 

- Select topic

- Searching

- Screening

- Data Extraction

- Analysis

Let's see its sample process diagram

♢ 1st we see the search resources

♢ Then we search the String developmen.

♢ Then either one of two are chosen: Scripted Scraping Searches and Manual Searches.

♢ Then Duplicate Screening

♢ Again for the Screening Criteria Development the Title Screening are chosen as Double Entry and then followed by Reconciliation.

♢ The reference checking is done

♢ Again duplicate screening

♢ Search results

♢ Again Double Entry and Reconciliation

♢ Finding full text of papers

♢ Then the screened papers.

After these, the process goes out to the data analysis.

● Analysis

The analysis of Fixed Effect: There is one true fixed effects.

Random Effect: True effects may vary by the study.

Mixed Model: True effects may vary by the study, and we can explain some of that.

In STATA the 'metan' package is used wheras in R 'meta' package must be downloaded ( discuss about R and STATA later in upcoming blogs).

We'll see the Heterogeneity of model and Estimating Biases (Funnel Plots, Caliper Tests) in the upcoming parts.

To be contd...

Aditya Pokhrel

MBA, MA Economics, MPA 




Thursday, January 28, 2021

Structural Vector Autoregression (SVAR) modelling basics I - Applied Econometrics

 ■ SVAR (Seld made notes: Reference to IMF reports)

The question may trigger in our mind tha why we need the SVAR? 

Say, we want to know the the affects of the monetary policy in the economy.

So for this let us consider the set of events: 

a) Central bank anticipates an increase in inflation.

b) The central bank increases the monetary policy interest rate, but inflation still rises as anticipated.

Now here, one could wrongly conclude that the interest rate hike led to the rise in the inflation.

However, it was endogenous reaction to expected inflation (monetary policy contraction was endogenous).

Monetary policy reacted to the expected inflation. So, these events reflect the cobtrary to the impact of inflation expectations on the monetary policy.

But in actual sense this is not what we are wanting to measure. Here, we can't say that the impact policy has on the other variables. Simply, this is not the correct way to measure the effects of the monetary policy.

The similar problem applies with the fiscal policy as well.

Suppose, we want to know the effects of fiscal spending on the economy, so let's consider new sequence of the events.

The fiscal authorities anticipate a reduction in private demand and then increase pubkic spending causing an increase in the deficit while total output continues declining for some time.

Say, the wrong conclusion would be the spending multiplier is negative or in other words that the spending hike reduced output. So in actual sense, the fiscal reaction was endogenous. The Fiscal policy reacted to the expected output development.

So, this is not again the way of measuring tge effects of public spending on the economy. So, we can't measure the impact of monetary or fiscal policy when the policy variable is reacting to the movemens of the other variables is reacting to the movements of the other variables. 

In order to measure the effects of the policywhat we really want is to identify or to isolate purely exogenous, purely independent movement or shocks to the variable of the interest and see how the economy reacts to them which is known as the input responses.

Here we want to identify totally exogenous monetary policy rate and to fiscal  spending respectively.

To do this we have to identify the SVAR.

To be contd...

Thank You

Aditya Pokhrel

MBA, MA Economics, MPA


Wednesday, January 27, 2021

ANCOVA model -Part I (Dummy Variables) - (Applied Econometrics)

 ■ Dummy Var (ANCOVA model)

Generally, in ANCOVA models the qualitative variables are only used as regressors. 

Even that those models are extensively used in Sociology, Paychology and Education, ANCOVA models are not quite common in Economics.

The mixture of the qualitative and quantitative variables is common in Economics i.e. explanatory variables as both qualitative and quantitative variables. Such models are known as the ANCOVA models.

□ Analysis of the Co Variance models

In the context of the regression, quantitative explanatory variables are known as co variance, so they are the ANCOVA models.

In ANCOVA models our aim is to asses whether there's a difference between the groups on the basis, say, race, cast, community keeping constant the effect of the quantitative regressors.

Few examples are cited:

ANCOVA is an extension of ANOVA models.

Say, 

Yi = aplha1 + alpha2 D2i + beta Xi + ui

        Where, say, Yi = Annual Salary

                              D2 = 1 = Male

                              D2 = 0 = Female

                              X = Teaching Experience                                             (yrs)

Now say we want to study whether there's the difference between salary of male and female teachers keeping constant, the teaching experience.

Now, assuming that the CLRM is satisfied and E (ui) = 0 the annual salary of a female person is; 

E (Yi/Xi, D2 = 0) = alpha 1 + beta Xi

E (Yi/Xi, D2 = 1) = (alpha1 + alpha2) + betaXi

The hypothese are: 

Ho: aplha2 = 0

Ha: alpha2 is not equal to 0

... keeping the years of teaching constant.

If alpha2 is significant, the null's rejected, then we'll say that there's a discrimination based on gender (sex).

To be contd...

Thank you 

Aditya Pokhrel

MBA, MA Economics, MPA 

Tuesday, January 26, 2021

GMM - Basics (Generalized Method of Moments) (Applied Econometrics)

 ■ GMM

GMM is one of the generic methods to identify the parameters in the statistical models.

It uses the moment conditions that are the functions of the model parameters and the data, such that their exception is zero at the parameters' true values. The GMM is also a dynamic panel estimator.

We know that the Panel data is a Longitudinal data and generally (as discussed in the previous blogs) the T and N should be as.

● The case for GMM

Let's assume the linear regressions with the endogenous regressors,

Y = X' beta + u
               Where, Y and u are the N×1 vectors; beta is a K×1 vector of the unknown parameters.
X is a N×K matrix of explanatory variables.

Because of the assumption of the endogeneity, we assume a matrix Z that is N×L and L>K.

The Z matrix is assumed to comprise a set of variables that are highly correlated with X but orthogonal to u (i.e. a highly set of valid instruments).

● GMM specifies

a) N (Number of cross sections or groups) > T (Time Space).

b) It uses instrumental variable (IV) estimation.

c) The instruments, Z must be exogenous, E(Z',u) = 0

d) Number of instruments,  Z <= number of groups, N.

The GMM estimators are of two kinds:

i) Difference GMM
ii) System GMM

Let's say the GMM is designed to:

- Dynamic Panel Models

- The T is small and large N panels

- The independent variables that are not strictly exogenous, meaning they are correlated with past and possibly current realisation of the error term (endogeneity).

- The fixed effect are arbitrarily idistributed.

- The heteroscedasticity.

- Autocorrelation within the panel or groups.

Basically there are two instruments in GMM:

- Internal Instruments --> gmmstyle ()
- External Instruments --> ivstyle ()

i) Difference GMM

- Arellano and Bond (1991)

1. It coorects endogeneity by:

-Transforming all the regressors through differencing.
-By removing the Fixed Effects

2. The first difference transformations has weakness. It
-Subtracts the previous observations from the contemporaneous one thereby magnifies gaps in the unbalanced panel.

ii) System GMM

Two people Arellano and Bover (1995) and Blundell and Bond  (1998).

- Coorects Endogeneity by:

□ Introducing more instruments to dramatically improve efficiency.

□ Transforms the instruments to make them uncorrelated (exogenous) with the fixed effects.

- Builds a system of two equations: the original equation, the transformed one equation.

- Uses orthogonal deviations: Instead  of subtracting the previous observation from the contemporaneous one, it subtracts the average of all future available observations of a variable. No matter how many gaps, it is computable for all observations of a varable except the last for each ibdividuals so that it minimises the data loss.

To be contd...

Thank you
Aditya Raz Pokhrel 
MBA, MA Economics, MPA


Monday, January 25, 2021

KPSS Unit root testing (Applied Econometrics)

 ■ KPSS test

This test was introduced by the econometrics Kwaisoski, Phillips, Schmidt and Shim so the name was regarded in KPSS test.

This test is quite different from from the Augmented Dicky Fuller Test and Phillip Perron Test. In both the ADF and PP Ho is the process is non stationary and the Ha is stationary.

Now we compare the results with KPSS from PP and ADF.

□ ADF/PP

Ho: Yt = I (1)

Ha: Yt = I (0)

□ KPSS

Ho: Yt = I (0)

Ha: Yt = I (1)

The possible outcomes are follows:

a) Reject Ho and Do not reject Ho.

b) Do not reject Ho and Reject Ho.

c) Reject Ho and Reject Ho.

d) Do not reject Ho and Do not Reject Ho.


Now the last two outcomes are contradictory, 1st two outcomes are consisting. ADF/PP will give us result as unstationary whereas the KPSS would give as stationary.

In such a cases a solution is confirmatory data analysis as suggested in literature.

So, this is the KPSS test.

Thank You

Aditya Pokhrel

MBA, MA Economics, MPA


Regression Discontinuity - How to determine whether it is Sharp or Fuzzy RD ? Simplest Look.           Regression discontinuity design is ga...