# Abriendo librerias
library(readxl)
library(sqldf)
## Loading required package: gsubfn
## Loading required package: proto
## Loading required package: RSQLite
library(moments)
library(tseries)
library(forecast)
library(ggplot2)
library(zoo)
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(lmtest)

# Asignando opciones al Script
options(digits = 2)
options(OutDec= ",")
#options(OutDec= ",")  # restore default value
sep.miles <- function(x){
  format(x,big.mark=".")}
fmt.porcen <- function(x){
  paste(format(round(x,2),decimal.mark = ","),'%')}
# Descargando la Base de Datos
BBDD <- read_excel("C:/Users/samora/OneDrive/Estudios/universidad/Desarrollo económico/Taller/BBDD.xls", 
                   sheet = "pwt71_wo_country_names_wo_g_var")
DEF <- read_excel("C:/Users/samora/OneDrive/Estudios/universidad/Desarrollo económico/Taller/BBDD.xls", 
                  sheet = "pwt70_vars")
COLDATA <- sqldf("SELECT * FROM BBDD WHERE isocode in ('COL')")

# Sustrayendo inofmración necesaria de la Base de datos, lenguaje usado en SQL
COL <- sqldf("SELECT year, POP, rgdpch, rgdpwok, ki FROM COLDATA WHERE isocode in ('COL')")
View(sep.miles(COL)) # separando valores en miles
# Valores faltantes en el Data
COL$Y <- c(COL$POP * COL$rgdpwok)
COL$Inversión <- c(COL$Y * COL$ki)
lim <- NROW(COL$ki)
COL$mean.ki <- mean(COL$ki)
COL$K <- c(c(COL$mean.ki * COL$Y * 0.01) / 0.1)
COL$PIBperCapita <- c(COL$Y / COL$POP)
COL$L <- c(COL$Y / c(COL$rgdpch * COL$rgdpwok))
COL$A <- c(COL$Y / c((COL$K ^ 0.36) * c(COL$L ^ c(1 - 0.36))))

# Crendo metodo para hacer vectores
Vectores <- function(x,y){
  X <- data.frame(x, check.names = TRUE)
  names(X)[1] <- y
  return(X)
}

# Asignando nombres a los vectores
POP <- Vectores(COL$POP,"POP")
rgdpch <- Vectores(COL$rgdpch, "rgdpch")
rgdpwok <- Vectores(COL$rgdpwok, "rgdpwok")
ki <- Vectores(COL$ki, "ki")
year <- Vectores(COL$year, "Year")
Y <- Vectores(COL$Y, "Y")
Inversion <- Vectores(COL$Inversión, "Inversión")
K <- Vectores(COL$K, "K")
PIBprCapita <- Vectores(COL$PIBperCapita, "Pib per Capita")
L <- Vectores(COL$L, "L")
A <- Vectores(COL$A, "A")
#Analsis descreiptivo por variable, creando un metodo
Descriptivo <- function(x){
  numeroFilas <- NROW(x)
  X <- x[2:numeroFilas,]
  as.numeric(X)
  library(moments)
  medianx <- median(X)
  meanx <- mean(X)
  sdx <- sd(X)
  kurtosisx <- kurtosis(X)
  skewnessx <- skewness(X)
  minx <- min(X)
  maxx <- max(X)
  #quantilex <- quantile(x)
  Descriptivox <- data.frame(medianx,
                             meanx,
                             sdx,
                             kurtosisx,
                             skewnessx,
                             minx,maxx)
  return(Descriptivox)
}

# Aplicando metodo a variables
POP.Descriptivo <- Descriptivo(POP)
rgdpch.Descriptivo <- Descriptivo(rgdpch)
rgdpwok.Descriptivo <- Descriptivo(rgdpwok)
ki.Descriptivo <- Descriptivo(ki)
Y.Descriptivo <- Descriptivo(Y)
Inversion.Descriptivo <- Descriptivo(Inversion)
K.Descriptivo <- Descriptivo(K)
PIBprCapita.Descriptivo <- Descriptivo(PIBprCapita)
L.Descriptivo <- Descriptivo(L)
A.Descriptivo <- Descriptivo(A)
#Creando matriz con análisis descriptivo
matrix.desciptivo <- rbind(sep.miles(POP.Descriptivo),
                           sep.miles(rgdpch.Descriptivo),
                           sep.miles(rgdpwok.Descriptivo),
                           sep.miles(ki.Descriptivo),
                           format(Y.Descriptivo, scientific=FALSE, big.mark="."),
                           format(Inversion.Descriptivo, scientific=FALSE, big.mark="."),
                           format(K.Descriptivo, scientific=FALSE, big.mark="."),
                           sep.miles(PIBprCapita.Descriptivo),
                           sep.miles(L.Descriptivo),
                           sep.miles(A.Descriptivo))
