library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.2      ✔ purrr   0.3.5 
## ✔ tibble  3.2.1      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.1 
## ✔ readr   2.1.3      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(dplyr)
library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(ggplot2)
library(tseries)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:dplyr':
## 
##     recode
## 
## The following object is masked from 'package:purrr':
## 
##     some
library(readr)
oecd_data <- read_csv("~/Downloads/mydatta.csv")
## Rows: 198 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): country, Indicator, measure
## dbl (2): year, GDS_Res_devel
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(oecd_data)
library(plm)
## 
## Attaching package: 'plm'
## The following objects are masked from 'package:dplyr':
## 
##     between, lag, lead
library(WDI)
wdi_data<-WDI(country =c("CAN", "USA", "ITA", "CZE", "JPN", "FRA", "TUR", "IRL", "POL"),
  indicator = c( "NY.GDP.PCAP.KD.ZG", "BX.KLT.DINV.WD.GD.ZS","SL.UEM.1524.ZS", "SL.TLF.ACTI.1524.NE.ZS", "NE.EXP.GNFS.ZS" ),
start=2000,
end=2021,
extra=FALSE,
cache=NULL)

#Change variable names

library(WDI)
library(dplyr)
my_data<-wdi_data%>%
  rename(country=iso3c,
         count=country,
         FDI_netinflows=BX.KLT.DINV.WD.GD.ZS,
        youth_unemp= SL.UEM.1524.ZS,
        GDP_percapita=NY.GDP.PCAP.KD.ZG,
        lbr_force=SL.TLF.ACTI.1524.NE.ZS,
     net_export  = NE.EXP.GNFS.ZS)

#Combine data

combi_data<-cbind(oecd_data,my_data)
nrow(combi_data)
## [1] 198
combi_data %>%
  is.na()%>%
sum()
## [1] 0

#Declare as a panel data

mydata<-pdata.frame(combi_data, index = c("country", "year"))
head(mydata)
##          country Indicator measure year GDS_Res_devel  count iso2c country.1
## CAN-2000     CAN   GDEXPRD  PC_GDP 2000      1.858470 Canada    CA       CAN
## CAN-2001     CAN   GDEXPRD  PC_GDP 2001      2.021156 Canada    CA       CAN
## CAN-2002     CAN   GDEXPRD  PC_GDP 2002      1.971695 Canada    CA       CAN
## CAN-2003     CAN   GDEXPRD  PC_GDP 2003      1.967807 Canada    CA       CAN
## CAN-2004     CAN   GDEXPRD  PC_GDP 2004      1.997333 Canada    CA       CAN
## CAN-2005     CAN   GDEXPRD  PC_GDP 2005      1.971243 Canada    CA       CAN
##          year.1 GDP_percapita FDI_netinflows youth_unemp lbr_force net_export
## CAN-2000   2000     4.2026826      9.1710243      12.685     64.39   44.20924
## CAN-2001   2001     0.6901612      3.8419213      12.879     64.66   42.03996
## CAN-2002   2002     1.9038520      3.2191477      13.625     66.53   40.05866
## CAN-2003   2003     0.8880302      0.7829676      13.631     67.33   36.86599
## CAN-2004   2004     2.1296309      0.1414659      13.471     66.84   37.32777
## CAN-2005   2005     2.2340594      2.1781638      12.416     65.87   36.85671
nrow(mydata)
## [1] 198
mydata%>%
  is.na()%>%
