#Set working directory setwd("C:/Andrzej/Dydaktyka/econometric_methods/") #Import dataset from CSV dataset <- read.csv("lecture_5_6_sc.csv", header = TRUE, sep = ",", dec = ".") #PART 1 OLS_results <- lm(log_Q_gasoline ~ log_P_gasoline + log_P_new_car + log_P_used_car + log_Income, data = dataset) summary(OLS_results) #PART 2 install.packages("lmtest") library(lmtest) dwtest(OLS_results,alternative="two.sided") # "positive", "negative" #Exercise: write a script to perform the h-Durbin test in the model additionally containing the lagged dependent variable. bgtest(OLS_results, order = 4) install.packages("stats") library(stats) Box.test(OLS_results$residuals, lag = 4, type = "Ljung-Box") acf(OLS_results$residuals, lag.max = 12) pacf(OLS_results$residuals, lag.max = 12) #PART 3 install.packages("sandwich") library(sandwich) Newey.West.Matrix <- vcovHAC(OLS_results) coeftest(OLS_results, df = OLS_results$df.residual, vcov = Newey.West.Matrix) install.packages("orcutt") library(orcutt) cochrane.orcutt(OLS_results) #Exercise 1: test for serial correlation in the estimated production function (data: lecture_5_6_ex1.csv), #in which the log value added (l_valueadd) depends on log labour (l_labour) and log capital (l_capital). #The model includes a constant. If serial correlation is present, attempt to overcome the problem. #Exercise 2: test for serial correlation in the estimated Phillips curve model with static inflation expectations # (data: lecture_5_6_ex2.csv), in which the inflation rate (d_infl) depends on the unemployment rate (unempl). #The model includes a constant. If serial correlation is present, attempt to overcome the problem.