variables <- c("POP", "rgdpch", "rgdpwok", "ki",
               "Y", "Inversion", "K", "PIB per Capita", "L", "A")
row.names(matrix.desciptivo) <- variables
matrix.desciptivo
##                      medianx         meanx           sdx kurtosisx
## POP                   26.923        27.608         9.895       1,7
## rgdpch                 4.972         4.696         1.419       1,9
## rgdpwok               14.657        13.698         2.611         2
## ki                        19            19           2,8       2,7
## Y                453.267.876   396.435.735   181.177.128       1,8
## Inversion      7.474.394.020 7.622.098.473 4.158.897.811       2,6
## K                860.423.425   752.540.851   343.922.552       1,8
## PIB per Capita        14.657        13.698         2.611         2
## L                        5,9           5,8          0,54       3,2
## A                     88.171        79.243        22.939       1,8
##                skewnessx          minx           maxx
## POP                0,062        11.965         44.205
## rgdpch              0,14         2.583          7.536
## rgdpwok            -0,62         8.107         16.949
## ki                  0,38            13             25
## Y                  -0,18    97.005.027    700.272.290
## Inversion           0,63 1.815.566.547 17.424.074.687
## K                  -0,18   184.141.437  1.329.303.739
## PIB per Capita     -0,62         8.107         16.949
## L                  -0,45           4,5            6,8
## A                   -0,3        38.477        117.237
# Aplicando descriptivo por Cuantiles
summary(COL)
##       year           POP            rgdpch        rgdpwok     
##  Min.   :1950   Min.   :11592   Min.   :2583   Min.   : 8107  
##  1st Qu.:1965   1st Qu.:18646   1st Qu.:3234   1st Qu.:11434  
##  Median :1980   Median :26631   Median :4959   Median :14555  
##  Mean   :1980   Mean   :27345   Mean   :4662   Mean   :13607  
##  3rd Qu.:1995   3rd Qu.:36532   3rd Qu.:5797   3rd Qu.:15817  
##  Max.   :2010   Max.   :44205   Max.   :7536   Max.   :16949  
##        ki             Y              Inversión           mean.ki  
##  Min.   :12,9   Min.   :9,46e+07   Min.   :1,82e+09   Min.   :19  
##  1st Qu.:17,2   1st Qu.:2,09e+08   1st Qu.:3,55e+09   1st Qu.:19  
##  Median :18,6   Median :4,51e+08   Median :7,34e+09   Median :19  
##  Mean   :19,0   Mean   :3,91e+08   Mean   :7,53e+09   Mean   :19  
##  3rd Qu.:20,3   3rd Qu.:5,24e+08   3rd Qu.:9,34e+09   3rd Qu.:19  
##  Max.   :25,0   Max.   :7,00e+08   Max.   :1,74e+10   Max.   :19  
##        K             PIBperCapita         L             A         
##  Min.   :1,79e+08   Min.   : 8107   Min.   :4,4   Min.   : 38477  
##  1st Qu.:3,96e+08   1st Qu.:11434   1st Qu.:5,4   1st Qu.: 55366  
##  Median :8,57e+08   Median :14555   Median :5,9   Median : 88082  
##  Mean   :7,43e+08   Mean   :13607   Mean   :5,8   Mean   : 78583  
##  3rd Qu.:9,95e+08   3rd Qu.:15817   3rd Qu.:6,1   3rd Qu.: 94731  
##  Max.   :1,33e+09   Max.   :16949   Max.   :6,8   Max.   :117237
# Creando Metodo para graficar Serie de Tiempo
grafico <- function(X){
  tittle <- paste("variable", names(X))
  color <- paste("",names(X),"")
  
  plot.X <- ggplot(data = COL,
                   aes(y = X,
                       x = year,
                       colour=color))+geom_line(
                         
                       )+geom_point(
                         
                       )+ggtitle(
                         tittle
                       )+xlab(
                         "Year"
                       )+ylab(
                         color)
  return(plot.X)
}

