Libraries

library(tidyverse)
library(dplyr)
library(stargazer)
# geo
library(sp)
library(spdep)
library(rgdal)
library(maptools)
library(rgeos)
library(sf)
library(spatialreg)

# mass retype()
library(hablar)

# multicollinearity test omcdiag imcdiag
library(mctest)

library(GGally)

#tables
library(xtable)
library(texreg)

#Specifications for 2017

grp_2017_RV_UV <- log(GRP_2017) ~ Rv_2017 + Uv_2017 + log(Inv_2017) + educ_2017 + Wage_2017
labpr_2017_RV_UV <- LabPr_2017 ~ Rv_2017 + Uv_2017 + log(Inv_2017) + educ_2017 + Wage_2017
emp_2017_RV_UV <- Emp_2017 ~ Rv_2017 + Uv_2017 + log(Inv_2017) + educ_2017 + Wage_2017
unemp_2017_RV_UV <- Unemp_2017 ~ Rv_2017 + Uv_2017 + log(Inv_2017) + educ_2017 + Wage_2017
grp_2017_V <- log(GRP_2017) ~ V_2017 + log(Inv_2017) + educ_2017 + Wage_2017
labpr_2017_V <- LabPr_2017 ~ V_2017 + log(Inv_2017) + educ_2017 + Wage_2017
emp_2017_V <- Emp_2017 ~ V_2017 + log(Inv_2017) + educ_2017 + Wage_2017
unemp_2017_V <- Unemp_2017 ~ V_2017 + log(Inv_2017) + educ_2017 + Wage_2017

#Spatial Analysis

#downloading spatial data
Russia_shape = readOGR(
  'C:/Users/Kolya/Documents/New_studies/GeoAnalisys/DataGeo/Term_paper/Spatial_dataset.shp')
## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\Kolya\Documents\New_studies\GeoAnalisys\DataGeo\Term_paper\Spatial_dataset.shp", layer: "Spatial_dataset"
## with 79 features
## It has 11 fields
## Integer64 fields read as strings:  educ_2017 Inv_2017
#should be done in shp!

# #our dataframe
# Bad_regions_sp = c("Crimea", "Khanty-Mansiy", "Yamal-Nenets", "Sevastopol'", "Chechnya", "Nenets")
# Russia_shape@data <- subset(Russia_shape@data,!(Russia_shape@data$NAME_1 %in% Bad_regions_sp))
# #drop duplicates
# Russia_shape@data <- Russia_shape@data[!duplicated(Russia_shape@data$NAME_1),]

# #drop useless columns
# Russia_shape@data <- subset(Russia_shape@data, select = -c(1:4, 6:15))
# 
# #rename first column
# names(Russia_shape@data)[1] <- 'region'
# names(Russia_shape@data)[9] <- 'V_2017'
# names(Russia_shape@data)[7] <- 'Emp_2017'
# Russia_shape@data 

#changing the data type
Russia_shape$educ_2017 <- as.numeric(Russia_shape$educ_2017)
glimpse(Russia_shape$educ_2017)#success
##  num [1:79] 275 218 199 164 289 255 316 223 253 278 ...
Russia_shape$Inv_2017 <- as.numeric(Russia_shape$Inv_2017)
glimpse(Russia_shape$Inv_2017)#success
##  num [1:79] 45977 37256 240560 185708 144040 ...
#Descriptive statistics
Russia_shape@data %>% glimpse()
## Rows: 79
## Columns: 11
## $ NAME_1     <chr> "Adygey", "Altay", "Amur", "Arkhangel'sk", "Astrakhan'", "B~
## $ educ_2017  <dbl> 275, 218, 199, 164, 289, 255, 316, 223, 253, 278, 288, 549,~
## $ GRP_2017   <dbl> 109714.5, 545303.0, 299181.0, 759206.5, 442608.8, 1487892.2~
## $ LabPr_2017 <dbl> 103.5, 100.7, 97.8, 103.9, 109.9, 102.9, 103.1, 105.6, 101.~
## $ Unemp_2017 <dbl> 8.8, 6.9, 5.9, 6.4, 7.4, 5.6, 3.9, 4.4, 9.6, 6.6, 5.1, 1.6,~
## $ Wage_2017  <dbl> 101.6, 100.0, 101.1, 98.9, 97.1, 99.2, 99.1, 99.4, 97.9, 97~
## $ Emp_2017   <dbl> 0.0112900000, 0.0153074205, 0.0715903614, 0.0213677966, 0.0~
## $ Inv_2017   <dbl> 45977, 37256, 240560, 185708, 144040, 68532, 91978, 45339, ~
## $ V_2017     <dbl> 2.877239, 3.477131, 3.052880, 3.580351, 3.126376, 3.527909,~
## $ Rv_2017    <dbl> 0.31220840, 0.67319887, 0.55326057, 0.42545317, 0.94392724,~
## $ Uv_2017    <dbl> 2.565030, 2.803932, 2.499619, 3.154898, 2.182449, 2.788336,~
#Russia_shape@data$region finally, 79
proj4string(Russia_shape) <- CRS("+init=epsg:4326")
## Warning in proj4string(obj): CRS object has comment, which is lost in output; in tests, see
## https://cran.r-project.org/web/packages/sp/vignettes/CRS_warnings.html
Russia.centroids<-gCentroid(Russia_shape,byid=TRUE)

weights <- knn2nb(knearneigh(Russia.centroids, k=8,longlat = TRUE),row.names=Russia_shape$region)
Russia.weights <- nb2listw(weights)
#H0 - variable is randomly distributed (no-autocrrelation)
columns  = names(Russia_shape@data)[2:length(names(Russia_shape@data))]
Russia_sp_dat <- Russia_shape@data
for(i in columns){
    res <- moran.test(Russia_sp_dat[[i]], Russia.weights)
    # print(res)
    if(res$p.value < 0.01){
      print(paste(i,': Spatial correlation detected'))
    }
}
## [1] "Unemp_2017 : Spatial correlation detected"
## [1] "Emp_2017 : Spatial correlation detected"
## [1] "Inv_2017 : Spatial correlation detected"
## [1] "V_2017 : Spatial correlation detected"
## [1] "Rv_2017 : Spatial correlation detected"
#only 5/10 variables appear to be spatially correlated
#Unemp_2017, EmpPerWF_2, Inv_2017, V_2017, Rv_2017
for (g in columns){
  moran.plot(Russia_shape@data[[g]], Russia.weights, xlab=g)
}

#graphically, all results of tests are correct

#Naive spatial models, RV, UV ##GRP, Rv, Uv

attach(Russia_shape@data) #strange ritual

reg_grp_2017_RV_UV <- lm(grp_2017_RV_UV, data = Russia_shape@data)
summary(reg_grp_2017_RV_UV) #%>% xtable()
## 
## Call:
## lm(formula = grp_2017_RV_UV, data = Russia_shape@data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.72792 -0.41127 -0.02262  0.47348  2.00452 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    3.379190   5.153948   0.656   0.5141    
## Rv_2017        0.182247   0.151832   1.200   0.2339    
## Uv_2017        0.782195   0.172554   4.533 2.23e-05 ***
## log(Inv_2017)  0.693175   0.142246   4.873 6.21e-06 ***
## educ_2017      0.002094   0.001052   1.990   0.0503 .  
## Wage_2017     -0.007027   0.051079  -0.138   0.8910    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7715 on 73 degrees of freedom
## Multiple R-squared:  0.5458, Adjusted R-squared:  0.5147 
## F-statistic: 17.55 on 5 and 73 DF,  p-value: 2.238e-11
#H0 - residuals are randomly distributed (no-autocorrelation)
lm.morantest(reg_grp_2017_RV_UV,Russia.weights)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = grp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## Moran I statistic standard deviate = 6.2213, p-value = 2.466e-10
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##      0.273592461     -0.018646456      0.002206571
moran.test(reg_grp_2017_RV_UV$residuals, Russia.weights)
## 
##  Moran I test under randomisation
## 
## data:  reg_grp_2017_RV_UV$residuals  
## weights: Russia.weights    
## 
## Moran I statistic standard deviate = 5.7772, p-value = 3.797e-09
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##        0.27359246       -0.01282051        0.00245779
moran.plot(reg_grp_2017_RV_UV$residuals, Russia.weights)