sum()
## [1] 0
summary(mydata)
##     country    Indicator           measure               year    
##  CAN    :22   Length:198         Length:198         2000   :  9  
##  CZE    :22   Class :character   Class :character   2001   :  9  
##  FRA    :22   Mode  :character   Mode  :character   2002   :  9  
##  IRL    :22                                         2003   :  9  
##  ITA    :22                                         2004   :  9  
##  JPN    :22                                         2005   :  9  
##  (Other):66                                         (Other):144  
##  GDS_Res_devel       count              iso2c            country.1        
##  Min.   :0.4653   Length:198         Length:198         Length:198        
##  1st Qu.:1.0910   Class :character   Class :character   Class :character  
##  Median :1.6042   Mode  :character   Mode  :character   Mode  :character  
##  Mean   :1.7320                                                           
##  3rd Qu.:2.2198                                                           
##  Max.   :3.4678                                                           
##                                                                           
##      year.1     GDP_percapita     FDI_netinflows     youth_unemp    
##  Min.   :2000   Min.   :-8.5958   Min.   :-11.678   Min.   : 3.671  
##  1st Qu.:2005   1st Qu.: 0.6118   1st Qu.:  1.097   1st Qu.:11.008  
##  Median :2010   Median : 1.7623   Median :  2.000   Median :16.608  
##  Mean   :2010   Mean   : 1.9610   Mean   :  4.230   Mean   :17.499  
##  3rd Qu.:2016   3rd Qu.: 3.7156   3rd Qu.:  3.637   3rd Qu.:21.864  
##  Max.   :2021   Max.   :23.2009   Max.   : 81.248   Max.   :42.707  
##                                                                     
##    lbr_force       net_export     
##  Min.   :23.83   Min.   :  9.036  
##  1st Qu.:34.22   1st Qu.: 22.548  
##  Median :40.83   Median : 29.364  
##  Mean   :43.56   Mean   : 39.180  
##  3rd Qu.:52.82   3rd Qu.: 46.668  
##  Max.   :69.37   Max.   :134.415  
## 
glimpse(mydata)
## Rows: 198
## Columns: 14
## $ country        <fct> CAN, CAN, CAN, CAN, CAN, CAN, CAN, CAN, CAN, CAN, CAN, …
## $ Indicator      <pseries> "GDEXPRD", "GDEXPRD", "GDEXPRD", "GDEXPRD", "GDEXPR…
## $ measure        <pseries> "PC_GDP", "PC_GDP", "PC_GDP", "PC_GDP", "PC_GDP", "…
## $ year           <fct> 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2…
## $ GDS_Res_devel  <pseries> 1.858470, 2.021156, 1.971695, 1.967807, 1.997333, 1…
## $ count          <pseries> "Canada", "Canada", "Canada", "Canada", "Canada", "…
## $ iso2c          <pseries> "CA", "CA", "CA", "CA", "CA", "CA", "CA", "CA", "CA…
## $ country.1      <pseries> "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "CAN", "C…
## $ year.1         <pseries> 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 200…
## $ GDP_percapita  <pseries> 4.20268257, 0.69016125, 1.90385200, 0.88803015, 2.1…
## $ FDI_netinflows <pseries> 9.1710243, 3.8419213, 3.2191477, 0.7829676, 0.14146…
## $ youth_unemp    <pseries> 12.685, 12.879, 13.625, 13.631, 13.471, 12.416, 11.…
## $ lbr_force      <pseries> 64.39, 64.66, 66.53, 67.33, 66.84, 65.87, 66.24, 66…
## $ net_export     <pseries> 44.20924, 42.03996, 40.05866, 36.86599, 37.32777, 3…
#Run a simple linear regression 
library(knitr)
library(car)
library(tidymodels)
## ── Attaching packages ────────────────────────────────────── tidymodels 1.0.0 ──
## ✔ broom        1.0.1     ✔ rsample      1.1.0
## ✔ dials        1.1.0     ✔ tune         1.0.1
## ✔ infer        1.0.3     ✔ workflows    1.1.2
## ✔ modeldata    1.0.1     ✔ workflowsets 1.0.0
## ✔ parsnip      1.0.3     ✔ yardstick    1.1.0
## ✔ recipes      1.0.3
## ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
## ✖ plm::between()    masks dplyr::between()
## ✖ scales::discard() masks purrr::discard()
## ✖ dplyr::filter()   masks stats::filter()
## ✖ recipes::fixed()  masks stringr::fixed()
## ✖ plm::lag()        masks dplyr::lag(), stats::lag()
## ✖ plm::lead()       masks dplyr::lead()
## ✖ car::recode()     masks dplyr::recode()
## ✖ car::some()       masks purrr::some()
## ✖ yardstick::spec() masks readr::spec()
## ✖ recipes::step()   masks stats::step()
## • Search for functions across packages at https://www.tidymodels.org/find/
OLS_simple<-lm(GDP_percapita~GDS_Res_devel, data=mydata)
kable(tidy(OLS_simple))
term estimate std.error statistic p.value
(Intercept) 2.7782796 0.6026574 4.610048 0.0000072
GDS_Res_devel -0.4718742 0.3148141 -1.498898 0.1355090
OLS<-lm(GDP_percapita~ GDS_Res_devel+FDI_netinflows+net_export, data=mydata)
kable(tidy(OLS))
term estimate std.error statistic p.value
(Intercept) 2.2687966 0.5507179 4.119707 0.0000561
GDS_Res_devel -1.1575621 0.3214476 -3.601091 0.0004025
FDI_netinflows 0.1326912 0.0363034 3.655063 0.0003310
net_export 0.0289881 0.0116581 2.486517 0.0137445
library(ggfortify)
## Registered S3 method overwritten by 'ggfortify':
##   method          from   
##   autoplot.glmnet parsnip
autoplot(OLS)