# Grafico de Serie de tiempo
POP.grafico <- grafico(POP)
POP.grafico
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

rgdpch.grafico <- grafico(rgdpch)
rgdpch.grafico
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

rgdpwok.grafico <- grafico(rgdpwok)
rgdpwok.grafico
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

ki.grafico <- grafico(ki)
ki.grafico
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

Y.grafico <- grafico(Y)
Y.grafico
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

Inversion.grafico <- grafico(Inversion)
Inversion.grafico
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

K.grafico <- grafico(K)
K.grafico
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

PIBprCapita.grafico <- grafico(PIBprCapita)
PIBprCapita.grafico
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

L.grafico <- grafico(L)
L.grafico
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

A.grafico <- grafico(A)
A.grafico
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

# Creando Metodo para graficar Histograma
histograma <- function(x){
  tittle <- paste("variable", names(x))
  color <- paste("",names(x),"")
  
  plot.histo <- ggplot(data = COL,
                       aes(x),
                       colour=color
                       )+geom_freqpoly(
                         binwidth = 500
                       )+geom_histogram(
                         binwidth = 500
                       )+scale_y_sqrt(
                       )+ggtitle(
                         tittle
                       )+xlab(
                         "Year"
                       )+ylab(
                         color)
  #Plot.histox <- hist(x[2:61,])
  return(plot.histo)
}

# Finalmente el loop es
# for(var in seq_along(variables.list)) {
#   # Graficando Histogramas
#   POP$Type <- c("POP")
#   names(POP)[1] <- "Variable"
#   rgdpch$Type <- c("rgdpch")
#   names(rgdpch)[1] <- "Variable"
#   rgdpwok$Type <- c("rgdpwok")
#   names(rgdpwok)[1] <- "Variable"
#   ki$Type <- c("ki")
#   names(ki)[1] <- "Variable"
#   COLvar <- as.data.frame(rbind(POP, rgdpch, rgdpwok, ki))
#   variables.list <- unique(COLvar$Type)
#   
#   C = 1 # Contadora dentro del loop
#  var <- variables.list[C]
#  histo <- subset(COLvar, Type == var)
#  histogr <- histograma(histo$Variable)
#  print(histogr)
#  C = C + 1
#}
# Formateando valores grandes
Y <- format(Y, scientific=FALSE, big.mark=".")
K <- format(K, scientific=FALSE, big.mark=".")
Inversion <- format(Inversion, scientific=FALSE, big.mark=".")


POP.histograma <- histograma(POP)
rgdpch.histograma <- histograma(rgdpch)
rgdpwok.histograma <- histograma(rgdpwok)
ki.histograma <- histograma(ki)
Y.histograma <- histograma(Y)
Inversion.histograma <- histograma(Inversion)
K.histograma <- histograma(K)
PIBprCapita.histograma <- histograma(PIBprCapita)
L.histograma <- histograma(L)
A.histograma <- histograma(A)
# Creando metodo para graficar relaciones individuales
relacion <- function(X,Y){
  tittle <- paste("Relación entre ", names(X), "-",names(Y))
  colorUno <- paste("",names(X),"")
  colorDos <- paste("",names(Y),"")
  color <- paste(names(X),"-",names(Y))
  
  Relacion <- ggplot(data = COL,
                   aes(y = X,
                       x = Y,
                       colour=color))+geom_point(
                         
                       )+ggtitle(
                         tittle
                       )+xlab(
                         colorDos
                       )+ylab(
                         colorUno)
  
  return(Relacion)
}

# Relaciones Globales
pairs(COL)

