chooseCRANmirror(graphics = TRUE, ind=1)
knitr::opts_chunk$set(echo = TRUE)
setwd("~/Desktop")
pr=read.csv("productivity.csv")
wage=read.csv("wage.csv")
tech=read.csv("tech.csv")
cap=read.csv("cap.csv")
tr=read.csv("trade.csv")
install.packages("dplyr")
## 
## The downloaded binary packages are in
##  /var/folders/tg/ndf9pfq972n0nl0yrwftf9rh0000gn/T//Rtmpbc6uyU/downloaded_packages
library(dplyr)
install.packages("car")
## 
## The downloaded binary packages are in
##  /var/folders/tg/ndf9pfq972n0nl0yrwftf9rh0000gn/T//Rtmpbc6uyU/downloaded_packages
library(car)
pr=pr%>%inner_join(wage,by="year")
pr=pr%>%inner_join(tech,by="year")
pr=pr%>%inner_join(cap,by="year")
pr=pr%>%inner_join(tr,by="year")
install.packages("ggplot2")
## 
## The downloaded binary packages are in
##  /var/folders/tg/ndf9pfq972n0nl0yrwftf9rh0000gn/T//Rtmpbc6uyU/downloaded_packages
library(ggplot2)

# Short-run Regressions
r1=lm(GDP_per_hour_worked~real_wage, pr)
summary(r1)
## 
## Call:
## lm(formula = GDP_per_hour_worked ~ real_wage, data = pr)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -6.6827 -1.9640 -0.7272  1.9728  9.7771 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -1.7286    10.0406  -0.172    0.865    
## real_wage     1.0355     0.1124   9.214 1.13e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.329 on 26 degrees of freedom
## Multiple R-squared:  0.7655, Adjusted R-squared:  0.7565 
## F-statistic: 84.89 on 1 and 26 DF,  p-value: 1.134e-09
r2=lm(real_wage~GDP_per_hour_worked, pr)
summary(r2)
## 
## Call:
## lm(formula = real_wage ~ GDP_per_hour_worked, data = pr)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.2697 -2.2425  0.2673  2.6193  6.6973 
## 
## Coefficients:
##                     Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         22.15522    7.29251   3.038  0.00536 ** 
## GDP_per_hour_worked  0.73930    0.08024   9.214 1.13e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.658 on 26 degrees of freedom
## Multiple R-squared:  0.7655, Adjusted R-squared:  0.7565 
## F-statistic: 84.89 on 1 and 26 DF,  p-value: 1.134e-09
# Real wage over years
ggplot(pr, aes(x=year, y=real_wage))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("Real wage over years")

# Labour productivity over years
ggplot(pr, aes(x=year, y=GDP_per_hour_worked))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("Labour productivity over years")

# higher real wage increases labour productivity?
ggplot(pr, aes(x=real_wage, y=GDP_per_hour_worked))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("labour productivity against real wage")

# higher labour productivity demands higher real wage?
ggplot(pr, aes(x=GDP_per_hour_worked, y=real_wage))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("real wage against labour productivity")

# Long-run regressions
# Productivity and real wage and other exogenous factors
r3=lm(GDP_per_hour_worked~real_wage+R_D+Capital+trade_union, pr)
summary(r3)
## 
## Call:
## lm(formula = GDP_per_hour_worked ~ real_wage + R_D + Capital + 
##     trade_union, data = pr)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.2832 -0.5430  0.2327  0.7664  1.6049 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1.045e+02  7.458e+00  14.016 9.40e-13 ***
## real_wage   -1.130e-02  8.164e-02  -0.138  0.89109    
## R_D          6.484e+00  2.003e+00   3.237  0.00364 ** 
## Capital     -1.733e-04  3.153e-03  -0.055  0.95664    
## trade_union -1.281e+00  9.114e-02 -14.051 8.92e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.284 on 23 degrees of freedom
## Multiple R-squared:  0.9818, Adjusted R-squared:  0.9786 
## F-statistic: 309.5 on 4 and 23 DF,  p-value: < 2.2e-16
# Potential factors influencing real wage in the LR
r4=lm(real_wage~trade_union,pr)
summary(r4)
## 
## Call:
## lm(formula = real_wage ~ trade_union, data = pr)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -8.0524 -2.1550 -0.5727  2.4166  8.6726 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 115.2220     3.2556  35.391  < 2e-16 ***
## trade_union  -1.1398     0.1379  -8.263 9.59e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.967 on 26 degrees of freedom
## Multiple R-squared:  0.7242, Adjusted R-squared:  0.7136 
## F-statistic: 68.28 on 1 and 26 DF,  p-value: 9.595e-09
r5=lm(real_wage~R_D,pr)
summary(r5)
## 
## Call:
## lm(formula = real_wage ~ R_D, data = pr)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -11.8319  -1.7022   0.3466   2.4314   4.7486 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   33.408      5.591   5.976 2.62e-06 ***
## R_D           21.905      2.186  10.019 2.04e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.427 on 26 degrees of freedom
## Multiple R-squared:  0.7943, Adjusted R-squared:  0.7864 
## F-statistic: 100.4 on 1 and 26 DF,  p-value: 2.038e-10
r6=lm(real_wage~Capital,pr)
summary(r6)
## 
## Call:
## lm(formula = real_wage ~ Capital, data = pr)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9.9619 -3.0435  0.4398  3.4379  8.6539 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 62.501512   5.253536  11.897 5.07e-12 ***
## Capital      0.042918   0.008338   5.147 2.28e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5.317 on 26 degrees of freedom
## Multiple R-squared:  0.5047, Adjusted R-squared:  0.4857 
## F-statistic: 26.49 on 1 and 26 DF,  p-value: 2.279e-05
# Capital investment over years
ggplot(pr, aes(x=year, y=Capital))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("Capital investment over years")

# Trade Union influence over years
ggplot(pr, aes(x=year, y=trade_union))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("Trade union impact over years")

# R&D spending over years
ggplot(pr, aes(x=year, y=R_D))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("technology over years")

# Trade union affects wage setting?
ggplot(pr, aes(x=trade_union, y=real_wage))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("Real wage against trade union")

# technology leads to higher productivity?
ggplot(pr, aes(x=R_D, y=GDP_per_hour_worked))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("labour productivity against technology")

# Capital investment over years
ggplot(pr, aes(x=year, y=Capital))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("capital investment over years")

# Capital investment leads to higher productivity?
ggplot(pr, aes(x=Capital, y=GDP_per_hour_worked))+geom_point(shape=20,size=2,color='light blue')+geom_smooth(method=lm,color=' blue')+theme_minimal()+ggtitle("labour productivity against capital investment")