Fixed effects using Least squares dummy variable model

Section 1: Building 4 panel data models for our data

#1: Pooled(OLS)

library(plm)
pooled<-plm(GDP_percapita~ GDS_Res_devel+FDI_netinflows+net_export, data=mydata,
             index=c("country", "year"), model="pooling")
summary(pooled)
## Pooling Model
## 
## Call:
## plm(formula = GDP_percapita ~ GDS_Res_devel + FDI_netinflows + 
##     net_export, data = mydata, model = "pooling", index = c("country", 
##     "year"))
## 
## Balanced Panel: n = 9, T = 22, N = 198
## 
## Residuals:
##      Min.   1st Qu.    Median   3rd Qu.      Max. 
## -11.50405  -1.17746   0.14958   1.69368   9.18980 
## 
## Coefficients:
##                 Estimate Std. Error t-value  Pr(>|t|)    
## (Intercept)     2.268797   0.550718  4.1197 5.614e-05 ***
## GDS_Res_devel  -1.157562   0.321448 -3.6011 0.0004025 ***
## FDI_netinflows  0.132691   0.036303  3.6551 0.0003310 ***
## net_export      0.028988   0.011658  2.4865 0.0137445 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    2586.1
## Residual Sum of Squares: 2026.1
## R-Squared:      0.21653
## Adj. R-Squared: 0.20442
## F-statistic: 17.8725 on 3 and 194 DF, p-value: 2.7736e-10

#2: Random

library(plm)
Random<-plm(GDP_percapita~ GDS_Res_devel+FDI_netinflows+net_export, data=mydata,
            index=c("country", "year"),  model="random")
summary(Random)
## Oneway (individual) effect Random Effect Model 
##    (Swamy-Arora's transformation)
## 
## Call:
## plm(formula = GDP_percapita ~ GDS_Res_devel + FDI_netinflows + 
##     net_export, data = mydata, model = "random", index = c("country", 
##     "year"))
## 
## Balanced Panel: n = 9, T = 22, N = 198
## 
## Effects:
##                  var std.dev share
## idiosyncratic 9.3593  3.0593 0.961
## individual    0.3836  0.6194 0.039
## theta: 0.2749
## 
## Residuals:
##      Min.   1st Qu.    Median   3rd Qu.      Max. 
## -11.44461  -1.03006   0.22245   1.43129   8.15542 
## 
## Coefficients:
##                 Estimate Std. Error z-value  Pr(>|z|)    
## (Intercept)     2.246106   0.722650  3.1082  0.001883 ** 
## GDS_Res_devel  -1.250791   0.414441 -3.0180  0.002544 ** 
## FDI_netinflows  0.150058   0.036224  4.1425 3.435e-05 ***
## net_export      0.031813   0.013653  2.3302  0.019796 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    2385.6
## Residual Sum of Squares: 1929.5
## R-Squared:      0.19119
## Adj. R-Squared: 0.17868
## Chisq: 45.8573 on 3 DF, p-value: 6.0819e-10

#3: fixed effects model

fixed <-plm(GDP_percapita~ GDS_Res_devel+FDI_netinflows+net_export, data=mydata,
             index=c("country", "year"), model="within")