cov(COL)
##                 year     POP  rgdpch rgdpwok       ki       Y Inversión
## year         3,2e+02 1,8e+05 2,5e+04 3,6e+04  5,2e+00 3,2e+09   6,6e+10
## POP          1,8e+05 1,0e+08 1,4e+07 2,0e+07  3,2e+03 1,8e+12   3,7e+13
## rgdpch       2,5e+04 1,4e+07 2,1e+06 3,0e+06  9,5e+02 2,6e+11   5,7e+12
## rgdpwok      3,6e+04 2,0e+07 3,0e+06 7,2e+06  9,3e+02 4,2e+11   8,9e+12
## ki           5,2e+00 3,2e+03 9,5e+02 9,3e+02  7,8e+00 9,8e+07   5,8e+09
## Y            3,2e+09 1,8e+12 2,6e+11 4,2e+11  9,8e+07 3,4e+16   7,2e+17
## Inversión    6,6e+10 3,7e+13 5,7e+12 8,9e+12  5,8e+09 7,2e+17   1,8e+19
## mean.ki      0,0e+00 0,0e+00 0,0e+00 0,0e+00  0,0e+00 0,0e+00   0,0e+00
## K            6,0e+09 3,4e+12 4,9e+11 8,0e+11  1,9e+08 6,4e+16   1,4e+18
## PIBperCapita 3,6e+04 2,0e+07 3,0e+06 7,2e+06  9,3e+02 4,2e+11   8,9e+12
## L            7,9e+00 4,4e+03 5,4e+02 8,0e+02 -5,5e-01 7,3e+07   1,2e+09
## A            3,9e+05 2,2e+08 3,2e+07 5,7e+07  1,4e+04 4,2e+12   9,2e+13
##              mean.ki       K PIBperCapita        L       A
## year               0 6,0e+09      3,6e+04  7,9e+00 3,9e+05
## POP                0 3,4e+12      2,0e+07  4,4e+03 2,2e+08
## rgdpch             0 4,9e+11      3,0e+06  5,4e+02 3,2e+07
## rgdpwok            0 8,0e+11      7,2e+06  8,0e+02 5,7e+07
## ki                 0 1,9e+08      9,3e+02 -5,5e-01 1,4e+04
## Y                  0 6,4e+16      4,2e+11  7,3e+07 4,2e+12
## Inversión          0 1,4e+18      8,9e+12  1,2e+09 9,2e+13
## mean.ki            0 0,0e+00      0,0e+00  0,0e+00 0,0e+00
## K                  0 1,2e+17      8,0e+11  1,4e+08 8,0e+12
## PIBperCapita       0 8,0e+11      7,2e+06  8,0e+02 5,7e+07
## L                  0 1,4e+08      8,0e+02  3,2e-01 8,3e+03
## A                  0 8,0e+12      5,7e+07  8,3e+03 5,4e+08
cor(COL)
## Warning in cor(COL): the standard deviation is zero
##              year  POP rgdpch rgdpwok    ki    Y Inversión mean.ki    K
## year         1,00 1,00   0,98    0,75  0,10 0,98      0,89      NA 0,98
## POP          1,00 1,00   0,98    0,73  0,12 0,97      0,89      NA 0,97
## rgdpch       0,98 0,98   1,00    0,78  0,24 0,99      0,94      NA 0,99
## rgdpwok      0,75 0,73   0,78    1,00  0,12 0,86      0,79      NA 0,86
## ki           0,10 0,12   0,24    0,12  1,00 0,19      0,49      NA 0,19
## Y            0,98 0,97   0,99    0,86  0,19 1,00      0,94      NA 1,00
## Inversión    0,89 0,89   0,94    0,79  0,49 0,94      1,00      NA 0,94
## mean.ki        NA   NA     NA      NA    NA   NA        NA       1   NA
## K            0,98 0,97   0,99    0,86  0,19 1,00      0,94      NA 1,00
## PIBperCapita 0,75 0,73   0,78    1,00  0,12 0,86      0,79      NA 0,86
## L            0,79 0,78   0,67    0,52 -0,35 0,70      0,51      NA 0,70
## A            0,94 0,93   0,97    0,91  0,22 0,99      0,94      NA 0,99
##              PIBperCapita     L    A
## year                 0,75  0,79 0,94
## POP                  0,73  0,78 0,93
## rgdpch               0,78  0,67 0,97
## rgdpwok              1,00  0,52 0,91
## ki                   0,12 -0,35 0,22
## Y                    0,86  0,70 0,99
## Inversión            0,79  0,51 0,94
## mean.ki                NA    NA   NA
## K                    0,86  0,70 0,99
## PIBperCapita         1,00  0,52 0,91
## L                    0,52  1,00 0,63
## A                    0,91  0,63 1,00
subCOL <- sqldf("SELECT Y,Inversión,K,PIBperCapita,L,A FROM COL")
pairs(subCOL)

