#Preliminares
#install.packages("survival")
#install.packages("KMsurv")
#install.packages("survMisc")
#install.packages("survminer")
#install.packages("flexsurv")
#install.packages("actuar")
#install.packages("dplyr")
#install.packages("moments")
#install.packages("rms")
#install.packages("SurvRegCensCov")
rm(list = ls())
options(scipen=999)
library(pacman)
library(janitor)
library(sandwich)
library(pastecs)
library(nnet)
library(MASS)
library(AER)
library(survival)
#library(sampleSelection)
#library(COUNT)
#library(quantreg)
library(rgdal) # Leer objetos espaciales
library(leaflet) #Mapas con fondos
library(spatialreg)
library(sf) #leer shapefiles
library(sp)
library(spdep) #análisis de regresión
library(tmap)
p_load(tidyverse, foreign, reshape2, psych, qwraps2, forcats, readxl,
broom, lmtest, margins, plm, rdrobust, multiwayvcov,
wesanderson, sandwich, stargazer, readstata13, pscore, optmatch, kdensity, MatchIt, bootstrap, matlib, dplyr)
Tenemos dos bases que vamos a ocupar para empezar a entender el funcionamiento de las mapas en R.
<-read_csv("./num_robo.csv",
num_robolocale = locale(encoding = "latin1"))
## Rows: 1336 Columns: 2
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): cve_col
## dbl (1): robos
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
<-read_csv("./num_totems.csv",
num_totemslocale = locale(encoding = "latin1"))
## Rows: 1325 Columns: 2
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (1): cve_col
## dbl (1): totems
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
Usamos el paquete rodal para empezar a dibujar los bordes de las colonias:
<- readOGR(".","coloniascdmx",
colonias_shp use_iconv = TRUE,
encoding = "UTF-8")
## OGR data source with driver: ESRI Shapefile
## Source: "C:\DAVE2\CIDE\Doc\Econometria II\Lab_12", layer: "coloniascdmx"
## with 1812 features
## It has 7 fields
## Warning in readOGR(".", "coloniascdmx", use_iconv = TRUE, encoding = "UTF-8"):
## Dropping null geometries: 421, 886, 1003, 1022
Para plotearlo serà suficiente, utilizar el comando dedicado:
plot(colonias_shp)
Si queremos plotear una colonia en particular:
<- colonias_shp[colonias_shp@data$alcaldia=="CUAUHTEMOC",]
colonias_shp2
plot (colonias_shp2)
Con el paquete leafleft podemos obtener mejores resultados.
En ese paquete vienen pre cargado algunas mapas, podemos por ejemplo mapear el mundo:
<- leaflet() %>%
m addTiles()
m
Podemos especificar unas coordinadas para hacer zoom en un determinado lugar:
<- leaflet() %>%
m2 addTiles() %>%
setView(lng=-99.1615, lat=19.430586,
zoom = 15)
m2
A lo shape file podemos pegar distintas estaditicas para poder hacer mapas con “caracteristicas” que reflejen las mismas:
<- st_read("./coloniascdmx.shp") %>%
colonias left_join(num_robo, by="cve_col") %>%
mutate(robos=ifelse(is.na(robos),0,robos)) #Para las colonias sin reporte alguno, ponemos 0
## Reading layer `coloniascdmx' from data source
## `C:\DAVE2\CIDE\Doc\Econometria II\Lab_12\coloniascdmx.shp'
## using driver `ESRI Shapefile'
## replacing null geometries with empty geometries
## Simple feature collection with 1812 features and 7 fields (with 4 geometries empty)
## Geometry type: GEOMETRY
## Dimension: XY
## Bounding box: xmin: -99.35038 ymin: 19.12798 xmax: -98.94565 ymax: 19.59378
## Geodetic CRS: WGS 84
plot(colonias)
SI queremos solo el mapa relativo a los robos haremos:
plot(colonias[8])
Para mapas tematicos podemos utilizar el paquete tmap:
<- sf::st_make_valid(colonias)
colonias
tm_shape(colonias) +
tm_fill("robos",title="Robos a transeuntes en 2019")+
tm_borders(alpha = 0.1)+
tmap_style("col_blind")+tmap_options(check.and.fix = TRUE)
## tmap style set to "col_blind"
## other available styles are: "white", "gray", "natural", "cobalt", "albatross", "beaver", "bw", "classic", "watercolor"
## Warning: The shape colonias contains empty units.
Para hacerlo interactivo podemos utilizr el comando view:
tmap_mode("view")
## tmap mode set to interactive viewing
Ahora el resultado serìa:
tm_shape(colonias) +
tm_fill("robos",title="Robos a transeuntes en 2019")+
tm_borders(alpha = 0.1)+
tmap_style("col_blind")+tmap_options(check.and.fix = TRUE)
## tmap style set to "col_blind"
## other available styles are: "white", "gray", "natural", "cobalt", "albatross", "beaver", "bw", "classic", "watercolor"
## Warning: The shape colonias contains empty units.
Para regresar a la modalidad plot serà suficiente poner:
tmap_mode("plot")
## tmap mode set to plotting
La opcion style nos permite dividir los datos:
<-tm_shape(colonias) +
c1 tm_polygons("robos",title="Robos a transeunte en 2019",style="equal")+
tm_borders(alpha = 0.1)+
tmap_options(check.and.fix = TRUE)
<-tm_shape(colonias) +
c2 ::tm_fill("robos",title="Robos a transeunte en 2019",style="jenks")+
tmaptm_borders(alpha = 0.1)+
tmap_options(check.and.fix = TRUE)
<-tm_shape(colonias) +
c3 tm_fill("robos",title="Robos a transeunte en 2019",style="quantile")+
tm_borders(alpha = 0.1)+
tmap_options(check.and.fix = TRUE)
<-tm_shape(colonias) +
c4 tm_fill("robos",title="Robos a transeunte en 2019",style="cont")+
tm_borders(alpha = 0.1)+
tmap_options(check.and.fix = TRUE)
Podemos ver cual de las distintas mapas y distribuciones nos convence mas:
tmap_arrange(c1,c2,c3,c4)
## Warning: The shape colonias contains empty units.
## Warning: One tm layer group has duplicated layer types, which are omitted. To
## draw multiple layers of the same type, use multiple layer groups (i.e. specify
## tm_shape prior to each of them).
## Warning: The shape colonias contains empty units.
## Warning: The shape colonias contains empty units.
## Warning: The shape colonias contains empty units.
## Warning: The shape colonias contains empty units.
## Warning: One tm layer group has duplicated layer types, which are omitted. To
## draw multiple layers of the same type, use multiple layer groups (i.e. specify
## tm_shape prior to each of them).
## Warning: The shape colonias contains empty units.
## Warning: The shape colonias contains empty units.
## Warning: The shape colonias contains empty units.
Si queremos hacer mapas con simbolos podemos utilizar la siguientes especificaciones:
tm_shape(colonias) +
tm_bubbles("robos")
## Warning: The shape colonias contains empty units.
Eso es un grafico de borbujas, como lo interpretamos¿
En caso que queramos insertarlo tambien en una grafica con las colonias:
tm_shape(colonias) +
tm_bubbles("robos", border.lwd=NA) +
tm_borders(alpha=0.1) +
tm_layout(legend.position = c("right", "bottom"),
legend.title.size = 0.8,
legend.text.size = 0.5)
## Warning: The shape colonias contains empty units.
Si queremos una colonia en especifico podemos hacer lo siguiente:
<- colonias %>%
colonias_coyoacan filter(alcaldia=="COYOACAN") %>% unique()
tm_shape(colonias_coyoacan) +
tm_bubbles("robos", border.lwd=NA, col="blue") +
tm_borders(alpha=0.1) +
tm_layout(legend.position = c("right", "bottom"),
legend.title.size = 0.8,
legend.text.size = 0.5)
Podemos ponerle un fondo con leafleft:
<- leaflet(colonias_coyoacan) %>%
m addTiles() %>%
addPolygons() %>%
setView(lng=-99.17222, lat=19.35417,
zoom = 15)
m
Ahora podemos llenar las diferentes colonias con los distintos robos:
<- colorBin("YlOrRd", domain = colonias_coyoacan$robos)
pal
<- leaflet(colonias_coyoacan) %>%
m addTiles() %>%
addPolygons(fillColor = ~pal(robos),
weight = 2,
opacity = 1,
color = "white",
dashArray = "3",
fillOpacity = 0.7) %>%
addLegend(pal = pal, values = ~robos, opacity = 0.7, title = NULL,
position = "bottomright") %>%
setView(lng=-99.17222, lat=19.35417,
zoom = 15)
m
Si queremos explorar mas las oportunidades que nos da leafleft, les dejo un link de referencia
Usemos la base de colonias y le pegamos nuestras bases de crimen y totems
@data <- colonias_shp@data %>%
colonias_shpleft_join(num_robo, by="cve_col")
@data <- colonias_shp@data %>%
colonias_shpleft_join(num_totems, by="cve_col")
Al fin de la exposicion modificamos nuestra base para que si no conocemos el dato exacto (NA) se vuelva 0.
@data <- colonias_shp@data %>%
colonias_shpmutate(robos=ifelse(is.na(robos),0,robos)) %>%
mutate(totems=ifelse(is.na(totems),0,totems))
Si haacemos la clasica regresión MCO obtendremos:
summary(m.mco<-lm(robos ~ totems, data=colonias_shp@data))
##
## Call:
## lm(formula = robos ~ totems, data = colonias_shp@data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.237 -3.346 -2.346 1.193 117.654
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.34621 0.19650 17.03 <0.0000000000000002 ***
## totems 0.16231 0.01379 11.77 <0.0000000000000002 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.239 on 1806 degrees of freedom
## Multiple R-squared: 0.07128, Adjusted R-squared: 0.07077
## F-statistic: 138.6 on 1 and 1806 DF, p-value: < 0.00000000000000022
Sabemos pero que puede haber una correlacion espacial entre las diferentes zonas, tanto en \(X\) como en \(Y\), cuando estamos regresando con respecto a caacteristicas georeferenciadas.
La matriz de contiguidad a veces se le conoce como tipo “reina” por que simula como se mueve una reina en el ajedrez
Style nos indica que tipo de estandarizacion utilizaremos. W es por filas, por ejemplo.
::sf_use_s2(FALSE) sf
## Spherical geometry (s2) switched off
<-poly2nb(colonias_shp, queen=TRUE) list.queen
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
<-nb2listw(list.queen, style="W", zero.policy=TRUE) Wqueen_row
Podemos obtener un resumen de lo que acabamos de hacer
summary(Wqueen_row, zero.policy=T)
## Characteristics of weights list object:
## Neighbour list object:
## Number of regions: 1808
## Number of nonzero links: 10166
## Percentage nonzero weights: 0.3109949
## Average number of links: 5.622788
## 1 region with no links:
## 744
## Link number distribution:
##
## 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
## 1 50 93 175 278 361 314 206 138 79 46 23 13 9 7 3 4 3 1 2
## 20 27
## 1 1
## 50 least connected regions:
## 24 76 98 137 207 222 261 269 272 300 437 485 506 544 568 590 643 646 696 755 778 780 799 894 902 967 980 1017 1044 1067 1103 1138 1149 1157 1177 1224 1234 1307 1372 1400 1451 1483 1573 1587 1621 1690 1701 1708 1745 1807 with 1 link
## 1 most connected region:
## 425 with 27 links
##
## Weights style: W
## Weights constants summary:
## n nn S0 S1 S2
## W 1807 3265249 1807 727.1154 7867.394
Finalmente, lo que acabamos de hacer es obtener los links entre cada punto con sus vecinos
plot(Wqueen_row,coordinates(colonias_shp))
Si queremos la matriz usando el inverso de las distancias, tendremos que:
Primero obtengamos la distancia
<- coordinates(colonias_shp) # nos da los centroides de las colonias
coords <- as.matrix(dist(coords, method = "euclidean"))
dist.mat 1:5, 1:5] dist.mat[
## 0 1 2 3 4
## 0 0.00000000 0.01608622 0.01304930 0.12760558 0.11494838
## 1 0.01608622 0.00000000 0.02899752 0.12378885 0.11097793
## 2 0.01304930 0.02899752 0.00000000 0.13431903 0.12189141
## 3 0.12760558 0.12378885 0.13431903 0.00000000 0.01281529
## 4 0.11494838 0.11097793 0.12189141 0.01281529 0.00000000
Y obtenemos el inverso de cada entrada
<- 1 / dist.mat
dist.mat.inv diag(dist.mat.inv) <- 0 # hacemos la diagonal igual a cero
1:5, 1:5] dist.mat.inv[
## 0 1 2 3 4
## 0 0.000000 62.165024 76.632442 7.836648 8.699557
## 1 62.165024 0.000000 34.485704 8.078272 9.010800
## 2 76.632442 34.485704 0.000000 7.444962 8.204024
## 3 7.836648 8.078272 7.444962 0.000000 78.031765
## 4 8.699557 9.010800 8.204024 78.031765 0.000000
La convertimos en un objeto para usarla en modelos espaciales
Winvd_row <- mat2listw(dist.mat.inv, style = "W", row.names = colonias_shp$cve_col) #Esto puede tardar un poco
summary(Winvd_row)
Para calcular el test de Moran tendremos que:
<-lm.morantest(m.mco, Wqueen_row, alternative="two.sided", zero.policy = TRUE)
moran.mcoprint(moran.mco)
##
## Global Moran I for regression residuals
##
## data:
## model: lm(formula = robos ~ totems, data = colonias_shp@data)
## weights: Wqueen_row
##
## Moran I statistic standard deviate = 24.486, p-value <
## 0.00000000000000022
## alternative hypothesis: two.sided
## sample estimates:
## Observed Moran I Expectation Variance
## 0.3641715048 -0.0005494363 0.0002218555
Se rechaza la H0 de aleatoriedad de los errores
Por lo tantos tendremos que hacer una regresion espacial
Usamos para eso el paquete spatialreg
Modelo SAR
library(spatialreg)
<-lagsarlm(robos ~ totems ,
m.sardata=colonias_shp@data,
listw=Wqueen_row,
zero.policy=T)
summary(m.sar)
##
## Call:lagsarlm(formula = robos ~ totems, data = colonias_shp@data,
## listw = Wqueen_row, zero.policy = T)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.8519 -2.6269 -1.2825 1.0772 102.9580
##
## Type: lag
## Regions with no neighbours included:
## 744
## Coefficients: (asymptotic standard errors)
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.744102 0.204418 3.6401 0.0002725
## totems 0.156861 0.012325 12.7268 < 0.00000000000000022
##
## Rho: 0.45671, LR test value: 331.37, p-value: < 0.000000000000000222
## Asymptotic standard error: 0.027269
## z-value: 16.748, p-value: < 0.000000000000000222
## Wald statistic: 280.51, p-value: < 0.000000000000000222
##
## Log likelihood: -5977.54 for lag model
## ML residual variance (sigma squared): 41.799, (sigma: 6.4652)
## Number of observations: 1808
## Number of parameters estimated: 4
## AIC: 11963, (AIC for lm: 12292)
## LM test for residual autocorrelation
## test value: 21.004, p-value: 0.0000045827
Noten que rho es el estimado de lo que en clase llamamos lambda
Modelo Durbin
<-lagsarlm(robos ~ totems ,
m.sdmdata=colonias_shp@data,
listw=Wqueen_row,
Durbin=T,
zero.policy=T)
summary(m.sdm)
##
## Call:lagsarlm(formula = robos ~ totems, data = colonias_shp@data,
## listw = Wqueen_row, Durbin = T, zero.policy = T)
##
## Residuals:
## Min 1Q Median 3Q Max
## -24.4381 -2.5862 -1.3437 1.1071 103.2041
##
## Type: mixed
## Regions with no neighbours included:
## 744
## Coefficients: (asymptotic standard errors)
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.288671 0.250508 5.1442 0.0000002686
## totems 0.156206 0.012252 12.7489 < 0.00000000000000022
## lag.totems -0.065565 0.018173 -3.6078 0.0003088
##
## Rho: 0.46916, LR test value: 344.29, p-value: < 0.000000000000000222
## Asymptotic standard error: 0.028422
## z-value: 16.507, p-value: < 0.000000000000000222
## Wald statistic: 272.47, p-value: < 0.000000000000000222
##
## Log likelihood: -5970.765 for mixed model
## ML residual variance (sigma squared): 41.381, (sigma: 6.4328)
## Number of observations: 1808
## Number of parameters estimated: 5
## AIC: 11952, (AIC for lm: 12294)
## LM test for residual autocorrelation
## test value: 171.12, p-value: < 0.000000000000000222
Modelo SEM
<-errorsarlm(robos ~ totems ,
m.semdata=colonias_shp@data,
listw=Wqueen_row,
zero.policy=T)
summary(m.sem)
##
## Call:errorsarlm(formula = robos ~ totems, data = colonias_shp@data,
## listw = Wqueen_row, zero.policy = T)
##
## Residuals:
## Min 1Q Median 3Q Max
## -24.4841 -2.5884 -1.3620 1.1025 103.2796
##
## Type: error
## Regions with no neighbours included:
## 744
## Coefficients: (asymptotic standard errors)
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 2.568542 0.290823 8.832 < 0.00000000000000022
## totems 0.154596 0.011611 13.315 < 0.00000000000000022
##
## Lambda: 0.46865, LR test value: 344.56, p-value: < 0.000000000000000222
## Asymptotic standard error: 0.028439
## z-value: 16.48, p-value: < 0.000000000000000222
## Wald statistic: 271.58, p-value: < 0.000000000000000222
##
## Log likelihood: -5970.944 for error model
## ML residual variance (sigma squared): 41.394, (sigma: 6.4338)
## Number of observations: 1808
## Number of parameters estimated: 4
## AIC: 11950, (AIC for lm: 12292)
Con cuidado la salida llama lambda lo que en clase llamamos rho
SAC
<-sacsarlm(robos ~ totems ,
m.sacdata=colonias_shp@data,
listw=Wqueen_row,
zero.policy=T)
## Warning in sacsarlm(robos ~ totems, data = colonias_shp@data, listw =
## Wqueen_row, : install the spatialreg package
## Warning: Function can.be.simmed moved to the spatialreg package
## Warning: Function can.be.simmed moved to the spatialreg package
## Warning: Function jacobianSetup moved to the spatialreg package
## Warning: Function jacobianSetup moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
## Warning: Function do_ldet moved to the spatialreg package
summary(m.sac)
## Warning in summary.sarlm(m.sac): install the spatialreg package
## Warning in Wald1.sarlm(object): install the spatialreg package
## Warning in logLik.sarlm(object): install the spatialreg package
## Warning in residuals.sarlm(object): install the spatialreg package
## Warning in LR1.sarlm(object): install the spatialreg package
## Warning in logLik.sarlm(object): install the spatialreg package
## Warning in residuals.sarlm(object): install the spatialreg package
## Warning in print.summary.sarlm(x): install the spatialreg package
##
## Call:sacsarlm(formula = robos ~ totems, data = colonias_shp@data,
## listw = Wqueen_row, zero.policy = T)
##
## Residuals:
## Warning in residuals.sarlm(x): install the spatialreg package
## Min 1Q Median 3Q Max
## -17.4389 -2.3748 -1.0232 1.0486 92.4322
##
## Type: sac
## Coefficients: (asymptotic standard errors)
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 4.121607 0.776956 5.3048 0.0000001128
## totems 0.108801 0.009701 11.2154 < 0.00000000000000022
##
## Rho: -0.73998
## Asymptotic standard error: 0.049777
## z-value: -14.866, p-value: < 0.000000000000000222
## Lambda: 0.82802
## Asymptotic standard error: 0.02091
## z-value: 39.599, p-value: < 0.000000000000000222
##
## LR test value: 449.23, p-value: < 0.000000000000000222
## Warning in logLik.sarlm(x): install the spatialreg package
## Warning in residuals.sarlm(object): install the spatialreg package
##
## Log likelihood: -5918.607 for sac model
## ML residual variance (sigma squared): 31.284, (sigma: 5.5932)
## Number of observations: 1808
## Number of parameters estimated: 5
## Warning in logLik.sarlm(object): install the spatialreg package
## Warning in logLik.sarlm(object): install the spatialreg package
## AIC: 11847, (AIC for lm: 12292)
Impactos totales con 10 simulaciones Pongan mas, quizas 200, y dÃjenlo correr una noche para mejor inferencia
<- impacts(m.sar,
im listw=Wqueen_row,
R=10,
zstats=TRUE)
## Warning in impacts.sarlm(m.sar, listw = Wqueen_row, R = 10, zstats = TRUE):
## install the spatialreg package
## Warning in intImpacts(rho = rho, beta = beta, P = P, n = n, mu = mu, Sigma =
## Sigma, : install the spatialreg package
print(im)
## Warning in print.lagImpact(im): install the spatialreg package
## Impact measures (lag, exact):
## Direct Indirect Total
## totems 0.1640522 0.1246004 0.2886526
Apendice—-
Obtenemos las listas del número de robos y el número de totems?
Robo a transeunte en la ciudad
<- readOGR(".","carpetas-de-investigacion-pgj-de-la-ciudad-de-mexico",
crimen_shp use_iconv = TRUE,
encoding = "UTF-8")
## OGR data source with driver: ESRI Shapefile
## Source: "C:\DAVE2\CIDE\Doc\Econometria II\Lab_12", layer: "carpetas-de-investigacion-pgj-de-la-ciudad-de-mexico"
## with 8254 features
## It has 17 fields
## Warning in readOGR(".", "carpetas-de-investigacion-pgj-de-la-ciudad-de-
## mexico", : Dropping null geometries: 8, 96, 294, 357, 392, 394, 635, 774, 994,
## 1026, 1071, 1117, 1153, 1168, 1411, 1583, 1674, 1801, 1864, 2016, 2240, 2241,
## 2503, 2510, 2628, 2639, 3001, 3006, 3165, 3256, 3308, 3357, 3406, 3510, 3546,
## 3596, 3625, 3676, 3737, 3908, 4057, 4107, 4148, 4152, 4195, 4300, 4402, 4555,
## 4559, 4570, 4581, 4585, 4737, 4829, 4982, 5026, 5152, 5186, 5257, 5461, 5577,
## 5972, 6024, 6122, 6182, 6273, 6361, 6470, 6582, 6668, 6704, 6721, 6819, 6832,
## 6844, 6845, 6869, 6892, 7169, 7528, 7584, 7877, 7891, 7928, 7942, 8065
<- crimen_shp@data
crimen_data
plot(crimen_shp)
Ambos
plot(colonias_shp)
plot(crimen_shp, col="red", add=TRUE)
Ulteriores especificaciones y datos que podemos utilizar:
data(World)
tm_shape(World, projection = "+proj=eck4") +
tm_polygons("HPI", palette="RdYlGn", style="cont", n=8,
title="Happy Planet Index", id="name") +
tm_text("iso_a3", size="AREA", scale=1.5) +
tm_style("grey") +
tm_format("World")
2
tm_shape(World) + tm_fill("darkolivegreen3") + tm_format("World", title="A green World")
Solo bordes
tm_shape(World) + tm_borders()
3
$isNLD <- ifelse(World$name=="Netherlands", "darkorange", "darkolivegreen3")
Worldtm_shape(World) +
tm_fill("isNLD") +
tm_layout("Find the Netherlands!")
4
tm_shape(World, projection = "+proj=eck4") +
tm_polygons("economy", title="Economy", id="name") +
tm_text("iso_a3", size="AREA", scale=1.5) +
tm_format("World")
Cuando no tenemos datos numericos
tm_shape(World, projection = "+proj=eck4") +
tm_polygons("HPI", palette="RdYlGn", style="cont", n=8,
title="Happy Planet Index", id="name") +
tm_text("iso_a3", size="AREA", scale=1.5) +
tm_style("grey") +
tm_format("World")
5
data(NLD_prov, NLD_muni)
# Map coloring algorithm
tm_shape(NLD_prov) +
tm_fill("name", legend.show = FALSE) +
tm_shape(NLD_muni) +
tm_polygons("MAP_COLORS", palette="Greys", alpha = .25) +
tm_shape(NLD_prov) +
tm_borders(lwd=2) +
tm_text("name", shadow=TRUE) +
tm_format("NLD", title="Dutch provinces and\nmunicipalities", bg.color="white")
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()
## old-style crs object detected; please recreate object with a recent sf::st_crs()