summary(fixed)
## Oneway (individual) effect Within Model
## 
## Call:
## plm(formula = GDP_percapita ~ GDS_Res_devel + FDI_netinflows + 
##     net_export, data = mydata, model = "within", index = c("country", 
##     "year"))
## 
## Balanced Panel: n = 9, T = 22, N = 198
## 
## Residuals:
##     Min.  1st Qu.   Median  3rd Qu.     Max. 
## -11.6399  -0.8459   0.4017   1.3942   7.6627 
## 
## Coefficients:
##                 Estimate Std. Error t-value  Pr(>|t|)    
## GDS_Res_devel  -2.324032   1.062215 -2.1879 0.0299227 *  
## FDI_netinflows  0.185323   0.036455  5.0836 8.987e-07 ***
## net_export      0.101807   0.028193  3.6110 0.0003922 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    2163.3
## Residual Sum of Squares: 1740.8
## R-Squared:      0.19529
## Adj. R-Squared: 0.1477
## F-statistic: 15.046 on 3 and 186 DF, p-value: 8.2732e-09

#4:Time-fixed effects model

fixed.time <- plm(GDP_percapita ~ GDS_Res_devel + FDI_netinflows+net_export+factor(year), data=mydata, index=c("country","year"), model="within")
summary(fixed.time)
## Oneway (individual) effect Within Model
## 
## Call:
## plm(formula = GDP_percapita ~ GDS_Res_devel + FDI_netinflows + 
##     net_export + factor(year), data = mydata, model = "within", 
##     index = c("country", "year"))
## 
## Balanced Panel: n = 9, T = 22, N = 198
## 
## Residuals:
##      Min.   1st Qu.    Median   3rd Qu.      Max. 
## -10.14876  -0.98740  -0.10327   0.93880   6.05823 
## 
## Coefficients:
##                   Estimate Std. Error t-value  Pr(>|t|)    
## GDS_Res_devel    -0.173232   0.962814 -0.1799 0.8574344    
## FDI_netinflows    0.167115   0.027017  6.1856 4.704e-09 ***
## net_export        0.088673   0.023075  3.8429 0.0001732 ***
## factor(year)2001 -3.461052   1.007083 -3.4367 0.0007452 ***
## factor(year)2002 -2.373839   1.004552 -2.3631 0.0192884 *  
## factor(year)2003 -1.787673   1.008989 -1.7717 0.0782822 .  
## factor(year)2004  0.115139   1.013168  0.1136 0.9096592    
## factor(year)2005 -1.065914   1.005158 -1.0604 0.2904923    
## factor(year)2006 -1.023189   1.008449 -1.0146 0.3117742    
## factor(year)2007 -1.856284   1.010723 -1.8366 0.0680697 .  
## factor(year)2008 -4.585767   1.019484 -4.4981 1.288e-05 ***
## factor(year)2009 -8.094483   1.028011 -7.8739 4.347e-13 ***
## factor(year)2010 -1.558586   1.028402 -1.5155 0.1315488    
## factor(year)2011 -1.787124   1.042041 -1.7150 0.0882184 .  
## factor(year)2012 -4.192751   1.052198 -3.9848 0.0001012 ***
## factor(year)2013 -3.623479   1.059038 -3.4215 0.0007852 ***
## factor(year)2014 -2.825941   1.076867 -2.6242 0.0094997 ** 
## factor(year)2015 -1.333195   1.072754 -1.2428 0.2157131    
## factor(year)2016 -3.873575   1.060959 -3.6510 0.0003503 ***
## factor(year)2017 -1.180737   1.079095 -1.0942 0.2754657    
## factor(year)2018 -2.166083   1.102068 -1.9655 0.0510383 .  
## factor(year)2019 -2.613205   1.132201 -2.3081 0.0222363 *  
## factor(year)2020 -8.104304   1.149955 -7.0475 4.719e-11 ***
## factor(year)2021  1.744280   1.145843  1.5223 0.1298561    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    2163.3
## Residual Sum of Squares: 747.81
## R-Squared:      0.65432
## Adj. R-Squared: 0.58727
## F-statistic: 13.0131 on 24 and 165 DF, p-value: < 2.22e-16