cov.df <- data.frame(cov(subCOL))
cov.df
##                    Y Inversión       K PIBperCapita       L       A
## Y            3,4e+16    7,2e+17 6,4e+16      4,2e+11 7,3e+07 4,2e+12
## Inversión   7,2e+17    1,8e+19 1,4e+18      8,9e+12 1,2e+09 9,2e+13
## K            6,4e+16    1,4e+18 1,2e+17      8,0e+11 1,4e+08 8,0e+12
## PIBperCapita 4,2e+11    8,9e+12 8,0e+11      7,2e+06 8,0e+02 5,7e+07
## L            7,3e+07    1,2e+09 1,4e+08      8,0e+02 3,2e-01 8,3e+03
## A            4,2e+12    9,2e+13 8,0e+12      5,7e+07 8,3e+03 5,4e+08
cor.df <- data.frame(cor(subCOL))
cor.df
##                 Y Inversión    K PIBperCapita    L    A
## Y            1,00       0,94 1,00         0,86 0,70 0,99
## Inversión   0,94       1,00 0,94         0,79 0,51 0,94
## K            1,00       0,94 1,00         0,86 0,70 0,99
## PIBperCapita 0,86       0,79 0,86         1,00 0,52 0,91
## L            0,70       0,51 0,70         0,52 1,00 0,63
## A            0,99       0,94 0,99         0,91 0,63 1,00
# Aplicando relaciones a POP
relacion(POP,rgdpch)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

relacion(POP,rgdpwok)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

relacion(POP,ki)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

#Aplicandorelacionesargdpch
relacion(rgdpch,POP)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

relacion(rgdpch,rgdpwok)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

relacion(rgdpch,ki)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

#Aplicandorelacionesargdwok
relacion(rgdpwok,POP)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

relacion(rgdpwok,rgdpch)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

relacion(rgdpwok,ki)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

#Aplicandorelacionesaki
relacion(ki,POP)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

relacion(ki,rgdpch)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

relacion(ki,rgdpwok)
## Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous.

# Haciendo regresión
model <- lm(COL$Y ~ COL$Inversión + COL$K + COL$PIBperCapita + COL$L + COL$A)
summary(model)
## Warning in summary.lm(model): essentially perfect fit: summary may be
## unreliable
## 
## Call:
## lm(formula = COL$Y ~ COL$Inversión + COL$K + COL$PIBperCapita + 
##     COL$L + COL$A)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -1,49e-07 -4,89e-08 -5,30e-09  3,50e-08  6,43e-07 
## 
## Coefficients:
##                   Estimate Std. Error   t value Pr(>|t|)    
## (Intercept)       1,47e-06   5,46e-07  2,70e+00   0,0093 ** 
## COL$Inversión     7,35e-18   1,27e-17  5,80e-01   0,5655    
## COL$K             5,27e-01   9,72e-16  5,42e+14   <2e-16 ***
## COL$PIBperCapita  3,09e-11   3,51e-11  8,80e-01   0,3820    
## COL$L            -1,89e-07   7,20e-08 -2,63e+00   0,0111 *  
## COL$A            -2,47e-11   1,68e-11 -1,47e+00   0,1482    
## ---
## Signif. codes:  0 '***' 0,001 '**' 0,01 '*' 0,05 '.' 0,1 ' ' 1
## 
## Residual standard error: 1,1e-07 on 55 degrees of freedom
## Multiple R-squared:     1,   Adjusted R-squared:     1 
## F-statistic: 3,52e+31 on 5 and 55 DF,  p-value: <2e-16
hist(model$residuals)

Podemos ver el sesgo en el histograma de los residuos, comprobando la no normalidad dentro de estos datos. De igual forma, más adelante conformaremos distintos test que sustenten la eficiencia y predicción del modelo.