# residuals are correlated according to the both test and graph
lm.LMtests(reg_grp_2017_RV_UV, listw = Russia.weights, test="all", zero.policy=TRUE)
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = grp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMerr = 26.695, df = 1, p-value = 2.383e-07
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = grp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMlag = 7.5941, df = 1, p-value = 0.005856
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = grp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMerr = 21.101, df = 1, p-value = 4.358e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = grp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMlag = 2.0002, df = 1, p-value = 0.1573
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = grp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## SARMA = 28.695, df = 2, p-value = 5.875e-07
# Analitics
# LMerr = 26.695, df = 1, p-value = 2.383e-07 => significant
# LMlag = 7.5941, df = 1, p-value = 0.005856 => significant
# conclusion => moving to Robust LM Diagnostics

# RLMerr = 21.101, df = 1, p-value = 4.358e-06
# RLMlag = 2.0002, df = 1, p-value = 0.1573
# p-value: RLMlag > RLMerr => RLMerr is robust

# #SEM - spatial error model
# y = X beta + rho W1 y + u
# u = lambda W2 u + e
#building an actual model
SEM_GRP_RV_UV <- errorsarlm(grp_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_GRP_RV_UV <- summary(SEM_GRP_RV_UV)

sum_GRP_RV_UV$Coef[, c(1,4)] %>% xtable()
# print("NOX")
# print(sum_b$Coef[c(11),])

#comparing our spatial model with the original one
logLik(SEM_GRP_RV_UV)
## 'log Lik.' -77.28472 (df=8)
logLik(reg_grp_2017_RV_UV)
## 'log Lik.' -88.48648 (df=7)
AIC(SEM_GRP_RV_UV)
## [1] 170.5694
AIC(reg_grp_2017_RV_UV)
## [1] 190.973
#AIC - the bigger, the better the model
#log-likelihood  - the smaller, the better the model

#SER is better than OLS in this case

##LabPr, Rv, Uv

 #strange ritual

reg_labpr_2017_RV_UV <- lm(labpr_2017_RV_UV, data = Russia_shape@data)
summary(reg_labpr_2017_RV_UV) #%>% xtable()
## 
## Call:
## lm(formula = labpr_2017_RV_UV, data = Russia_shape@data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -7.4942 -1.6520 -0.0417  1.5016 10.0609 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   134.432680  19.052399   7.056  8.2e-10 ***
## Rv_2017        -0.118557   0.561273  -0.211    0.833    
## Uv_2017         0.517382   0.637873   0.811    0.420    
## log(Inv_2017)  -0.244087   0.525836  -0.464    0.644    
## educ_2017      -0.003996   0.003890  -1.027    0.308    
## Wage_2017      -0.298336   0.188822  -1.580    0.118    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.852 on 73 degrees of freedom
## Multiple R-squared:  0.0531, Adjusted R-squared:  -0.01176 
## F-statistic: 0.8187 on 5 and 73 DF,  p-value: 0.5403
#H0 - residuals are randomly distributed (no-autocorrelation)
lm.morantest(reg_labpr_2017_RV_UV,Russia.weights)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = labpr_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## Moran I statistic standard deviate = -0.46781, p-value = 0.68
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##     -0.040621347     -0.018646456      0.002206571
moran.test(reg_labpr_2017_RV_UV$residuals, Russia.weights)
## 
##  Moran I test under randomisation
## 
## data:  reg_labpr_2017_RV_UV$residuals  
## weights: Russia.weights    
## 
## Moran I statistic standard deviate = -0.56841, p-value = 0.7151
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      -0.040621347      -0.012820513       0.002392169
moran.plot(reg_labpr_2017_RV_UV$residuals, Russia.weights)

# residuals are not correlated according to the both test and graph
lm.LMtests(reg_labpr_2017_RV_UV, listw = Russia.weights, test="all", zero.policy=TRUE)
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = labpr_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMerr = 0.58847, df = 1, p-value = 0.443
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = labpr_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMlag = 0.55568, df = 1, p-value = 0.456
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = labpr_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMerr = 0.040606, df = 1, p-value = 0.8403
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = labpr_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMlag = 0.0078192, df = 1, p-value = 0.9295
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = labpr_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## SARMA = 0.59629, df = 2, p-value = 0.7422
# Analitics
# LMerr = 26.695, df = 1, p-value = 2.383e-07 => non -significant
# LMlag = 7.5941, df = 1, p-value = 0.005856 => non -significant
# conclusion => sticking to OLS

##Emp, Rv, Uv

 #strange ritual

reg_emp_2017_RV_UV <- lm(emp_2017_RV_UV, data = Russia_shape@data)
summary(reg_emp_2017_RV_UV) #%>% xtable()
## 
## Call:
## lm(formula = emp_2017_RV_UV, data = Russia_shape@data)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.018458 -0.005822 -0.001369  0.002788  0.052274 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -7.338e-02  7.682e-02  -0.955 0.342609    
## Rv_2017       -7.878e-05  2.263e-03  -0.035 0.972324    
## Uv_2017        6.357e-03  2.572e-03   2.472 0.015775 *  
## log(Inv_2017)  7.294e-03  2.120e-03   3.440 0.000964 ***
## educ_2017     -3.141e-05  1.568e-05  -2.003 0.048922 *  
## Wage_2017      2.450e-05  7.614e-04   0.032 0.974413    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.0115 on 73 degrees of freedom
## Multiple R-squared:  0.243,  Adjusted R-squared:  0.1911 
## F-statistic: 4.686 on 5 and 73 DF,  p-value: 0.000913
#H0 - residuals are randomly distributed (no-autocorrelation)
lm.morantest(reg_emp_2017_RV_UV,Russia.weights)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = emp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## Moran I statistic standard deviate = 5.7608, p-value = 4.185e-09
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##      0.251964083     -0.018646456      0.002206571
moran.test(reg_emp_2017_RV_UV$residuals, Russia.weights)
## 
##  Moran I test under randomisation
## 
## data:  reg_emp_2017_RV_UV$residuals  
## weights: Russia.weights    
## 
## Moran I statistic standard deviate = 5.6529, p-value = 7.888e-09
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.251964083      -0.012820513       0.002194021
moran.plot(reg_emp_2017_RV_UV$residuals, Russia.weights)

# residuals are correlated according to the both test and graph
lm.LMtests(reg_emp_2017_RV_UV, listw = Russia.weights, test="all", zero.policy=TRUE)
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = emp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMerr = 22.641, df = 1, p-value = 1.953e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = emp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMlag = 40.163, df = 1, p-value = 2.336e-10
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = emp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMerr = 1.7098, df = 1, p-value = 0.191
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = emp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMlag = 19.232, df = 1, p-value = 1.158e-05
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = emp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## SARMA = 41.873, df = 2, p-value = 8.081e-10
# Analitics
# LMerr = 22.641, df = 1, p-value = 1.953e-06 => significant
# LMlag = 40.163, df = 1, p-value = 2.336e-10 => significant
# conclusion => moving to Robust LM Diagnostics

# RLMerr = 1.7098, df = 1, p-value = 0.191 
# RLMlag = 19.232, df = 1, p-value = 1.158e-05
# p-value: RLMlag < RLMerr => RLMlag is robust

# SAR - spatial autoregressive model
# y = X beta + rho W1 y + u
#building an actual model
SAR_Emp_RV_UV <- lagsarlm(emp_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_Emp_RV_UV <- summary(SAR_Emp_RV_UV)

sum_Emp_RV_UV$Coef[, c(1,4)] %>% xtable()
# print("NOX")
# print(sum_b$Coef[c(11),])

#comparing our spatial model with the original one
logLik(SAR_Emp_RV_UV)
## 'log Lik.' 254.7317 (df=8)
logLik(reg_emp_2017_RV_UV)
## 'log Lik.' 243.7909 (df=7)
AIC(SAR_Emp_RV_UV)
## [1] -493.4633
AIC(reg_emp_2017_RV_UV)
## [1] -473.5818
#AIC - the bigger, the better the model
#log-likelihood  - the smaller, the better the model

#SAR is better than OLS in this case

##Unemp, Rv, Uv

 #strange ritual

reg_unemp_2017_RV_UV <- lm(unemp_2017_RV_UV, data = Russia_shape@data)
summary(reg_unemp_2017_RV_UV) #%>% xtable()
## 
## Call:
## lm(formula = unemp_2017_RV_UV, data = Russia_shape@data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.9400 -2.0770 -0.5294  1.4176 17.1003 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)   
## (Intercept)   40.772412  21.506862   1.896  0.06195 . 
## Rv_2017        0.515684   0.633580   0.814  0.41834   
## Uv_2017       -1.102269   0.720048  -1.531  0.13013   
## log(Inv_2017) -1.928983   0.593578  -3.250  0.00175 **
## educ_2017     -0.006644   0.004391  -1.513  0.13453   
## Wage_2017     -0.085552   0.213148  -0.401  0.68932   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.22 on 73 degrees of freedom
## Multiple R-squared:  0.2246, Adjusted R-squared:  0.1715 
## F-statistic:  4.23 on 5 and 73 DF,  p-value: 0.001969
#H0 - residuals are randomly distributed (no-autocorrelation)
lm.morantest(reg_unemp_2017_RV_UV,Russia.weights)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = unemp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## Moran I statistic standard deviate = 7.5185, p-value = 2.77e-14
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##      0.334530629     -0.018646456      0.002206571
moran.test(reg_unemp_2017_RV_UV$residuals, Russia.weights)
## 
##  Moran I test under randomisation
## 
## data:  reg_unemp_2017_RV_UV$residuals  
## weights: Russia.weights    
## 
## Moran I statistic standard deviate = 7.5524, p-value = 2.137e-14
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.334530629      -0.012820513       0.002115296
moran.plot(reg_unemp_2017_RV_UV$residuals, Russia.weights)

# residuals are correlated according to the both test and graph
lm.LMtests(reg_unemp_2017_RV_UV, listw = Russia.weights, test="all", zero.policy=TRUE)
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = unemp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMerr = 39.911, df = 1, p-value = 2.659e-10
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = unemp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMlag = 49.776, df = 1, p-value = 1.723e-12
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = unemp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMerr = 0.17875, df = 1, p-value = 0.6725
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = unemp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMlag = 10.044, df = 1, p-value = 0.001528
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = unemp_2017_RV_UV, data = Russia_shape@data)
## weights: Russia.weights
## 
## SARMA = 49.955, df = 2, p-value = 1.42e-11
# Analitics
# LMerr = 39.911, df = 1, p-value = 2.659e-10 => significant
# LMlag = 49.776, df = 1, p-value = 1.723e-12 => significant
# conclusion => moving to Robust LM Diagnostics

# RLMerr = 0.17875, df = 1, p-value = 0.6725 
# RLMlag = 10.044, df = 1, p-value = 0.001528
# p-value: RLMlag < RLMerr => RLMlag is robust

# SAR - spatial autoregressive model
# y = X beta + rho W1 y + u
#building an actual model
SAR_Unemp_RV_UV <- lagsarlm(unemp_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_Unemp_RV_UV <- summary(SAR_Unemp_RV_UV)

sum_Unemp_RV_UV$Coef[, c(1,4)] %>% xtable()
# print("NOX")
# print(sum_b$Coef[c(11),])

#comparing our spatial model with the original one
logLik(SAR_Unemp_RV_UV)
## 'log Lik.' -186.7775 (df=8)
logLik(reg_unemp_2017_RV_UV)
## 'log Lik.' -201.3466 (df=7)
AIC(SAR_Unemp_RV_UV)
## [1] 389.5549
AIC(reg_unemp_2017_RV_UV)
## [1] 416.6932
#AIC - the bigger, the better the model
#log-likelihood  - the smaller, the better the model

#SAR is better than OLS in this case

#Stars

library(gtsummary)
## Warning: пакет 'gtsummary' был собран под R версии 4.1.3
packageVersion("gtsummary")
## [1] '1.5.2'
style_pvalue_stars <- function(x) {
  dplyr::case_when(
    x < 0.001 ~ paste0(style_pvalue(x), "***"),
    x < 0.01 ~ paste0(style_pvalue(x), "**"),
    x < 0.05 ~ paste0(style_pvalue(x), "*"),
    TRUE ~ style_pvalue(x)
  )
}

#Naive spatial models, V ##GRP, V

# attach(Russia_shape@data) #strange ritual

reg_grp_2017_V <- lm(grp_2017_V, data = Russia_shape@data)
summary(reg_grp_2017_V) #%>% xtable()
## 
## Call:
## lm(formula = grp_2017_V, data = Russia_shape@data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.78289 -0.51180  0.04225  0.40835  2.28803 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    4.856058   5.263340   0.923   0.3592    
## V_2017         0.452125   0.100286   4.508 2.40e-05 ***
## log(Inv_2017)  0.715093   0.146065   4.896 5.58e-06 ***
## educ_2017      0.003009   0.001004   2.997   0.0037 ** 
## Wage_2017     -0.020112   0.052245  -0.385   0.7014    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.794 on 74 degrees of freedom
## Multiple R-squared:  0.5124, Adjusted R-squared:  0.4861 
## F-statistic: 19.44 on 4 and 74 DF,  p-value: 5.728e-11
#H0 - residuals are randomly distributed (no-autocorrelation)
lm.morantest(reg_grp_2017_V,Russia.weights)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = grp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## Moran I statistic standard deviate = 6.4592, p-value = 5.263e-11
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##        0.2860602       -0.0186465        0.0022254
moran.test(reg_grp_2017_V$residuals, Russia.weights)
## 
##  Moran I test under randomisation
## 
## data:  reg_grp_2017_V$residuals  
## weights: Russia.weights    
## 
## Moran I statistic standard deviate = 6.0395, p-value = 7.732e-10
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.286060226      -0.012820513       0.002449061
moran.plot(reg_grp_2017_V$residuals, Russia.weights)

# residuals are correlated according to the both test and graph
lm.LMtests(reg_grp_2017_V, listw = Russia.weights, test="all", zero.policy=TRUE)
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = grp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMerr = 29.183, df = 1, p-value = 6.585e-08
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = grp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMlag = 8.4352, df = 1, p-value = 0.00368
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = grp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMerr = 23.731, df = 1, p-value = 1.108e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = grp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMlag = 2.9827, df = 1, p-value = 0.08416
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = grp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## SARMA = 32.166, df = 2, p-value = 1.036e-07
# Analitics
# LMerr = 29.183, df = 1, p-value = 6.585e-08 => significant
# LMlag = 8.4352, df = 1, p-value = 0.00368 => significant
# conclusion => moving to Robust LM Diagnostics

# RLMerr = 23.731, df = 1, p-value = 1.108e-06
# RLMlag = 2.9827, df = 1, p-value = 0.08416
# p-value: RLMlag > RLMerr => RLMerr is robust

# #SEM - spatial error model
# y = X beta + rho W1 y + u
# u = lambda W2 u + e
#building an actual model
SEM_GRP_V <- errorsarlm(grp_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_GRP_V <- summary(SEM_GRP_V)

sum_GRP_V$Coef[, c(1,4)] %>% xtable()
# print("NOX")
# print(sum_b$Coef[c(11),])

#comparing our spatial model with the original one
logLik(SEM_GRP_V)
## 'log Lik.' -79.90729 (df=7)
logLik(reg_grp_2017_V)
## 'log Lik.' -91.29149 (df=6)
AIC(SEM_GRP_V)
## [1] 173.8146
AIC(reg_grp_2017_V)
## [1] 194.583
#AIC - the bigger, the better the model
#log-likelihood  - the smaller, the better the model

#SER is better than OLS in this case

##LabPr, V

 #strange ritual

reg_labpr_2017_V <- lm(labpr_2017_V, data = Russia_shape@data)
summary(reg_labpr_2017_V) #%>% xtable()
## 
## Call:
## lm(formula = labpr_2017_V, data = Russia_shape@data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -7.6667 -1.6670  0.0114  1.3682 10.2422 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   135.998145  18.834791   7.221 3.81e-10 ***
## V_2017          0.167511   0.358870   0.467   0.6420    
## log(Inv_2017)  -0.220854   0.522690  -0.423   0.6739    
## educ_2017      -0.003026   0.003592  -0.842   0.4022    
## Wage_2017      -0.312205   0.186956  -1.670   0.0992 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.841 on 74 degrees of freedom
## Multiple R-squared:  0.04737,    Adjusted R-squared:  -0.004128 
## F-statistic: 0.9198 on 4 and 74 DF,  p-value: 0.4571
#H0 - residuals are randomly distributed (no-autocorrelation)
lm.morantest(reg_labpr_2017_V,Russia.weights)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = labpr_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## Moran I statistic standard deviate = -0.31217, p-value = 0.6225
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##      -0.03337275      -0.01864650       0.00222540
moran.test(reg_labpr_2017_V$residuals, Russia.weights)
## 
##  Moran I test under randomisation
## 
## data:  reg_labpr_2017_V$residuals  
## weights: Russia.weights    
## 
## Moran I statistic standard deviate = -0.42047, p-value = 0.6629
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      -0.033372746      -0.012820513       0.002389148
moran.plot(reg_labpr_2017_V$residuals, Russia.weights)

# residuals are not correlated according to the both test and graph
lm.LMtests(reg_labpr_2017_V, listw = Russia.weights, test="all", zero.policy=TRUE)
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = labpr_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMerr = 0.39719, df = 1, p-value = 0.5285
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = labpr_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMlag = 0.40348, df = 1, p-value = 0.5253
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = labpr_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMerr = 2.9529e-05, df = 1, p-value = 0.9957
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = labpr_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMlag = 0.0063212, df = 1, p-value = 0.9366
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = labpr_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## SARMA = 0.40351, df = 2, p-value = 0.8173
# Analitics
# LMerr = 26.695, df = 1, p-value = 2.383e-07 => non -significant
# LMlag = 7.5941, df = 1, p-value = 0.005856 => non -significant
# conclusion => sticking to OLS

##Emp, V

 #strange ritual

reg_emp_2017_V <- lm(emp_2017_V, data = Russia_shape@data)
summary(reg_emp_2017_V) #%>% xtable()
## 
## Call:
## lm(formula = emp_2017_V, data = Russia_shape@data)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.016307 -0.005385 -0.001907  0.002592  0.054110 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -5.754e-02  7.714e-02  -0.746  0.45812    
## V_2017         2.816e-03  1.470e-03   1.916  0.05922 .  
## log(Inv_2017)  7.529e-03  2.141e-03   3.517  0.00075 ***
## educ_2017     -2.160e-05  1.471e-05  -1.468  0.14636    
## Wage_2017     -1.159e-04  7.657e-04  -0.151  0.88014    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.01164 on 74 degrees of freedom
## Multiple R-squared:  0.2141, Adjusted R-squared:  0.1716 
## F-statistic:  5.04 on 4 and 74 DF,  p-value: 0.001199
#H0 - residuals are randomly distributed (no-autocorrelation)
lm.morantest(reg_emp_2017_V,Russia.weights)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = emp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## Moran I statistic standard deviate = 5.805, p-value = 3.219e-09
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##        0.2551977       -0.0186465        0.0022254
moran.test(reg_emp_2017_V$residuals, Russia.weights)
## 
##  Moran I test under randomisation
## 
## data:  reg_emp_2017_V$residuals  
## weights: Russia.weights    
## 
## Moran I statistic standard deviate = 5.7524, p-value = 4.4e-09
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.255197663      -0.012820513       0.002170878
moran.plot(reg_emp_2017_V$residuals, Russia.weights)

# residuals are correlated according to the both test and graph
lm.LMtests(reg_emp_2017_V, listw = Russia.weights, test="all", zero.policy=TRUE)
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = emp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMerr = 23.226, df = 1, p-value = 1.441e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = emp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMlag = 41.312, df = 1, p-value = 1.298e-10
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = emp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMerr = 2.764, df = 1, p-value = 0.09641
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = emp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMlag = 20.85, df = 1, p-value = 4.966e-06
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = emp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## SARMA = 44.076, df = 2, p-value = 2.685e-10
# Analitics
# LMerr = 23.226, df = 1, p-value = 1.441e-06 => significant
# LMlag = 20.85, df = 1, p-value = 1.298e-10 => significant
# conclusion => moving to Robust LM Diagnostics

# RLMerr = 2.764, df = 1, p-value = 0.09641 
# RLMlag = 19.232, df = 1, p-value = 4.966e-06
# p-value: RLMlag < RLMerr => RLMlag is robust

# SAR - spatial autoregressive model
# y = X beta + rho W1 y + u
#building an actual model
SAR_Emp_V <- lagsarlm(emp_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_Emp_V <- summary(SAR_Emp_V)

sum_Emp_V$Coef[, c(1,4)] %>% xtable()
# print("NOX")
# print(sum_b$Coef[c(11),])

#comparing our spatial model with the original one
logLik(SAR_Emp_V)
## 'log Lik.' 253.3943 (df=7)
logLik(reg_emp_2017_V)
## 'log Lik.' 242.313 (df=6)
AIC(SAR_Emp_V)
## [1] -492.7886
AIC(reg_emp_2017_V)
## [1] -472.626
#AIC - the bigger, the better the model
#log-likelihood  - the smaller, the better the model

#SAR is better than OLS in this case

##Unemp, V

 #strange ritual

reg_unemp_2017_V <- lm(unemp_2017_V, data = Russia_shape@data)
summary(reg_unemp_2017_V) #%>% xtable()
## 
## Call:
## lm(formula = unemp_2017_V, data = Russia_shape@data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -4.0931 -1.9198 -0.4699  1.1838 17.5392 
## 
## Coefficients:
##                Estimate Std. Error t value Pr(>|t|)   
## (Intercept)   36.789563  21.520500   1.710  0.09155 . 
## V_2017        -0.212129   0.410043  -0.517  0.60647   
## log(Inv_2017) -1.988094   0.597222  -3.329  0.00136 **
## educ_2017     -0.009111   0.004104  -2.220  0.02950 * 
## Wage_2017     -0.050265   0.213615  -0.235  0.81462   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 3.247 on 74 degrees of freedom
## Multiple R-squared:  0.2008, Adjusted R-squared:  0.1576 
## F-statistic: 4.648 on 4 and 74 DF,  p-value: 0.002108
#H0 - residuals are randomly distributed (no-autocorrelation)
lm.morantest(reg_unemp_2017_V,Russia.weights)
## 
##  Global Moran I for regression residuals
## 
## data:  
## model: lm(formula = unemp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## Moran I statistic standard deviate = 8.3878, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Observed Moran I      Expectation         Variance 
##        0.3770416       -0.0186465        0.0022254
moran.test(reg_unemp_2017_V$residuals, Russia.weights)
## 
##  Moran I test under randomisation
## 
## data:  reg_unemp_2017_V$residuals  
## weights: Russia.weights    
## 
## Moran I statistic standard deviate = 8.4991, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##       0.377041625      -0.012820513       0.002104124
moran.plot(reg_unemp_2017_V$residuals, Russia.weights)

# residuals are correlated according to the both test and graph
lm.LMtests(reg_unemp_2017_V, listw = Russia.weights, test="all", zero.policy=TRUE)
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = unemp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMerr = 50.698, df = 1, p-value = 1.077e-12
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = unemp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## LMlag = 56.152, df = 1, p-value = 6.706e-14
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = unemp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMerr = 0.068266, df = 1, p-value = 0.7939
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = unemp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## RLMlag = 5.5219, df = 1, p-value = 0.01878
## 
## 
##  Lagrange multiplier diagnostics for spatial dependence
## 
## data:  
## model: lm(formula = unemp_2017_V, data = Russia_shape@data)
## weights: Russia.weights
## 
## SARMA = 56.22, df = 2, p-value = 6.193e-13
# Analitics
# LMerr = 50.698, df = 1, p-value = 1.077e-12 => significant
# LMlag = 56.152, df = 1, p-value = 6.706e-14 => significant
# conclusion => moving to Robust LM Diagnostics

# RLMerr = 0.068266, df = 1, p-value = 0.7939 
# RLMlag = 5.5219, df = 1, p-value =0.01878
# p-value: RLMlag < RLMerr => RLMlag is robust

# SAR - spatial autoregressive model
# y = X beta + rho W1 y + u
#building an actual model
SAR_Unemp_V <- lagsarlm(unemp_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_Unemp_V <- summary(SAR_Unemp_V)

sum_Unemp_V$Coef[, c(1,4)] %>% xtable()
# print("NOX")
# print(sum_b$Coef[c(11),])

#comparing our spatial model with the original one
logLik(SAR_Unemp_V)
## 'log Lik.' -186.9628 (df=7)
logLik(reg_unemp_2017_V)
## 'log Lik.' -202.5425 (df=6)
AIC(SAR_Unemp_V)
## [1] 387.9257
AIC(reg_unemp_2017_V)
## [1] 417.0849
#AIC - the bigger, the better the model
#log-likelihood  - the smaller, the better the model

#SAR is better than OLS in this case

#Right tables, RV, UV ## SEM, RV, UV

SEM_GRP_RV_UV <- errorsarlm(grp_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_GRP_RV_UV <- summary(SEM_GRP_RV_UV)
sum_GRP_RV_UV
## 
## Call:errorsarlm(formula = grp_2017_RV_UV, listw = Russia.weights, 
##     zero.policy = TRUE)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -1.268640 -0.344029 -0.033312  0.381603  1.579997 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value  Pr(>|z|)
## (Intercept)   -5.12308318  4.07349607 -1.2577  0.208514
## Rv_2017        0.37582518  0.12838078  2.9274  0.003418
## Uv_2017        0.84269512  0.13450702  6.2651 3.727e-10
## log(Inv_2017)  0.86691086  0.12287194  7.0554 1.721e-12
## educ_2017      0.00076803  0.00083658  0.9180  0.358593
## Wage_2017      0.05866649  0.03977885  1.4748  0.140262
## 
## Lambda: 0.70158, LR test value: 22.404, p-value: 2.2097e-06
## Asymptotic standard error: 0.10163
##     z-value: 6.9032, p-value: 5.0833e-12
## Wald statistic: 47.655, p-value: 5.0833e-12
## 
## Log likelihood: -77.28472 for error model
## ML residual variance (sigma squared): 0.38385, (sigma: 0.61956)
## Number of observations: 79 
## Number of parameters estimated: 8 
## AIC: 170.57, (AIC for lm: 190.97)
# sum_GRP_RV_UV$Coef[, c(1,4)] %>% xtable()
SEM_LabPr_RV_UV <- errorsarlm(labpr_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_LabPr_RV_UV <- summary(SEM_LabPr_RV_UV)
sum_LabPr_RV_UV
## 
## Call:errorsarlm(formula = labpr_2017_RV_UV, listw = Russia.weights, 
##     zero.policy = TRUE)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -7.339217 -1.568437 -0.012222  1.383038  9.771580 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value  Pr(>|z|)
## (Intercept)   134.0442462  18.1914227  7.3685 1.725e-13
## Rv_2017        -0.3015020   0.5140901 -0.5865   0.55756
## Uv_2017         0.5256910   0.6089462  0.8633   0.38798
## log(Inv_2017)  -0.1557103   0.4814599 -0.3234   0.74638
## educ_2017      -0.0035936   0.0036895 -0.9740   0.33004
## Wage_2017      -0.3045703   0.1806852 -1.6856   0.09186
## 
## Lambda: -0.25462, LR test value: 0.79569, p-value: 0.37239
## Asymptotic standard error: 0.27104
##     z-value: -0.93943, p-value: 0.34751
## Wald statistic: 0.88253, p-value: 0.34751
## 
## Log likelihood: -191.3756 for error model
## ML residual variance (sigma squared): 7.3993, (sigma: 2.7202)
## Number of observations: 79 
## Number of parameters estimated: 8 
## AIC: 398.75, (AIC for lm: 397.55)
# sum_LabPr_RV_UV$Coef[, c(1,4)] %>% xtable()
SEM_Emp_RV_UV <- errorsarlm(emp_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_Emp_RV_UV <- summary(SEM_Emp_RV_UV)
sum_Emp_RV_UV
## 
## Call:errorsarlm(formula = emp_2017_RV_UV, listw = Russia.weights, 
##     zero.policy = TRUE)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0240285 -0.0047497 -0.0019357  0.0029796  0.0421506 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value Pr(>|z|)
## (Intercept)   -6.5370e-03  6.2903e-02 -0.1039  0.91723
## Rv_2017       -1.2833e-03  1.9811e-03 -0.6478  0.51713
## Uv_2017        3.5233e-03  2.0827e-03  1.6918  0.09069
## log(Inv_2017)  3.3945e-03  1.8907e-03  1.7954  0.07260
## educ_2017     -1.4115e-05  1.2933e-05 -1.0914  0.27509
## Wage_2017     -1.7146e-04  6.1562e-04 -0.2785  0.78061
## 
## Lambda: 0.64862, LR test value: 18.228, p-value: 1.9602e-05
## Asymptotic standard error: 0.1151
##     z-value: 5.6352, p-value: 1.7489e-08
## Wald statistic: 31.755, p-value: 1.7489e-08
## 
## Log likelihood: 252.9047 for error model
## ML residual variance (sigma squared): 9.124e-05, (sigma: 0.009552)
## Number of observations: 79 
## Number of parameters estimated: 8 
## AIC: -489.81, (AIC for lm: -473.58)
# sum_Emp_RV_UV$Coef[, c(1,4)] %>% xtable()
SEM_Unemp_RV_UV <- errorsarlm(unemp_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_Unemp_RV_UV <- summary(SEM_Unemp_RV_UV)
sum_Unemp_RV_UV
## 
## Call:errorsarlm(formula = unemp_2017_RV_UV, listw = Russia.weights, 
##     zero.policy = TRUE)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -4.39172 -1.27483 -0.46471  0.43817 15.11471 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##                 Estimate Std. Error z value  Pr(>|z|)
## (Intercept)   54.0341714 16.1969696  3.3361 0.0008497
## Rv_2017       -0.8681169  0.5103454 -1.7010 0.0889359
## Uv_2017       -0.8698158  0.5337190 -1.6297 0.1031594
## log(Inv_2017) -1.2875275  0.4893523 -2.6311 0.0085113
## educ_2017     -0.0040946  0.0033228 -1.2323 0.2178434
## Wage_2017     -0.2915002  0.1579002 -1.8461 0.0648771
## 
## Lambda: 0.73449, LR test value: 29.063, p-value: 7.006e-08
## Asymptotic standard error: 0.092918
##     z-value: 7.9047, p-value: 2.6645e-15
## Wald statistic: 62.484, p-value: 2.6645e-15
## 
## Log likelihood: -186.8151 for error model
## ML residual variance (sigma squared): 6.0784, (sigma: 2.4654)
## Number of observations: 79 
## Number of parameters estimated: 8 
## AIC: 389.63, (AIC for lm: 416.69)
# sum_Unemp_RV_UV$Coef[, c(1,4)] %>% xtable()

SAR, RV, UV

SAR_GRP_RV_UV <- lagsarlm(grp_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_GRP_RV_UV <- summary(SAR_GRP_RV_UV)
sum_GRP_RV_UV
## 
## Call:
## lagsarlm(formula = grp_2017_RV_UV, listw = Russia.weights, zero.policy = TRUE)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -1.601843 -0.381421 -0.020803  0.366851  1.859883 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value  Pr(>|z|)
## (Intercept)   -5.26362652  4.85216403 -1.0848   0.27801
## Rv_2017        0.22694118  0.13903419  1.6323   0.10262
## Uv_2017        0.76473134  0.15875648  4.8170 1.457e-06
## log(Inv_2017)  0.68249716  0.13290477  5.1352 2.818e-07
## educ_2017      0.00207507  0.00097229  2.1342   0.03282
## Wage_2017      0.02670350  0.04646894  0.5747   0.56553
## 
## Rho: 0.41441, LR test value: 7.1133, p-value: 0.0076512
## Asymptotic standard error: 0.11595
##     z-value: 3.5739, p-value: 0.00035165
## Wald statistic: 12.773, p-value: 0.00035165
## 
## Log likelihood: -84.9298 for lag model
## ML residual variance (sigma squared): 0.49242, (sigma: 0.70172)
## Number of observations: 79 
## Number of parameters estimated: 8 
## AIC: 185.86, (AIC for lm: 190.97)
## LM test for residual autocorrelation
## test value: 17.003, p-value: 3.7317e-05
# sum_GRP_RV_UV$Coef[, c(1,4)] %>% xtable()
SAR_LabPr_RV_UV <- lagsarlm(labpr_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_LabPr_RV_UV <- summary(SAR_LabPr_RV_UV)
sum_LabPr_RV_UV
## 
## Call:lagsarlm(formula = labpr_2017_RV_UV, listw = Russia.weights, 
##     zero.policy = TRUE)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -7.391974 -1.605995 -0.067596  1.422568  9.812599 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value  Pr(>|z|)
## (Intercept)   154.9373027  32.1146394  4.8245 1.403e-06
## Rv_2017        -0.2186861   0.5364057 -0.4077   0.68350
## Uv_2017         0.5459102   0.6094575  0.8957   0.37040
## log(Inv_2017)  -0.1805109   0.5027455 -0.3591   0.71956
## educ_2017      -0.0038268   0.0037172 -1.0295   0.30326
## Wage_2017      -0.2967812   0.1804183 -1.6450   0.09998
## 
## Rho: -0.20944, LR test value: 0.65137, p-value: 0.41962
## Asymptotic standard error: 0.26232
##     z-value: -0.79841, p-value: 0.42463
## Wald statistic: 0.63746, p-value: 0.42463
## 
## Log likelihood: -191.4478 for lag model
## ML residual variance (sigma squared): 7.4261, (sigma: 2.7251)
## Number of observations: 79 
## Number of parameters estimated: 8 
## AIC: 398.9, (AIC for lm: 397.55)
## LM test for residual autocorrelation
## test value: 0.076501, p-value: 0.7821
# sum_LabPr_RV_UV$Coef[, c(1,4)] %>% xtable()
SAR_Emp_RV_UV <- lagsarlm(emp_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_Emp_RV_UV <- summary(SAR_Emp_RV_UV)
sum_Emp_RV_UV
## 
## Call:
## lagsarlm(formula = emp_2017_RV_UV, listw = Russia.weights, zero.policy = TRUE)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0255106 -0.0042322 -0.0015043  0.0031514  0.0409784 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value Pr(>|z|)
## (Intercept)   -1.7499e-02  6.2778e-02 -0.2787  0.78044
## Rv_2017       -7.2485e-04  1.8481e-03 -0.3922  0.69490
## Uv_2017        4.4786e-03  2.1079e-03  2.1247  0.03361
## log(Inv_2017)  3.8050e-03  1.7639e-03  2.1572  0.03099
## educ_2017     -1.6962e-05  1.2865e-05 -1.3185  0.18733
## Wage_2017     -2.4252e-04  6.2176e-04 -0.3901  0.69649
## 
## Rho: 0.59543, LR test value: 21.882, p-value: 2.9001e-06
## Asymptotic standard error: 0.11764
##     z-value: 5.0617, p-value: 4.156e-07
## Wald statistic: 25.621, p-value: 4.156e-07
## 
## Log likelihood: 254.7317 for lag model
## ML residual variance (sigma squared): 8.8191e-05, (sigma: 0.009391)
## Number of observations: 79 
## Number of parameters estimated: 8 
## AIC: -493.46, (AIC for lm: -473.58)
## LM test for residual autocorrelation
## test value: 1.5874, p-value: 0.2077
# sum_Emp_RV_UV$Coef[, c(1,4)] %>% xtable()
SAR_Unemp_RV_UV <- lagsarlm(unemp_2017_RV_UV, listw = Russia.weights, zero.policy=TRUE)
sum_Unemp_RV_UV <- summary(SAR_Unemp_RV_UV)
sum_Unemp_RV_UV
## 
## Call:lagsarlm(formula = unemp_2017_RV_UV, listw = Russia.weights, 
##     zero.policy = TRUE)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -4.33587 -1.23364 -0.29277  0.67184 14.69214 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##                 Estimate Std. Error z value Pr(>|z|)
## (Intercept)   46.7447483 16.6151022  2.8134 0.004902
## Rv_2017       -0.3572664  0.4885261 -0.7313 0.464587
## Uv_2017       -0.8712627  0.5560522 -1.5669 0.117145
## log(Inv_2017) -1.4090245  0.4613569 -3.0541 0.002257
## educ_2017     -0.0061257  0.0033969 -1.8033 0.071338
## Wage_2017     -0.2516032  0.1637879 -1.5362 0.124501
## 
## Rho: 0.71156, LR test value: 29.138, p-value: 6.7393e-08
## Asymptotic standard error: 0.089121
##     z-value: 7.9843, p-value: 1.3323e-15
## Wald statistic: 63.748, p-value: 1.4433e-15
## 
## Log likelihood: -186.7775 for lag model
## ML residual variance (sigma squared): 6.1189, (sigma: 2.4736)
## Number of observations: 79 
## Number of parameters estimated: 8 
## AIC: 389.55, (AIC for lm: 416.69)
## LM test for residual autocorrelation
## test value: 0.070019, p-value: 0.79131
# sum_Unemp_RV_UV$Coef[, c(1,4)] %>% xtable()

#Right tables, V ## SEM, V

SEM_GRP_V <- errorsarlm(grp_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_GRP_V <- summary(SEM_GRP_V)
sum_GRP_V
## 
## Call:
## errorsarlm(formula = grp_2017_V, listw = Russia.weights, zero.policy = TRUE)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -1.4572154 -0.3616371  0.0082359  0.3594635  1.6644839 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value  Pr(>|z|)
## (Intercept)   -4.11947703  4.19264608 -0.9825   0.32583
## V_2017         0.59945416  0.08793841  6.8167 9.312e-12
## log(Inv_2017)  0.84441430  0.12672454  6.6634 2.676e-11
## educ_2017      0.00148510  0.00080593  1.8427   0.06537
## Wage_2017      0.05411408  0.04112019  1.3160   0.18817
## 
## Lambda: 0.69705, LR test value: 22.768, p-value: 1.8275e-06
## Asymptotic standard error: 0.10281
##     z-value: 6.7799, p-value: 1.203e-11
## Wald statistic: 45.966, p-value: 1.203e-11
## 
## Log likelihood: -79.90729 for error model
## ML residual variance (sigma squared): 0.41077, (sigma: 0.64091)
## Number of observations: 79 
## Number of parameters estimated: 7 
## AIC: 173.81, (AIC for lm: 194.58)
# sum_GRP_V$Coef[, c(1,4)] %>% xtable()
SEM_LabPr_V <- errorsarlm(labpr_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_LabPr_V <- summary(SEM_LabPr_V)
sum_LabPr_V
## 
## Call:
## errorsarlm(formula = labpr_2017_V, listw = Russia.weights, zero.policy = TRUE)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -7.61870 -1.53586  0.10756  1.34730 10.05941 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value  Pr(>|z|)
## (Intercept)   136.3692901  18.1140989  7.5284 5.129e-14
## V_2017          0.0841114   0.3303093  0.2546   0.79900
## log(Inv_2017)  -0.1259115   0.4855179 -0.2593   0.79538
## educ_2017      -0.0024834   0.0034384 -0.7222   0.47014
## Wage_2017      -0.3255194   0.1798097 -1.8104   0.07024
## 
## Lambda: -0.19552, LR test value: 0.50358, p-value: 0.47793
## Asymptotic standard error: 0.26435
##     z-value: -0.73962, p-value: 0.45953
## Wald statistic: 0.54704, p-value: 0.45953
## 
## Log likelihood: -191.76 for error model
## ML residual variance (sigma squared): 7.4886, (sigma: 2.7365)
## Number of observations: 79 
## Number of parameters estimated: 7 
## AIC: 397.52, (AIC for lm: 396.02)
# sum_LabPr_V$Coef[, c(1,4)] %>% xtable()
SEM_Emp_V <- errorsarlm(emp_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_Emp_V <- summary(SEM_Emp_V)
sum_Emp_V
## 
## Call:
## errorsarlm(formula = emp_2017_V, listw = Russia.weights, zero.policy = TRUE)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0235151 -0.0047620 -0.0014592  0.0026884  0.0432237 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value Pr(>|z|)
## (Intercept)    3.7341e-03  6.3452e-02  0.0588   0.9531
## V_2017         1.0055e-03  1.3286e-03  0.7568   0.4492
## log(Inv_2017)  3.1601e-03  1.9132e-03  1.6517   0.0986
## educ_2017     -6.7154e-06  1.2208e-05 -0.5501   0.5823
## Wage_2017     -2.1739e-04  6.2334e-04 -0.3488   0.7273
## 
## Lambda: 0.6554, LR test value: 18.827, p-value: 1.4313e-05
## Asymptotic standard error: 0.11342
##     z-value: 5.7788, p-value: 7.5244e-09
## Wald statistic: 33.394, p-value: 7.5244e-09
## 
## Log likelihood: 251.7265 for error model
## ML residual variance (sigma squared): 9.384e-05, (sigma: 0.0096871)
## Number of observations: 79 
## Number of parameters estimated: 7 
## AIC: -489.45, (AIC for lm: -472.63)
# sum_Emp_V$Coef[, c(1,4)] %>% xtable()
SEM_Unemp_V <- errorsarlm(unemp_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_Unemp_V <- summary(SEM_Unemp_V)
sum_Unemp_V
## 
## Call:
## errorsarlm(formula = unemp_2017_V, listw = Russia.weights, zero.policy = TRUE)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -4.39135 -1.27525 -0.46509  0.43801 15.11481 
## 
## Type: error 
## Coefficients: (asymptotic standard errors) 
##                 Estimate Std. Error z value  Pr(>|z|)
## (Intercept)   54.0308174 16.1122315  3.3534 0.0007982
## V_2017        -0.8689451  0.3382183 -2.5692 0.0101938
## log(Inv_2017) -1.2874281  0.4877799 -2.6394 0.0083062
## educ_2017     -0.0040971  0.0030934 -1.3245 0.1853521
## Wage_2017     -0.2914879  0.1577385 -1.8479 0.0646142
## 
## Lambda: 0.73452, LR test value: 31.455, p-value: 2.0414e-08
## Asymptotic standard error: 0.092911
##     z-value: 7.9056, p-value: 2.6645e-15
## Wald statistic: 62.498, p-value: 2.6645e-15
## 
## Log likelihood: -186.8151 for error model
## ML residual variance (sigma squared): 6.0784, (sigma: 2.4654)
## Number of observations: 79 
## Number of parameters estimated: 7 
## AIC: 387.63, (AIC for lm: 417.08)
# sum_Unemp_V$Coef[, c(1,4)] %>% xtable()

SAR, V

SAR_GRP_V <- lagsarlm(grp_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_GRP_V <- summary(SAR_GRP_V)
sum_GRP_V
## 
## Call:lagsarlm(formula = grp_2017_V, listw = Russia.weights, zero.policy = TRUE)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.72443 -0.39031 -0.03862  0.35148  2.10420 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value  Pr(>|z|)
## (Intercept)   -4.43646678  4.94129824 -0.8978  0.369274
## V_2017         0.46980323  0.09440304  4.9766 6.472e-07
## log(Inv_2017)  0.70141368  0.13523092  5.1868 2.140e-07
## educ_2017      0.00288847  0.00092998  3.1060  0.001897
## Wage_2017      0.01695573  0.04759926  0.3562  0.721677
## 
## Rho: 0.43781, LR test value: 7.6954, p-value: 0.0055362
## Asymptotic standard error: 0.11549
##     z-value: 3.7908, p-value: 0.00015019
## Wald statistic: 14.37, p-value: 0.00015019
## 
## Log likelihood: -87.4438 for lag model
## ML residual variance (sigma squared): 0.52332, (sigma: 0.72341)
## Number of observations: 79 
## Number of parameters estimated: 7 
## AIC: 188.89, (AIC for lm: 194.58)
## LM test for residual autocorrelation
## test value: 17.657, p-value: 2.6453e-05
# sum_GRP_V$Coef[, c(1,4)] %>% xtable()
SAR_LabPr_V <- lagsarlm(labpr_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_LabPr_V <- summary(SAR_LabPr_V)
sum_LabPr_V
## 
## Call:
## lagsarlm(formula = labpr_2017_V, listw = Russia.weights, zero.policy = TRUE)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -7.61160 -1.58671  0.13859  1.39787 10.06902 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value  Pr(>|z|)
## (Intercept)   153.0414023  31.8372152  4.8070 1.532e-06
## V_2017          0.1329236   0.3458757  0.3843    0.7007
## log(Inv_2017)  -0.1649660   0.5037736 -0.3275    0.7433
## educ_2017      -0.0027275   0.0034636 -0.7875    0.4310
## Wage_2017      -0.3132298   0.1802191 -1.7380    0.0822
## 
## Rho: -0.17144, LR test value: 0.45327, p-value: 0.50079
## Asymptotic standard error: 0.25959
##     z-value: -0.66043, p-value: 0.50898
## Wald statistic: 0.43616, p-value: 0.50898
## 
## Log likelihood: -191.7851 for lag model
## ML residual variance (sigma squared): 7.4991, (sigma: 2.7385)
## Number of observations: 79 
## Number of parameters estimated: 7 
## AIC: 397.57, (AIC for lm: 396.02)
## LM test for residual autocorrelation
## test value: 0.00032567, p-value: 0.9856
# sum_LabPr_V$Coef[, c(1,4)] %>% xtable()
SAR_Emp_V <- lagsarlm(emp_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_Emp_V <- summary(SAR_Emp_V)
sum_Emp_V
## 
## Call:lagsarlm(formula = emp_2017_V, listw = Russia.weights, zero.policy = TRUE)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0251511 -0.0046484 -0.0017103  0.0029902  0.0422805 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##                  Estimate  Std. Error z value Pr(>|z|)
## (Intercept)   -3.8653e-03  6.3309e-02 -0.0611   0.9513
## V_2017         1.5971e-03  1.2112e-03  1.3187   0.1873
## log(Inv_2017)  3.9399e-03  1.7733e-03  2.2218   0.0263
## educ_2017     -8.8339e-06  1.2106e-05 -0.7297   0.4656
## Wage_2017     -3.5976e-04  6.2815e-04 -0.5727   0.5668
## 
## Rho: 0.60472, LR test value: 22.163, p-value: 2.505e-06
## Asymptotic standard error: 0.11786
##     z-value: 5.1308, p-value: 2.8845e-07
## Wald statistic: 26.326, p-value: 2.8845e-07
## 
## Log likelihood: 253.3943 for lag model
## ML residual variance (sigma squared): 9.1047e-05, (sigma: 0.0095419)
## Number of observations: 79 
## Number of parameters estimated: 7 
## AIC: -492.79, (AIC for lm: -472.63)
## LM test for residual autocorrelation
## test value: 1.6953, p-value: 0.19291
# sum_Emp_V$Coef[, c(1,4)] %>% xtable()
SAR_Unemp_V <- lagsarlm(unemp_2017_V, listw = Russia.weights, zero.policy=TRUE)
sum_Unemp_V <- summary(SAR_Unemp_V)
sum_Unemp_V
## 
## Call:
## lagsarlm(formula = unemp_2017_V, listw = Russia.weights, zero.policy = TRUE)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -4.22816 -1.25631 -0.29717  0.72377 14.79010 
## 
## Type: lag 
## Coefficients: (asymptotic standard errors) 
##                 Estimate Std. Error z value Pr(>|z|)
## (Intercept)   45.6125959 16.5041991  2.7637 0.005715
## V_2017        -0.5942460  0.3170156 -1.8745 0.060861
## log(Inv_2017) -1.4192191  0.4594867 -3.0887 0.002010
## educ_2017     -0.0068755  0.0031531 -2.1806 0.029214
## Wage_2017     -0.2433058  0.1629150 -1.4935 0.135319
## 
## Rho: 0.72246, LR test value: 31.159, p-value: 2.377e-08
## Asymptotic standard error: 0.086524
##     z-value: 8.3498, p-value: < 2.22e-16
## Wald statistic: 69.72, p-value: < 2.22e-16
## 
## Log likelihood: -186.9628 for lag model
## ML residual variance (sigma squared): 6.126, (sigma: 2.4751)
## Number of observations: 79 
## Number of parameters estimated: 7 
## AIC: 387.93, (AIC for lm: 417.08)
## LM test for residual autocorrelation
## test value: 0.22334, p-value: 0.63651
# sum_Unemp_V$Coef[, c(1,4)] %>% xtable()

#Common tables

stargazer(SEM_GRP_V, reg_labpr_2017_V, SAR_Emp_V, SAR_Unemp_V, SEM_GRP_RV_UV, reg_labpr_2017_RV_UV, SAR_Emp_RV_UV, SAR_Unemp_RV_UV, type = "text", omit = c('Constant'), keep.stat = c("n"), font.size = "tiny", title = 'Crossectional Spatial models, mixed types',
          
add.lines = list(c('model', 'SEM', 'OLS', 'SAR', 'SAR', 'SEM', 'OLS', 'SAR', 'SAR')), header=FALSE, dep.var.labels = NULL, 
model.names = FALSE) #ci = T
## 
## Crossectional Spatial models, mixed types
## =========================================================================================================
##                                                   Dependent variable:                                    
##               -------------------------------------------------------------------------------------------
##               log(GRP_2017) LabPr_2017 Emp_2017  Unemp_2017 log(GRP_2017) LabPr_2017 Emp_2017  Unemp_2017
##                    (1)         (2)        (3)       (4)          (5)         (6)        (7)       (8)    
## ---------------------------------------------------------------------------------------------------------
## V_2017          0.599***      0.168      0.002    -0.594*                                                
##                  (0.088)     (0.359)    (0.001)   (0.317)                                                
##                                                                                                          
## Rv_2017                                                       0.376***      -0.119    -0.001     -0.357  
##                                                                (0.128)     (0.561)    (0.002)   (0.489)  
##                                                                                                          
## Uv_2017                                                       0.843***      0.517     0.004**    -0.871  
##                                                                (0.135)     (0.638)    (0.002)   (0.556)  
##                                                                                                          
## log(Inv_2017)   0.844***      -0.221    0.004**  -1.419***    0.867***      -0.244    0.004**  -1.409*** 
##                  (0.127)     (0.523)    (0.002)   (0.459)      (0.123)     (0.526)    (0.002)   (0.461)  
##                                                                                                          
## educ_2017        0.001*       -0.003   -0.00001   -0.007**      0.001       -0.004   -0.00002   -0.006*  
##                  (0.001)     (0.004)   (0.00001)  (0.003)      (0.001)     (0.004)   (0.00001)  (0.003)  
##                                                                                                          
## Wage_2017         0.054      -0.312*    -0.0004    -0.243       0.059       -0.298    -0.0002    -0.252  
##                  (0.041)     (0.187)    (0.001)   (0.163)      (0.040)     (0.189)    (0.001)   (0.164)  
##                                                                                                          
## ---------------------------------------------------------------------------------------------------------
## model              SEM         OLS        SAR       SAR          SEM         OLS        SAR       SAR    
## Observations       79           79        79         79          79           79        79         79    
## =========================================================================================================
## Note:                                                                         *p<0.1; **p<0.05; ***p<0.01
stargazer(SEM_GRP_V, SEM_LabPr_V, SEM_Emp_V, SEM_Unemp_V, SEM_GRP_RV_UV, SEM_LabPr_RV_UV, SEM_Emp_RV_UV, SEM_Unemp_RV_UV, type = "text", omit = c('Constant'), keep.stat = c("n"), font.size = "tiny", title = 'Crossectional Spatial models, Spatial Error model',
          
add.lines = list(c('model', 'SEM', 'SEM', 'SEM', 'SEM', 'SEM', 'SEM', 'SEM', 'SEM')), header=FALSE, dep.var.labels = NULL, 
model.names = FALSE)
## 
## Crossectional Spatial models, Spatial Error model
## =========================================================================================================
##                                                   Dependent variable:                                    
##               -------------------------------------------------------------------------------------------
##               log(GRP_2017) LabPr_2017 Emp_2017  Unemp_2017 log(GRP_2017) LabPr_2017 Emp_2017  Unemp_2017
##                    (1)         (2)        (3)       (4)          (5)         (6)        (7)       (8)    
## ---------------------------------------------------------------------------------------------------------
## V_2017          0.599***      0.084      0.001    -0.869**                                               
##                  (0.088)     (0.330)    (0.001)   (0.338)                                                
##                                                                                                          
## Rv_2017                                                       0.376***      -0.302    -0.001    -0.868*  
##                                                                (0.128)     (0.514)    (0.002)   (0.510)  
##                                                                                                          
## Uv_2017                                                       0.843***      0.526     0.004*     -0.870  
##                                                                (0.135)     (0.609)    (0.002)   (0.534)  
##                                                                                                          
## log(Inv_2017)   0.844***      -0.126    0.003*   -1.287***    0.867***      -0.156    0.003*   -1.288*** 
##                  (0.127)     (0.486)    (0.002)   (0.488)      (0.123)     (0.481)    (0.002)   (0.489)  
##                                                                                                          
## educ_2017        0.001*       -0.002   -0.00001    -0.004       0.001       -0.004   -0.00001    -0.004  
##                  (0.001)     (0.003)   (0.00001)  (0.003)      (0.001)     (0.004)   (0.00001)  (0.003)  
##                                                                                                          
## Wage_2017         0.054      -0.326*    -0.0002   -0.291*       0.059      -0.305*    -0.0002   -0.292*  
##                  (0.041)     (0.180)    (0.001)   (0.158)      (0.040)     (0.181)    (0.001)   (0.158)  
##                                                                                                          
## ---------------------------------------------------------------------------------------------------------
## model              SEM         SEM        SEM       SEM          SEM         SEM        SEM       SEM    
## Observations       79           79        79         79          79           79        79         79    
## =========================================================================================================
## Note:                                                                         *p<0.1; **p<0.05; ***p<0.01
stargazer( SAR_GRP_V, SAR_LabPr_V, SAR_Emp_V, SAR_Unemp_V, SAR_GRP_RV_UV, SAR_LabPr_RV_UV, SAR_Emp_RV_UV, SAR_Unemp_RV_UV, type = "text", omit = c('Constant'), keep.stat = c("n"), font.size = "tiny", title = 'Crossectional Spatial models, Spatial Autoregressive model',
          
add.lines = list(c('model', 'SAR', 'SAR', 'SAR', 'SAR', 'SAR', 'SAR', 'SAR', 'SAR')), header=FALSE, dep.var.labels = NULL, 
model.names = FALSE)
## 
## Crossectional Spatial models, Spatial Autoregressive model
## =========================================================================================================
##                                                   Dependent variable:                                    
##               -------------------------------------------------------------------------------------------
##               log(GRP_2017) LabPr_2017 Emp_2017  Unemp_2017 log(GRP_2017) LabPr_2017 Emp_2017  Unemp_2017
##                    (1)         (2)        (3)       (4)          (5)         (6)        (7)       (8)    
## ---------------------------------------------------------------------------------------------------------
## V_2017          0.470***      0.133      0.002    -0.594*                                                
##                  (0.094)     (0.346)    (0.001)   (0.317)                                                
##                                                                                                          
## Rv_2017                                                         0.227       -0.219    -0.001     -0.357  
##                                                                (0.139)     (0.536)    (0.002)   (0.489)  
##                                                                                                          
## Uv_2017                                                       0.765***      0.546     0.004**    -0.871  
##                                                                (0.159)     (0.609)    (0.002)   (0.556)  
##                                                                                                          
## log(Inv_2017)   0.701***      -0.165    0.004**  -1.419***    0.682***      -0.181    0.004**  -1.409*** 
##                  (0.135)     (0.504)    (0.002)   (0.459)      (0.133)     (0.503)    (0.002)   (0.461)  
##                                                                                                          
## educ_2017       0.003***      -0.003   -0.00001   -0.007**     0.002**      -0.004   -0.00002   -0.006*  
##                  (0.001)     (0.003)   (0.00001)  (0.003)      (0.001)     (0.004)   (0.00001)  (0.003)  
##                                                                                                          
## Wage_2017         0.017      -0.313*    -0.0004    -0.243       0.027      -0.297*    -0.0002    -0.252  
##                  (0.048)     (0.180)    (0.001)   (0.163)      (0.046)     (0.180)    (0.001)   (0.164)  
##                                                                                                          
## ---------------------------------------------------------------------------------------------------------
## model              SAR         SAR        SAR       SAR          SAR         SAR        SAR       SAR    
## Observations       79           79        79         79          79           79        79         79    
## =========================================================================================================
## Note:                                                                         *p<0.1; **p<0.05; ***p<0.01