Section 2: Model diagnostics. Which model is the best for our data.

#(i) Pooled vs Random

Breusch-Pagan Lagrange Multiplier for random effects. Null is no panel effect (i.e. OLS better).

plmtest(pooled, type = c("bp"))
## 
##  Lagrange Multiplier Test - (Breusch-Pagan)
## 
## data:  GDP_percapita ~ GDS_Res_devel + FDI_netinflows + net_export
## chisq = 5.6663, df = 1, p-value = 0.01729
## alternative hypothesis: significant effects

Here we reject the null and conclude that random effects is appropriate. This is, no evidence of significant differences across countries, therefore we could run a simple OLS regression if were to choose between the two. We need to compare OLS to fixed and see which one is more appropriate.

-OLS wins

#(ii) pooled vs fixed

#After constructing an OLS model, we can also run a pFtest to see which is the better fitted model.

#The null hypothesis of the pFtest is OLS is better than fixed.

pFtest(fixed, pooled)
## 
##  F test for individual effects
## 
## data:  GDP_percapita ~ GDS_Res_devel + FDI_netinflows + net_export
## F = 3.8105, df1 = 8, df2 = 186, p-value = 0.0003613
## alternative hypothesis: significant effects

Reject the null, we go for fixed. -fixed effect model wins

#(iii) Random vs fixed

phtest(fixed, Random)
## 
##  Hausman Test
## 
## data:  GDP_percapita ~ GDS_Res_devel + FDI_netinflows + net_export
## chisq = 16.913, df = 3, p-value = 0.0007366
## alternative hypothesis: one model is inconsistent

We use fixed since p<0.05.

-Fixed model wins

#(iv) Fixed-time effecs model vs fixed

The null is that no time-fixed effects are needed: We conduct two tests for consistency.

#Test 1

pFtest(fixed.time, fixed)
## 
##  F test for individual effects
## 
## data:  GDP_percapita ~ GDS_Res_devel + FDI_netinflows + net_export +  ...
## F = 10.433, df1 = 21, df2 = 165, p-value < 2.2e-16
## alternative hypothesis: significant effects

p-value<0.05 .We reject null. We need to use time-fixed effects model(fixed.time)

#Test 2

plmtest(fixed, c("time"), type=("bp"))
## 
##  Lagrange Multiplier Test - time effects (Breusch-Pagan)
## 
## data:  GDP_percapita ~ GDS_Res_devel + FDI_netinflows + net_export
## chisq = 162.47, df = 1, p-value < 2.2e-16
## alternative hypothesis: significant effects

p-value<0.05 .We reject null. We need to use time-fixed effects model(fixed.time). It is consistent with test 1.

Section 3: Checking model assumptions(fixed time effects model)

#a) Cross-sectional dependence testing:

#H0: The null is that there is no cross-sectional dependence

pcdtest(fixed.time, test = c("cd"))
## 
##  Pesaran CD test for cross-sectional dependence in panels
## 
## data:  GDP_percapita ~ GDS_Res_devel + FDI_netinflows + net_export +     factor(year)
## z = -1.7352, p-value = 0.08271
## alternative hypothesis: cross-sectional dependence

Since p_value > 0.05,we fail to reject the null. This means that there is no cross-sectional dependence.

-In our diagnostics, we will use the time-fixed effect model as we have chosen it as the most appropriate

b) Serial correlation testing

Serial correlation tests apply to macro panels with long time series. Not a problem in micro panels (with very few years

#H0) The null is that there is not serial correlation.

pbgtest(fixed.time)
## 
##  Breusch-Godfrey/Wooldridge test for serial correlation in panel models
## 
## data:  GDP_percapita ~ GDS_Res_devel + FDI_netinflows + net_export +  ...
## chisq = 37.259, df = 22, p-value = 0.02215
## alternative hypothesis: serial correlation in idiosyncratic errors

Since p-value < 0.05, we reject the null and conclude that there is serial correlation.

c) Unit roots/stationarity testing

#H0) The null hypothesis is that the series has a unit root (i.e. non-stationary)