#Aplicando test el LM
Durbin.Watson <- dwtest(COL$Y ~ COL$Inversión + COL$K + COL$PIBperCapita + COL$L + COL$A)
Durbin.Watson
## 
##  Durbin-Watson test
## 
## data:  COL$Y ~ COL$Inversión + COL$K + COL$PIBperCapita + COL$L + COL$A
## DW = 1, p-value = 3e-04
## alternative hypothesis: true autocorrelation is greater than 0
Breusch.Godfrey <- bgtest(COL$Y ~ COL$Inversión + COL$K + COL$PIBperCapita + COL$L + COL$A)
Breusch.Godfrey
## 
##  Breusch-Godfrey test for serial correlation of order up to 1
## 
## data:  COL$Y ~ COL$Inversión + COL$K + COL$PIBperCapita + COL$L + COL$A
## LM test = 0,008, df = 1, p-value = 0,9
Breusch.Pagan <- bptest(COL$Y ~ COL$Inversión + COL$K + COL$PIBperCapita + COL$L + COL$A)
Breusch.Pagan
## 
##  studentized Breusch-Pagan test
## 
## data:  COL$Y ~ COL$Inversión + COL$K + COL$PIBperCapita + COL$L + COL$A
## BP = 10, df = 5, p-value = 0,01

Podemos observar que en el tst de Durbin-Watson y el valor-p es mayor al 5% de significancia con un intervalo de confianza del 95% por tanto no podemos aceptar la hipotesis nula, es decir, no podemos aceptar que la autocorrelación entre las variables es mayor a cero.

Con la prueba de Breusch-Godfrey podemos evaluar que el valor-p es menor a uno, es decir, que la probabilidad deno rechazar la hipotesis alternativa es muy baja, debido a que el valor es menor al 0,05 de significancia en un intervalo de confianza del 0,95, es decir que según este test no tenemos evidencia estadistica para detectar dependencia serial, al interior del primer modelo. No obstante, en comparación con el modelo anterior este es menor.

Finalmente, con la prueba de Breushc-Pagan, la cual evalua la normalidad de los residuos del modelo, tenemos una probabilidad menor al 1% dentro de una significancia del 5%, por lo tanto no podemos rechazar la hipotesis nula, infiriendo normalidad en el modelo.

Referencias: T.S. Breusch & A.R. Pagan (1979), A Simple Test for Heteroscedasticity and Random Coefficient

Variation. Econometrica 47, 1287–1294 R. Koenker (1981), A Note on Studentizing a Test for Heteroscedasticity. Journal of Econometrics 17, 107–112.

W. Krämer & H. Sonnberger (1986), The Linear Regression Model under Test. Heidelberg: Physica

J. Durbin & G.S. Watson (1950), Testing for Serial Correlation in Least Squares Regression I. Biometrika 37, 409–428.

J. Durbin & G.S. Watson (1951), Testing for Serial Correlation in Least Squares Regression II. Biometrika 38, 159–178.

J. Durbin & G.S. Watson (1971), Testing for Serial Correlation in Least Squares Regression III. Biometrika 58, 1–19.

R.W. Farebrother (1980), Pan’s Procedure for the Tail Probabilities of the Durbin-Watson Statistic (Corr: 81V30 p189; AS R52: 84V33 p363- 366; AS R53: 84V33 p366- 369). Applied Statistics 29, 224–227.

R. W. Farebrother (1984), [AS R53] A Remark on Algorithms AS 106 (77V26 p92-98), AS 153 (80V29 p224-227) and AS 155: The Distribution of a Linear Combination of χ 2 Random Variables (80V29 p323-333) Applied Statistics 33, 366–369.

W. Krämer & H. Sonnberger (1986), The Linear Regression Model under Test. Heidelberg: Physica.

Breusch, T.S. (1978): Testing for Autocorrelation in Dynamic Linear Models, Australian Economic Papers, 17, 334-355.

Godfrey, L.G. (1978): Testing Against General Autoregressive and Moving Average Error Models when the Regressors Include Lagged Dependent Variables’, Econometrica, 46, 1293-1301.

Wooldridge, J.M. (2013): Introductory Econometrics: A Modern Approach, 5th edition, SouthWestern College.