Monday, February 1, 2021

Some Important Codes in R Part II (Applied Econometrics)

 ■ Codes in R contd...

a) Multicollinearity in R

Packages are - car, faraway, VIF, fmsb, HH.

Say, 

#install.packages (faraway)

library (faraway)

model1 = lm (depvar~ind vars)

faraway : : vif (model1)

The result obtained should be less than 5.


b) Serial Correlation in R

Box.Test (var, lag = n, type = "Ljung-Box")

Box.Test (var, lag = n, type = "Box-Pierce")

Serial correlation if exist we can make the model into GARCH.


c) Heteroscedasticity in R

#install.packages (lmtest)

model1 = lm (var1~ var2)

bp test (model1) Breush Pagan test


d) Normality Test

Shapiro - Wilk test

Say a hypothetical test

c < - LC $ variable [1:n]

shapiro.test (c)

If the result p value is more than .05 then the data is normally distributed.


e) Ramsey Test

#install.packages (lmtest)

library (lmtest)

model1 = lm (var 1 ~ var 2)

resettest (model1)

Let's see the results, Ho: There's linearity in model.

If the p value is more than .05 then our null hypothesis is accepted then linearity in the model.


To be contd...

Aditya Pokhrel 

MBA, MA Economics, MPA 



No comments:

Post a Comment

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