library(tseries)
adf.test(mydata$GDP_percapita, k=2)
## Warning in adf.test(mydata$GDP_percapita, k = 2): p-value smaller than printed
## p-value
## 
##  Augmented Dickey-Fuller Test
## 
## data:  mydata$GDP_percapita
## Dickey-Fuller = -6.2306, Lag order = 2, p-value = 0.01
## alternative hypothesis: stationary

Since p-value < 0.05, we conclude that the series does NOT have unit root. In other words, the series is stationary.

d) Heteroskedasticity testing

#H0:The null hypothesis for the Breusch-Pagan test is homoskedasticity

library(lmtest)
bptest( GDP_percapita ~ GDS_Res_devel+ factor(country), data = mydata, studentize=F)
## 
##  Breusch-Pagan test
## 
## data:  GDP_percapita ~ GDS_Res_devel + factor(country)
## BP = 90.161, df = 9, p-value = 1.511e-15

Because p-value < 0.05, we reject Ho; We detect heteroskedasticity

#Section 4: coefficient estimations and significance

# Original coefficients
coeftest(fixed.time)
## 
## t test of coefficients:
## 
##                   Estimate Std. Error t value  Pr(>|t|)    
## GDS_Res_devel    -0.173232   0.962814 -0.1799 0.8574344    
## FDI_netinflows    0.167115   0.027017  6.1856 4.704e-09 ***
## net_export        0.088673   0.023075  3.8429 0.0001732 ***
## factor(year)2001 -3.461052   1.007083 -3.4367 0.0007452 ***
## factor(year)2002 -2.373839   1.004552 -2.3631 0.0192884 *  
## factor(year)2003 -1.787673   1.008989 -1.7717 0.0782822 .  
## factor(year)2004  0.115139   1.013168  0.1136 0.9096592    
## factor(year)2005 -1.065914   1.005158 -1.0604 0.2904923    
## factor(year)2006 -1.023189   1.008449 -1.0146 0.3117742    
## factor(year)2007 -1.856284   1.010723 -1.8366 0.0680697 .  
## factor(year)2008 -4.585767   1.019484 -4.4981 1.288e-05 ***
## factor(year)2009 -8.094483   1.028011 -7.8739 4.347e-13 ***
## factor(year)2010 -1.558586   1.028402 -1.5155 0.1315488    
## factor(year)2011 -1.787124   1.042041 -1.7150 0.0882184 .  
## factor(year)2012 -4.192751   1.052198 -3.9848 0.0001012 ***
## factor(year)2013 -3.623479   1.059038 -3.4215 0.0007852 ***
## factor(year)2014 -2.825941   1.076867 -2.6242 0.0094997 ** 
## factor(year)2015 -1.333195   1.072754 -1.2428 0.2157131    
## factor(year)2016 -3.873575   1.060959 -3.6510 0.0003503 ***
## factor(year)2017 -1.180737   1.079095 -1.0942 0.2754657    
## factor(year)2018 -2.166083   1.102068 -1.9655 0.0510383 .  
## factor(year)2019 -2.613205   1.132201 -2.3081 0.0222363 *  
## factor(year)2020 -8.104304   1.149955 -7.0475 4.719e-11 ***
## factor(year)2021  1.744280   1.145843  1.5223 0.1298561    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

#arellano - both heteroskedasticity and serial correlation are present. Recommended for fixed effects.

# Heteroskedasticity consistent coefficients (Arellano)
coeftest(fixed, vcovHC(fixed.time, method = "arellano"))
## 
## t test of coefficients:
## 
##                  Estimate Std. Error t value  Pr(>|t|)    
## GDS_Res_devel  -2.3240319  0.8014973 -2.8996  0.004186 ** 
## FDI_netinflows  0.1853229  0.0095512 19.4031 < 2.2e-16 ***
## net_export      0.1018067  0.0412928  2.4655  0.014589 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Considering the data provided, we conclude that Gross domestic spending on R&D is negatively correlated with GDP per capita growth (annual %). 1 percent increase in Gross domestic spending on R&D decreases annual GDP per capita growth by -2.32 % with p-value of 0.004186 .This result is statistically significant at 5% significant level since p-value < 0.05.