Clusters de Acidentes por Affinity Propagation: N=15020 = (20%) | APCluster Parameter: q=0.999 | 3288 Objetos

library(leaflet.extras)
## Loading required package: leaflet
library(apcluster)
## 
## Attaching package: 'apcluster'
## The following object is masked from 'package:stats':
## 
##     heatmap
library(magrittr)
library(dplyr)   
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(leaflet)
library(rgdal)
## Loading required package: sp
## Please note that rgdal will be retired by the end of 2023,
## plan transition to sf/stars/terra functions using GDAL and PROJ
## at your earliest convenience.
## 
## rgdal: version: 1.5-27, (SVN revision 1148)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.2.1, released 2020/12/29
## Path to GDAL shared files: C:/Users/fagne/Documents/R/win-library/4.1/rgdal/gdal
## GDAL binary built with GEOS: TRUE 
## Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721]
## Path to PROJ shared files: C:/Users/fagne/Documents/R/win-library/4.1/rgdal/proj
## PROJ CDN enabled: FALSE
## Linking to sp version:1.4-5
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
## Overwritten PROJ_LIB was C:/Users/fagne/Documents/R/win-library/4.1/rgdal/proj
library(rgeos)
## rgeos version: 0.5-8, (SVN revision 679)
##  GEOS runtime version: 3.9.1-CAPI-1.14.2 
##  Please note that rgeos will be retired by the end of 2023,
## plan transition to sf functions using GEOS at your earliest convenience.
##  GEOS using OverlayNG
##  Linking to sp version: 1.4-5 
##  Polygon checking: TRUE
library(geojsonio)
## Registered S3 method overwritten by 'geojsonsf':
##   method        from   
##   print.geojson geojson
## 
## Attaching package: 'geojsonio'
## The following object is masked from 'package:base':
## 
##     pretty
library(mapview)
library(contoureR)
## Loading required package: geometry
library(geosphere)
## 
## Attaching package: 'geosphere'
## The following object is masked from 'package:geojsonio':
## 
##     centroid
library(cluster)
library(sp)
library(rgdal)
library(RColorBrewer)
library(sp)
library(foreign)

Carga de Dados

dados = read.dbf("/Users/fagne/OneDrive/r-files/CIET/acidentes2020/_Base/acidentes_2014a2020_WGS84.dbf")
dados = dados[dados$ANO > 2014, ]
sort(unique(dados$ANO))
## [1] 2015 2016 2017 2018 2019 2020
anos = length(unique(dados$ANO))
anos
## [1] 6
class(dados)
## [1] "data.frame"
x2 <- cbind(dados$LONGITUDE, dados$LATITUDE)
x2 <- x2[complete.cases(x2), ]
dim(x2)
## [1] 75102     2
head(x2)
##           [,1]      [,2]
## [1,] -51.01213 -30.19741
## [2,] -51.03732 -30.21369
## [3,] -51.05466 -30.23513
## [4,] -51.05470 -30.23517
## [5,] -51.05470 -30.23517
## [6,] -51.05470 -30.23517

Preparação

x1 <- x2
#x2 <- x2[sample(nrow(x2), round(nrow(dados)*0.25, 0)), ]
load("data/AZURE/x2-20000-99920.rda")
load("data/AZURE/apres2-20000-99920.rda")
names(x2) = c("LONGITUDE", "LATITUDE" )
head(x2)
dim(x1)
## [1] 75102     2
dim(x2)
## [1] 15020     2

Treino

#apres <- apcluster(negDistMat(r=2), x2, q=0.999)
plot(apres, x2)
A caption

A caption

summary(apres)
##   Length    Class     Mode 
##     3288 APResult       S4
#save(apres, file = "data/apres2-20000-99920.rda")

Obtenção de Centróides

centroides = unique(apres@exemplars)
poly = data.frame()
centr_indice = 0
for (i in centroides){
  centr_indice = centr_indice + 1
  centr_lat=x2[i,1]
  centr_lon=x2[i,2]
  poly = rbind(poly, c(centr_lat, centr_lon, centr_indice))
}
names(poly) = c("Lat", "Lon", "Cluster")
head(poly)
dim(poly)
## [1] 3288    3
exemplars = poly
#save(exemplars, file = "data/exemplars-20000-99920.rda")

Classificação Global

predict.apcluster <- function(s, exemplars, newdata){
  simMat <- s(rbind(exemplars, newdata), sel=(1:nrow(newdata)) + nrow(exemplars))[1:nrow(exemplars), ]
  unname(apply(simMat, 2, which.max))
}
resultado <- list()

dados$cluster = 0
for(i in seq(from=1, to=length(dados$ID)-1000, by=1000)){
  inicio = i
  final = i+999
  resultado = predict.apcluster(negDistMat(r=2), x2[apres@exemplars, ],  dados[inicio:final, 2:3])
  dados$cluster[inicio:final] = resultado
}
controle = length(dados$cluster)  - final

resultado = predict.apcluster(negDistMat(r=2), x2[apres@exemplars, ],  dados[(final + 1):length(dados$cluster), 2:3])
dados$cluster[(final + 1):length(dados$cluster)] = resultado
head(dados)
tail(dados)
#save(dados, file = "data/acidentes-20000-99920.rda")

Acidentes por Cluster

pal <- colorFactor(
  palette = 'Dark2',
  domain = dados$cluster
)

leaflet(dados) %>%
  addTiles(group="Mapa") %>% 
  addCircles(group="Acidentes", ~LONGITUDE, ~LATITUDE, weight = 0.1, radius=7, color=~pal(cluster),
             stroke = TRUE, fillOpacity = 0.8, popup=~paste("Cluster Nº: ", cluster,  
            "<br>Ano: ", ANO, "<br>Tipo: ", TIPO_ACID, "<br>Local: ", LOG1,  "<br>UPS: ", UPS,   sep = " ")) %>% 
  addLegend(group="Legenda", "topright", colors= "", labels=paste("Classificados em meio a ", summary(apres)[1], "Clusters"), title="Acidentes em Porto Alegre") %>% 
  addLayersControl(overlayGroups = c("Mapa", "Acidentes", "Legenda"),
                   options = layersControlOptions(collapsed = FALSE)) %>% 
  addProviderTiles(providers$CartoDB.DarkMatter)

A caption

Enriquecimento Informacional

rm(apres)
clusters_encontrados = sort(unique(dados$cluster))
#clusters_encontrados
parq = dados
poly = data.frame()
for (i in clusters_encontrados){
  temp = parq[parq$"cluster" == i,  ]
  ch1 = convexHullAM_Indexes(temp[,2],temp[,3], includeColinear=FALSE,zeroBased = FALSE)
  #print(i)
  #print(ch1)
  poligono = temp[ch1, 2:3 ]
  area <- geosphere::areaPolygon(x = poligono)
  acidentes = nrow(temp)
  pol = temp
  coordinates(pol) = ~LONGITUDE+LATITUDE
  centr_lat=gCentroid(pol, byid=FALSE)$x
  centr_lon=gCentroid(pol, byid=FALSE)$y
  if(nrow(temp) >= anos) {
    for (ii in ch1) {
    polying = temp[ii,]
    polying$area = area
    polying$acidentes = acidentes
    polying$centroide_lat = centr_lat
    polying$centroide_lon = centr_lon
    poly = rbind(poly, polying)
    }  
  }
}
head(poly)
tail(poly)
mean(poly$area)
## [1] 13160.01
median(poly$area)
## [1] 6466.954
minimoquantil = quantile(poly$area, probs = 0.01)
maximoquantil = quantile(poly$area, probs = 0.90)
quantile(poly$area, probs = c(0.01, 0.25, 0.5,0.75,0.99))
##         1%        25%        50%        75%        99% 
##   140.3398  2559.9523  6466.9535 12499.3989 91665.3517
poly = poly[(poly$area < maximoquantil) & (poly$area > minimoquantil), ]
dim(poly)
## [1] 15413    48
class(poly)
## [1] "data.frame"
pol = poly

Combinando Informações

dados = poly[,c(1:9, 11:13,38,41,44:48)]
head(dados)
names(dados) = c("ID","lat", "lon", "log1", "Log2", "Pred", "Local", "Tipo", "Via", "Data", "Dia", "Hora", 
                 "Fx_horaria","UPS", "box_id", "Area", "Acidentes", "CentLon", "CentLat")
dados$id = (dados$box_id * 11)
dados$group = dados$id
head(dados)
dadostemp = dados[, c(15:21)]
coordinates(dados)=c("lat","lon")
df = dados
df
## class       : SpatialPointsDataFrame 
## features    : 15413 
## extent      : -51.26617, -51.0838, -30.23911, -29.96328  (xmin, xmax, ymin, ymax)
## crs         : NA 
## variables   : 19
## names       :     ID,               log1,        Log2,  Pred,      Local,         Tipo,                  Via,       Data,         Dia,  Hora, Fx_horaria, UPS, box_id,             Area, Acidentes, ... 
## min values  : 601001, AC A AV A J RENNER,  AC HAMMOND,     0, Cruzamento, ABALROAMENTO, 0 AV ERICO VERISSIMO, 01/01/2015,     DOMINGO, 00:00,          0,   1,      1, 145.254447296262,         6, ... 
## max values  : 683133, VDT LEONEL BRIZOLA, VDT OBIRICI, 90100, Logradouro,   TOMBAMENTO,   VDT LEONEL BRIZOLA, 31/12/2020, TERCA-FEIRA, 23:58,         23,  13,   3288, 23277.2719039803,       298, ...
data <- data.frame(box_id=unique(df$box_id),row.names=unique(df$id))
head(data)
dadostemp2 = dados[!duplicated(dados$id),]
data = as.data.frame(cbind(data, dadostemp2@data))

Criação de Polígonos

points2polygons <- function(df,data) {
  get.grpPoly <- function(group,ID,df) {
    Polygon(coordinates(df[df$id==ID & df$group==group,]))
  }
  get.spPoly  <- function(ID,df) {
    Polygons(lapply(unique(df[df$id==ID,]$group),get.grpPoly,ID,df),ID)
  }
  spPolygons  <- SpatialPolygons(lapply(unique(df$id),get.spPoly,df))
  SpatialPolygonsDataFrame(spPolygons,match.ID=T,data=data)
}

#Criamos o SpatialPolygonsDataFrame
data$Log2 = NULL
spDF <- points2polygons(df,data)
spDF
## class       : SpatialPolygonsDataFrame 
## features    : 2437 
## extent      : -51.26617, -51.0838, -30.23911, -29.96328  (xmin, xmax, ymin, ymax)
## crs         : NA 
## variables   : 19
## names       : box_id,     ID,                   log1,  Pred,      Local,         Tipo,                      Via,       Data,         Dia,  Hora, Fx_horaria, UPS, box_id.1,             Area, Acidentes, ... 
## min values  :      1, 601034,     AC A AV A J RENNER,     0, Cruzamento, ABALROAMENTO, 100 AV CRISTOVAO COLOMBO, 01/01/2017,     DOMINGO, 00:00,          0,   1,        1, 145.254447296262,         6, ... 
## max values  :   3288, 683107, VDT JOSE EDUARDO UTZIG, 90010, Logradouro,   TOMBAMENTO,   VDT JOSE EDUARDO UTZIG, 31/12/2020, TERCA-FEIRA, 23:58,         23,  13,     3288, 23277.2719039803,       298, ...
class(spDF)
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"
spDF@data$group = 1
spDF@data$box_id = NULL
dim(spDF@data)
## [1] 2437   18
dadostemp = unique(dadostemp)
spDF@data = merge(spDF@data, dadostemp, by = "box_id")
dim(spDF@data)
## [1] 2437   24
plot(spDF,col=spDF$box_id+1)
A caption

A caption

library(rgdal)
rgdal::writeOGR(obj = spDF,
                dsn = "data/myParq-99920.json",
                layer = "myParq",
                driver = "GeoJSON",
                overwrite_layer = TRUE)

Acidentes por Cluster

#carregamos os dados SpatialPolygonsDataFrame
parqs <- geojsonio::geojson_read("data/myParq-99920.json", what = "sp")
#Verificamos o objeto
dim(parqs)
## [1] 2437   24
library(raster)
## 
## Attaching package: 'raster'
## The following object is masked from 'package:dplyr':
## 
##     select
## The following object is masked from 'package:magrittr':
## 
##     extract
projection(parqs)
## [1] "+proj=longlat +datum=WGS84 +no_defs"
library(mapview)
mapviewPalette(name = "Viridis")
library(RColorBrewer)
mapview(parqs, zcol = "Acidentes.x", col.regions=brewer.pal(9, "YlOrRd"))

Acidentes por m2

parqs@data$densidade = (parqs@data$Acidentes.x/parqs@data$Area.x)*1000000
mapview(parqs, zcol = "densidade", col.regions=brewer.pal(9, "YlOrRd"))

Acidentes por poligono

hist(parqs@data$Acidentes.x, col = "magenta")
A caption

A caption

Acidentes por KM2

hist(parqs@data$densidade, col = "orange")
A caption

A caption

Locais mais densos

quantile(parqs$densidade, probs = 0.99)
##     99% 
## 84308.2
temp = parqs[parqs$densidade > quantile(parqs$densidade, probs = 0.99), ]
mapview(temp, zcol = "densidade")

Calculando a matriz de vizinhanças

projection(parqs)
## [1] "+proj=longlat +datum=WGS84 +no_defs"
parqstemp = parqs
require(sf)
## Loading required package: sf
## Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
shape <- read_sf(dsn = ".", layer = "mercator_32722_2014_2019")
projection(shape)
## [1] "+proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs"
projection(parqstemp) = projection(shape)

ccods = coordinates(parqs)
temps = as.data.frame(ccods)
cord.dec = SpatialPoints(cbind(temps$V1, temps$V2), proj4string=CRS("+proj=longlat"))
cord.UTM <- spTransform(cord.dec, CRS("+init=epsg:32722"))
ccods = as.data.frame(cord.UTM)
points = cbind(ccods[,1],ccods[,2])
head(points)
##          [,1]    [,2]
## [1,] 482257.6 6674809
## [2,] 487289.8 6678862
## [3,] 486549.9 6678196
## [4,] 476005.9 6671064
## [5,] 485498.8 6678477
## [6,] 479870.1 6673050
library(spdep)
## Loading required package: spData
## To access larger datasets in this package, install the spDataLarge
## package with: `install.packages('spDataLarge',
## repos='https://nowosad.github.io/drat/', type='source')`
distNeighbors = 400
dnb = dnearneigh(points,0,distNeighbors)
class(dnb)
## [1] "nb"
subsets = as.data.frame(matrix(dnb))
class(subsets)
## [1] "data.frame"
subsets = subsets$V1
lengths(subsets)
##    [1]  8  2  5  1  8  7 10 16 18 32  1  1 12  3 22  5 15 17  5 10  4  6 21 11
##   [25]  5 19 11  9  4  7 14 16  5  6  6 13  8  8 11 18 18  3  9 20  3 12 20  3
##   [49]  6 20  6  7  2 13 16 13 10 10 23 21 13 24  5  5 16  5  4 20 19  5 16  9
##   [73]  7 10 20  6 14 18  1  7  1  4  4  2  3  6  9 15  5  3  9  8 21 26 13 10
##   [97] 13  2  8 11 17 11  3  6  7  5 10 15 21  4 13 14  7 10 16 15  3 17 17  7
##  [121] 13  3  8  2 26 30  9 14 17  5  6 17  3  8 12  7  5  3 17  9 13 16 21  9
##  [145] 17 10 10 14  6  4 10  1  1 12  2 15 14  6 17  8 21 12 14 13 16  8  2 16
##  [169] 25 19 18 16  5  7  3 20  7 18 10 17 18  8  7 11 21  1 25 14 11 17  4  2
##  [193]  8 11  5 16  4 12 12 22 18  6 17  5 12 17 16 28  4 18  2 16  8  4 21 13
##  [217] 11 14  4  9 18  8 17  2  9  1  1  7 14  7 17 20  9  5 14  8 21 15  4 17
##  [241]  9 11 20  7  7 11 22 19 12  9  8 22 14 19 18 19  6 25  9 10 11 14  9  5
##  [265]  8 19  9 15  6 22 10  1  5  7  7  3  5  5  2  1  3  6  8 12 10  7 17  3
##  [289]  7 12 14 11  9  9  7  7 10 15  1 12 16  2 19  9 17 17 12  8  3 15 23 17
##  [313] 20  3  7  6  6 15  5  1 20 19 19  1  6 13 12 16 16 21  6 16  9  2  6 21
##  [337]  6 19 18 19 11 15  6  4 14 26  1  4  7  4  8 23  6  9 15 17  4 23 16  6
##  [361] 17  6  7 16  3  9  3 16  6  8  7 11 11 20  9 15  8 10 10  2  3  1 13 17
##  [385] 10  7  4  4 16 10 18 17 19  8 10 10 18  7 19 10 16 16  2  2 16 10 14  9
##  [409]  1  7 17  2 19 13 24 10  9 12  7 13 13  7  7  2  2 13  7 17 10 12 29  8
##  [433]  7 11 16  5  8 11  2  1 16 14 17  9 20  4 19 15 22  5  2  8  9 13  5  8
##  [457] 20  5 10  9  3 17  1 30  9  3  8 16  4  9 16  2  6  2 15  7  9 18  1  4
##  [481] 17 12  6  3  5  1  7 13 11 19 29  9  7 26  4 13 10 17 12 24  7 11  7  8
##  [505] 10 19  3 12  3  7  9 23 15  7  3 20  6  9  6 18 10 10 12  5  7 13 19  6
##  [529]  4 15 11 11 18  1  8  9 21  4 16  9  4 17  8  9 14 17  5  3  8 20 14  3
##  [553]  2  4 12  9 19  1 10 11 18  8 12 17 14  6  7  8  6 21 12 18 10 11  8 20
##  [577] 11  8  4 26 16 13 16 13 15 12  5 11 16  1 14  9 19  3 18 16  7  8  2 11
##  [601] 19 20 12 12 12  4 16 24 11  9 12 12 10 19  2 19 18  7  8  4  1  1  1 14
##  [625]  7  6 14  5  6 10  2 21 12  4  4 13 21  5  4  5  3 16  4 14  3 10 10 14
##  [649]  5 19 10  1 12 15  5 11  8  4 10 24  8 16  4  1  3  3 29 14 21 14  6  2
##  [673]  9  6 11  3  3 13  4 10 15  1 10 23  7 16  6 11 11  3  6 20  1 11 12  6
##  [697]  7  3 10 15 21 15  3  3  1  6 13  8  2  5  4 10 16 19 22 16 14 20  4 17
##  [721]  9  4  2 14 28  1 17  8 12  3  5  9  3 17 20  7  7 10  6 11 15  7  6 11
##  [745]  1  8  8 15  3 18 16 20  3  3 19 11 13  3 10  5 12  4 16 18  7 11 20 10
##  [769]  7 12  9 14  7 18 10  6  2  2 15 18 18 12 21  3 14 18 18 11 19  6 10  7
##  [793] 21 20 22 19  3  1  1  5  7  5 10 16 24 20  3 23  2 17  8  6  6  1 31 23
##  [817]  3  1 11 10  6 12 19 18 19  6  7  7  6 23  2  1 16 14  5 13 16  3 18 15
##  [841] 17 17  7 11  9  2 22 23 16 17 18 23  2 11  3 13 11 15  1  2 18 13  5 22
##  [865] 20  1 14 10 12 10  4  2  4 10 17  9 16 14  3 13 17 19 15  3  8 16 17  9
##  [889]  4 15 10 11  7 13 16 25 10 30  7 22  3 14  7 24 15  1  9  7 22  4 18  9
##  [913]  5 15 16  2  3 28  9 10 20 17 13  6  2 16  6  3 24 25  9 12 17  5 15 28
##  [937]  1 12 10 10 10  7  6  4 11  7 11  3  4  6  7 20 13  8 10 14  8  5  6 16
##  [961] 10  6  1 15  3 16  8  1 19 21  7  9  9 16  4  2  6  3  7 16  2  7 12 12
##  [985] 15 14  3 20  8  8 19 17  6  3  5  1 20 21 10 15 28 14  2 13  2  3  5  9
## [1009]  2 14 17  2  6 13  3  6 11  7  6 17 10  3 10 16 20 11 12 26 17  7  7  9
## [1033]  6  3 13  7  3 13  9  7 17  1 18 17  2  6 15 16 17 19 11  2 17  9  4  3
## [1057] 14  1 19 15 16 24 16  3  2 11 21 10 18 11 11 19 13 21 19  4  7 21 16 10
## [1081] 11 10 10  8  6  7  7  1 18  3  8 17 16 12  1 16 16 17  3 23  4  2  8  9
## [1105]  8  3  3  2 19  5 23  9  9 10  3 10  5  1  3  2  1  5  6  7 17 10 16  5
## [1129]  9  3 19 15 15 18  4 11  5 16 19  5 19  7 11 23 11  6  4  4  6 16  2 14
## [1153]  2 19 20 14  7  9  5 20 18 12 14 18  7  6  7  5  2  6  6  3  8  5  6 18
## [1177]  5  2 10  3  8  5  3  8 22 11 17  6 12  7  2  1 10 15 11 20  3  3  6  8
## [1201] 13 12 12 15  4  6 11 14 12 12 12  2 18  7  5  9 16 10 27 16  1 16 14 10
## [1225]  9 16  3  6 17  7 20 20 16  3 18 12  3  1 16  1  8  3 14 12  5  6 11 13
## [1249] 17  5 18 11  4 15 16 13  2 18 11 12 14  3  3 11 18  6 10 10 14  3 13  3
## [1273] 16  3 13  5  1  9 15 10  2 11 10 19 23 11  3  9 23 14  6  6 13 16 11 14
## [1297]  8  3 12  5  8 21  6  2  8  6 17  8  3  5  5  4  6 15 16  3 22  5  3 13
## [1321]  4  1  3  4  3  2 15  5  6 15  3  9  7 10  5 13 17 12 17  3  7  3  4  7
## [1345]  2 11  4  4 13 19  6 13  9  9 19  6  7 13 15  9 18  8  1 15  3  7  4  6
## [1369]  7  3  2  7 14 18  8 11 11  7 12  9 16  6 26  8 13 15 19 14  8 12  2  4
## [1393] 17  5 16 15 20  6  7  8  5 10  2 11  8 14  1 14  5  9 23 11  3  1  2 13
## [1417] 14 12 11  9  3  9  8 16  5  2 22 16 10 17  5  8 20  5 20  5 17  9  6  4
## [1441] 15 10  1 19 15  6 11  2 18  4  8 16  1 19 16 14  3 13  4 14 11  8  2 14
## [1465]  2 12 11  5 17 17  4 12 25  1  4 17  3 11  9  8  2 16 13  1  2 12 15  8
## [1489]  3  6  5 16 11  5 15 14 14 11  5  8 17 22  9  7  4 11  5 18  6  2  3 14
## [1513] 22 11  6  8 12  2 16  2 11  5  4  7  3 12 10  1  2  6  2 20 17  6  4 11
## [1537]  8  7  6 11 14 20 25  9  3 18  3  5 12  6 22 14 21  4 15 14 18  3  9 18
## [1561] 21 15 16  3 14  3 15 19  7  8 13  2  1 31  7 15  7  8  2 15 10  8 17 13
## [1585] 16 20 12  9 13  2  3 19 10 15 15  6 19  9 21  9  7  2  8 17 13  8  4 25
## [1609]  2  2 14  3 14 14  8  8 17 10  4  7  8 18 10  1 19  3  3  4  5  2  6  7
## [1633] 14  6  5 15  7 12  7 13  6 22  1 19 17  6  6  5  9 10 17 15  8 19  9 11
## [1657] 11  5 11  7 12 15 13 21 14 13  1 17 17 10 18 14 18 14 24 10  7 14  2 11
## [1681]  6  2  4 13 10 12 11 16  4  4 22  5 21 19 11 16  4  6  8 10  8 12  3 14
## [1705] 10  1 12  3 14  5 31  5  1  1 16  3 17 11  5 22  5 26 22 12 20 11 12  5
## [1729]  1  3 10  8  7  8  6 13  7  2  8 13  6  3 18  4 12  9 16 14 20  6 14 10
## [1753] 13 18 13  1 17  6  4 13 18 13  7 15  2 14  5  9  5 13  7  7 10  8 10 12
## [1777]  8 22  1  7  4  6  4  5 23  9 14 18  6 20  9  3  7 25 28 12 16 14  6  7
## [1801] 12  3  6  3 14  5 17  4 13  3  2 12 14 16 12  3  6 18 20  5 16  1  7 20
## [1825]  2  6 17 10  6  4  8 13  7  4 14  4  6 10 12 15  4  6 14 21 14 23 20  5
## [1849] 14 11  4 13  3  4 21 15 15  1 27 19 19 11 12 12  7  4  6  2 16 15 19 23
## [1873]  2 14  1  7 13 10 21  2 18  7  3  1  9  6 11 11  6 11 13 19  2  2  4  5
## [1897]  3 22 18 13 20 13 12  3  7 10 10  8 21  9  4 15  7  9 13  8 26  3  6  7
## [1921] 10 17  7 19 19  4 16  6 26 11  9 13 18 27  7 18 19 12  2 13  2 12  6 21
## [1945] 14 11 18  7  3 20 24  2 16 22  7 21  1  8 18 15  2 27 16  6 12 18 16 10
## [1969] 16 12  3 11 11  8 11  8  8  5 12  1  1  8 13 22 25  5  8  9 15 17  5 18
## [1993] 10  6  6  8 17 12  7  3  5  9 16  1 22 16  7 14  3 11 16  4  2  6  6 10
## [2017]  6  5  4 10 16  9  2  7 21  7  8 19  3 30  5  1  1  9  8 21  3 15  2 18
## [2041]  5  4  5 10  6 17 10 24  8  3 11 11  2  2  3 19 10  4  9  9 10 11 16  9
## [2065]  5  8 14 17  9 11 18  7  6 19 15  5  2 10 14 17 13 13  5 13  3  9 11 15
## [2089] 11 22  2 12 20  9  9  5  8  6 12 15 12 16 18 13  3  9 12  1  2 16 16  4
## [2113]  1 19  7 29  3  8 14 14  2 11  1 16 15  4  9  8  8  9 17 17  6  5 11  3
## [2137]  4  6  3  5  7 10  6 10 14 14 12  4  6  8  8  8  7  5  5 15 13  4 11  7
## [2161]  8 17  8 12 18  7  7  2 10 10  8  7  6  6  6  4 20 13 15  1 16  4  9  8
## [2185] 10 22 16  8 10 11  5  2 18 11  8  7  2 14  7  3 12 10 19 24 16  5  8  6
## [2209]  4 13  4  3  2 11  9 16  4 19 22  4  8 12  1  6  2  1 20  7 16 10  6 15
## [2233] 17  6 15  4  9  9  6  2  4  6 25  6 19 10  8 19  8 17  2 21  4  1 17  6
## [2257] 19  9 11  2  9 11  3 16  8 12  2  4  8  3 12 14 14  2 16 11 11  5  6 14
## [2281] 17  4 15  4  7  5 17 11  7 17 13  9  2 15  1  3  7  5  6 22 28 10  2 14
## [2305]  2  9  4  2 10  8  8  8  8 24  7 17 15 14 13  4 10  1 19 13 13  1  4  7
## [2329]  3 21 20  6 19 10  4  6  4 12  7 11 17 10  6  6  6 12 10 13  5  9 13  9
## [2353]  6  5  6  4 12  7  5 13  2 13  9 18  4  1  2 14 20  9 10  2 10  9  6  7
## [2377] 18 15 17  2  9  6  9 20 16  4 12  7 19 10 24 16 11 13  7 14  6  9  1 18
## [2401] 15  7 12 19 15 26  8 17  8  8  3  2 13 10 16 16  8  4 12  7  6  8 11 15
## [2425] 22  1  8 13 12  7 12 10  1 16 20 10 11
parqs$n = 1
sub = which(subsets == '0')
sub
##  [1]   11   79  153  186  226  227  299  320  324  382  486  621  622  693  705
## [16]  798  818  859  906 1058 1088 1095 1118 1121 1221 1238 1277 1363 1453 1474
## [31] 1484 1528 1573 1624 1714 1756 1822 1858 1875 1884 1957 1980 2033 2113 2180
## [46] 2326 2366 2399 2426
parqs$n[sub] = 0
length(parqs)
## [1] 2437
parqs = parqs[parqs$n > 0,]
length(parqs)
## [1] 2388
length(dnb)
## [1] 2437
#dim(ccods)
ccods = ccods[-sub, ]
dim(ccods)
## [1] 2388    2
points = cbind(ccods[,1],ccods[,2])
head(points)
##          [,1]    [,2]
## [1,] 482257.6 6674809
## [2,] 487289.8 6678862
## [3,] 486549.9 6678196
## [4,] 476005.9 6671064
## [5,] 485498.8 6678477
## [6,] 479870.1 6673050
#dnb = dnearneigh(points,0,2000)
dnb = dnearneigh(points,0,distNeighbors)
dnb
## Neighbour list object:
## Number of regions: 2388 
## Number of nonzero links: 25276 
## Percentage nonzero weights: 0.4432408 
## Average number of links: 10.58459
length(dnb)
## [1] 2388

Matriz de Vizinhanca

Matriz Binária

W.Bin= nb2mat(neighbours = dnb, style = "B")
#parqs <- parqs[!sub,]

Matriz Normalizada

W.Normal= nb2mat(neighbours = dnb, style = "W")
#head(W.Normal)

KNN

vizinhos_4 <- knearneigh(points, k = 4)
class(vizinhos_4)
## [1] "knn"
head(vizinhos_4$nn)
##      [,1] [,2] [,3] [,4]
## [1,]  888  460  291 1940
## [2,] 1397  220 1381 1586
## [3,] 1307 1485   79 2099
## [4,] 2258   83 1393 1271
## [5,]  672 2123 2006 2240
## [6,] 2202 2183 1166 2091
vizinhanca_4 <- knn2nb(vizinhos_4)
class(vizinhanca_4)
## [1] "nb"

Preparação para Análisis Global e Local

mv_simpl = st_as_sf(parqs)
plot(mv_simpl)
A caption

A caption

class(mv_simpl)
## [1] "sf"         "data.frame"
library(dplyr)
mv_simpl =  mv_simpl %>% dplyr::select(Acidentes.y)
#mv_simpl <- st_simplify(mv_simpl, preserveTopology = FALSE,                  dTolerance = 1)
class(mv_simpl)
## [1] "sf"         "data.frame"
mapview::mapview(mv_simpl)
sf::sf_use_s2(FALSE)#trips and tiks
## Spherical geometry (s2) switched off
mv_simpl = st_as_sf(mv_simpl)
vizinhanca_neig <- poly2nb(mv_simpl)
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
ShapeNEIG = parqs
ShapeNEIG$vizinhos = card(vizinhanca_neig)
ShapeNEIG <- subset(ShapeNEIG, parqs$vizinhos != 0)
#vizinhanca2neig <- poly2nb(ShapeNEIG)

Calculando o Índice de Moran Global

Os índices de autocorrelção espacial global calculados pelos testes de normalidade e permutação.

Pelo teste de Normalidade

moran.test(parqs$Acidentes.y,listw=nb2listw(dnb, style = "W"), randomisation= FALSE)
## 
##  Moran I test under normality
## 
## data:  parqs$Acidentes.y  
## weights: nb2listw(dnb, style = "W")    
## 
## Moran I statistic standard deviate = 13.241, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.1497314058     -0.0004189359      0.0001285973

Pelo teste de Permutação ou Teste de pseudo-significˆancia

 moran.test(parqs$Acidentes.y,listw=nb2listw(dnb, style = "W"), randomisation= TRUE)
## 
##  Moran I test under randomisation
## 
## data:  parqs$Acidentes.y  
## weights: nb2listw(dnb, style = "W")    
## 
## Moran I statistic standard deviate = 13.289, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.1497314058     -0.0004189359      0.0001276711

Por simulação de Monte-Carlo

moran.mc(parqs$Acidentes.y, listw=nb2listw(dnb, style = "W"), nsim=999)
## 
##  Monte-Carlo simulation of Moran I
## 
## data:  parqs$Acidentes.y 
## weights: nb2listw(dnb, style = "W")  
## number of simulations + 1: 1000 
## 
## statistic = 0.14973, observed rank = 1000, p-value = 0.001
## alternative hypothesis: greater

Pelo teste de Permutação

Diferente dos demais testes globais o teste para o EBI é exclusivo para taxas e tem-se apenas a opção de teste da permutação

EBImoran.mc(parqs$Acidentes.y,parqs$Area.y,
            nb2listw(dnb, style="B", zero.policy=TRUE), nsim=999, zero.policy=TRUE)
## The default for subtract_mean_in_numerator set TRUE from February 2016
## 
##  Monte-Carlo simulation of Empirical Bayes Index (mean subtracted)
## 
## data:  cases: parqs$Acidentes.y, risk population: parqs$Area.y
## weights: nb2listw(dnb, style = "B", zero.policy = TRUE)
## number of simulations + 1: 1000
## 
## statistic = 0.066985, observed rank = 1000, p-value = 0.001
## alternative hypothesis: greater

Por simulação de Monte-Carlo

shapeCG.p=parqs$Acidentes.y/parqs$Area.y
moran.mc(shapeCG.p, nb2listw(dnb, style="B", zero.policy=TRUE),
         nsim=999, zero.policy=TRUE)
## 
##  Monte-Carlo simulation of Moran I
## 
## data:  shapeCG.p 
## weights: nb2listw(dnb, style = "B", zero.policy = TRUE)  
## number of simulations + 1: 1000 
## 
## statistic = 0.060119, observed rank = 1000, p-value = 0.001
## alternative hypothesis: greater

Calculando a Estatística C de Geary Global

Pelo teste de Normalidade

geary.test(parqs$Acidentes.y, listw=nb2listw(dnb, style = "W"), randomisation= FALSE)
## 
##  Geary C test under normality
## 
## data:  parqs$Acidentes.y 
## weights: nb2listw(dnb, style = "W") 
## 
## Geary C statistic standard deviate = 11.254, p-value < 2.2e-16
## alternative hypothesis: Expectation greater than statistic
## sample estimates:
## Geary C statistic       Expectation          Variance 
##      0.8669210216      1.0000000000      0.0001398407

Pelo teste de Permutação

geary.test(parqs$Acidentes.y, listw=nb2listw(dnb, style = "W"), randomisation=TRUE)
## 
##  Geary C test under randomisation
## 
## data:  parqs$Acidentes.y 
## weights: nb2listw(dnb, style = "W") 
## 
## Geary C statistic standard deviate = 8.6543, p-value < 2.2e-16
## alternative hypothesis: Expectation greater than statistic
## sample estimates:
## Geary C statistic       Expectation          Variance 
##      0.8669210216      1.0000000000      0.0002364576

Por simulação de Monte-Carlo

geary.mc(parqs$Acidentes.y, listw=nb2listw(dnb, style = "W"),nsim=999)
## 
##  Monte-Carlo simulation of Geary C
## 
## data:  parqs$Acidentes.y 
## weights: nb2listw(dnb, style = "W") 
## number of simulations + 1: 1000 
## 
## statistic = 0.86692, observed rank = 1, p-value = 0.001
## alternative hypothesis: greater

Calculando Índice de Getis e Ord Global

Getis-Ord é um indicador que mede a concentração local de uma variável de atributo distribuída espacialmente

globalG.test(parqs$Acidentes.y, nb2listw(dnb, style="B"))
## 
##  Getis-Ord global G statistic
## 
## data:  parqs$Acidentes.y 
## weights: nb2listw(dnb, style = "B") 
## 
## standard deviate = 19.082, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Global G statistic        Expectation           Variance 
##       6.186941e-03       4.434265e-03       8.435933e-09

Getis e Ord Local

localG(parqs$Acidentes.y, nb2listw(dnb, style="B"), zero.policy=NULL, spChk=NULL, return_internals=FALSE)
##    [1]  1.1042211534 -0.7355520638 -1.4525267470 -0.7784881164 -0.5266815131
##    [6] -1.6386277697 -0.1329568406  0.7556649900  1.9619003713  4.5420997886
##   [11] -0.8212818186 -1.0426857379 -1.1992231068  0.6856012866 -0.2187766810
##   [16]  0.7014415163 -0.0547493113 -0.8938568347 -1.1295124768 -0.8246426444
##   [21] -0.4658150316  0.3821048629  1.3032901371 -1.4530893264  7.3853864908
##   [26] -0.6604982072 -0.4128174534  0.5965412559 -0.2031396628  0.9968116831
##   [31]  0.7482779165 -0.4099226984 -0.3070822843  0.3624593420 -0.2155527170
##   [36]  0.8910613070 -0.2525144367 -2.0262851020  0.5773179087  0.4252899843
##   [41] -0.6027047382 -0.4981395561  3.7290630078 -1.2246293780 -1.2696015280
##   [46]  0.4399377321 -0.6765837787 -0.6751389234  0.3249667874 -0.3062686319
##   [51] -0.7585690941 -0.8572373870  2.6946031383  1.5434976370 -0.8841789285
##   [56] -1.4568925540  0.8795689333  3.1120334799  2.7687783963  1.0176937870
##   [61]  1.8759241379 -1.0083379763 -1.0477500596  7.8485822204  0.3411503763
##   [66] -1.0178426878 -0.6912932725  4.1119587598 -0.3927408397  1.8009156970
##   [71] -0.4101081820  0.3987138633 -0.5552756309  1.8327146817  0.8731793654
##   [76]  0.1282616893 -0.0543377580  1.5239303007 -0.3908891700  2.2987996886
##   [81] -0.9544397634 -0.4304522347  0.4674668964 -0.2182408193 -0.4102446058
##   [86]  0.2787706782 -0.0266627740 -0.9005681987 -0.2255963033 -1.1202694489
##   [91]  0.8353431569  2.6723315274  3.2518463403 -0.0751288439  0.4309711994
##   [96] -0.6133989668 -0.8172780759 -0.4922543672  2.5042712636  1.2510280314
##  [101] -1.4231831867 -1.5388761591  2.0456487638 -0.7393421828 -0.2290570173
##  [106]  3.4473934087  0.5429216214  0.2740594929  0.8502195676 -0.9474090861
##  [111]  0.5486059674 -0.8412022990  2.1790872090  0.4680409342 -1.0753867579
##  [116]  1.8850838779  1.0769878654  0.4810575503  0.9476437541 -0.7018853851
##  [121] -1.8233598667 -0.7356570374  0.6304683024  3.3938574256  0.6962730592
##  [126]  0.2072749879  0.4339449164 -1.4146013515  2.5257424759  1.4988120849
##  [131] -0.4533188533  0.5405156689  0.4875734282 -0.3987270941 -1.4143603943
##  [136] -0.5278609829 -0.4528519293 -0.5982836982  0.7819969609 -0.1856697449
##  [141]  2.5189111126 -0.3948423587  0.9949036664  0.3167196849 -0.2818180757
##  [146]  2.2134215769 -0.2371179251  0.5321973021 -0.9360494045 -0.9504114505
##  [151]  0.1006761025  0.6348636905  1.1878168774 -0.3350917436 -1.1324494848
##  [156]  0.2689341191  0.6471312543  0.3543757841 -1.2799431817  0.7266239975
##  [161] -0.3233165349 -0.8764154719 -0.8619894156 -0.7659734285 -0.8645353974
##  [166]  0.4929680744  1.2456533289  0.8009832116  1.8777142732 -0.9518335791
##  [171] -1.3609939001 -0.6016012964  0.6342165441  0.6757147201  1.5705103420
##  [176]  1.2318634257  2.7246988082  0.4555398225  2.4301762611  1.1481952676
##  [181]  1.3198594147  2.3004508312  5.3886220469  2.3191423944 -0.9214728294
##  [186]  1.3140487681 -0.6313211979 -0.9482493135 -0.4206957590 -0.4650551936
##  [191] -1.7025403057  0.6509402694 -0.9110878816 -1.1441182891  2.5211919708
##  [196]  0.4097044395  2.1256413597 -0.2883753326 -1.0402106644 -0.4689604736
##  [201]  2.2814721976  2.8552391731  4.4471007519  3.8557698941 -1.4061825465
##  [206]  1.3465161242  1.0007889536  6.0486268844  0.1756225430 -1.6442615176
##  [211]  0.9772979869 -1.0299291822  4.2597624456  1.1996338132 -0.2653059647
##  [216]  0.9563563725  0.9338811110  1.6684372782  1.3497107159 -0.8878661026
##  [221]  2.0320749512  1.2627959033 -0.9227615447  0.2723878443  1.9905499021
##  [226]  9.0436891820 -0.5276651300 -0.2770123155  0.9114427989 -1.0463028776
##  [231]  2.3832135966  0.7349588460 -0.6520259352  0.0073754615 -0.5261910295
##  [236] -0.3865923799  0.8952957495  0.4973037123 -0.0900337292  0.6671782155
##  [241]  5.4658366853  1.4045248300 -1.4182680495 -0.2256535971 -0.7717190002
##  [246]  7.6724849993 -1.3624526956  1.2360337539 -0.6021144607  1.4339832181
##  [251]  0.1154837931  4.3075258682  0.8958325910  0.3331318438 -0.1277662449
##  [256]  0.0816221527  0.1915840404  1.3033184512 -0.2531466320  4.3410413233
##  [261]  0.2368774620  0.1432289877  0.0621263764  2.2105955889 -0.6366772146
##  [266] -0.7353674609  1.3036559061 -0.8071671660  1.5563715275 -0.5768526027
##  [271] -0.0641565665  0.3010383831 -0.3088158187 -0.9077775344 -0.8267386597
##  [276] -1.8725962378  0.8750750647 -0.6948440300  0.4269947807  0.4803663512
##  [281] -0.2233243627 -0.6010194449 -0.1880091738  3.1037184244  1.3034372559
##  [286] -0.6227053164  0.1347149292  0.1772588315 -1.6382106071 -0.2532471318
##  [291]  5.1762170396  1.6046342390 -0.3809251883  0.3660758486 -1.1621808748
##  [296]  0.9573295062 -0.2806754876 -0.4319717151  3.5214985911 -0.4347612667
##  [301] -0.0096077744 -0.5777156044  0.3559799250 -0.3759263927  0.7427408742
##  [306]  0.0332733393  0.7652918437 -0.9202573754 -0.3948812694 -1.7330501456
##  [311]  1.4071450161 -0.2578682869  0.8564674844  0.3061603569  3.6548151452
##  [316] -1.4867225334 -0.5506010232  1.7215251313  2.0278038975  3.4644146652
##  [321]  4.3369217815 -0.2159158303  3.2879236710 -0.1097984109  0.0562675430
##  [326]  0.3448623674  0.0519377421 -1.3979817989  1.5633261196  2.1218489613
##  [331]  2.1304677816 -0.1670447334 -0.5918003926 -0.5880791353 -1.3639906108
##  [336] -0.4392377738  3.8289184134 -0.5197837726 -0.6091815381  0.2368290211
##  [341] -1.1055532228 -0.9695052619  3.2865923953 -1.4679622547 -0.5277273710
##  [346] -0.2314182886  0.0081210893 -1.7301992352  5.6139646905  0.3437632876
##  [351] -0.4658667183  0.3119216585  0.1329943819  0.3996811292  0.3561722990
##  [356] -0.4035397584 -0.1822358331 -0.2534404782 -1.0930430509  1.2067039621
##  [361] -0.7106096509 -1.3610539246 -1.1303206250  4.9087116114  1.2227714738
##  [366]  0.5937886261 -1.4835344960 -1.2120512402  0.5896080359 -0.5809317839
##  [371] -0.8573390606 -0.8762648714  0.5179375106  0.4890190224 -1.7954779191
##  [376] -0.6764721959 -0.9110464223 -0.3083983257 -1.3197432865 -1.2655047606
##  [381]  1.0029985692 -1.4061466342  3.1700586887  1.5001360395 -0.5150746214
##  [386] -0.1735344022  2.0331661850 -0.3337339412  0.6698802263 -0.0242181082
##  [391]  0.9051651506  1.1538673899 -0.4309965085 -1.1011378232  2.9893490899
##  [396] -0.8281715966  0.6605488879  0.2798996425 -0.0461976966 -0.1879589625
##  [401]  2.4717984607 -0.6137962085  0.2954918725  1.1404167164  4.0832210425
##  [406]  0.4267149455 -0.1641657933 -0.2229551649  0.7735326131  1.3768242283
##  [411]  1.0218378824 -1.7039686985 -1.0012513135 -1.1315535848 -1.1922348877
##  [416]  0.3987798114 -0.3815308378 -0.2534622671 -0.9246359701 -1.6057715212
##  [421]  5.0841947584 -0.2528797666  0.6439574158 -0.1535425209  0.6136631979
##  [426]  1.4575336033 -0.7864936305 -1.0357257800 -0.0655298421 -0.8215825722
##  [431]  1.5323106885 -1.3263739390 -0.7149667940  0.3363175497 -0.0305999160
##  [436] -0.0707647876  0.9571363723  1.6931350679  1.0633114964 -1.3181053953
##  [441] -0.0351002292  0.4483935489 -0.0950963548  0.9346664982  0.5515361367
##  [446] -0.5875169900  9.6312072550 -1.5298886745  0.6450417954  1.1692667865
##  [451] -0.0294070976  2.5178829311 -0.3478958703  6.0022405109 -0.7267366486
##  [456] -1.4733134065  0.6314415288 -0.3040862383 -1.3848635546  5.1375084872
##  [461]  2.8812208427 -1.0096520636 -0.7285942398 -0.3391917405  1.0471717779
##  [466] -0.7094459188 -0.0378601993  3.2060076718 -0.7784881164  0.1021957134
##  [471]  6.6137449946  0.6737245891  0.0099890725 -1.1746453271 -0.6619564052
##  [476]  0.9364615560  1.3296948665  0.4716500204  1.7010951394  3.4972423369
##  [481] -0.2109912080 -0.1705025880  4.2911738430 -1.4498037550 -0.2388238630
##  [486] -0.1306486336  2.3127769469 -0.2981739608  4.6673141992 -0.7088058754
##  [491]  0.2117591830 -0.4979228627 -0.5561014238  0.0352110222  1.0491313084
##  [496] -0.8262396704  1.3614984147  0.4423770361  0.5134075371  1.4281054207
##  [501] -0.7712558215  2.3194723814 -0.4149764365  0.0690498556  2.0154451283
##  [506]  0.8365162487  0.3505289950 -0.0248065387  0.8836231369  2.2005482315
##  [511] -0.1585932830 -0.2971942691 -0.4313334800  0.0408566125 -0.2141568275
##  [516]  3.4439874726  0.6254950660 -0.4156375395  1.4480866377  0.1319763506
##  [521] -0.8158281722  2.4819486659 -0.8646471454  0.0058958121 -0.7124840234
##  [526]  3.3955238643 -1.5143856845 -1.2218164537  0.8688708214 -1.6872290266
##  [531]  1.8575563459 -0.0545774527  0.9400886068 -0.4153788929 -0.7042553170
##  [536]  0.2447713170 -0.5528060139 -1.0455622004  0.3545420646 -0.0466669025
##  [541] -1.5478275834  2.0054522806 -1.0194754810 -0.0978573498 -1.6636670728
##  [546]  0.2043380289 -0.8644700840  0.3447522467  0.7052326550  3.7680689903
##  [551] -0.0536085428 -1.0430533551 -0.7790892303 -0.3691532199 -0.6947196127
##  [556]  0.5954249340  0.7083246012 -0.8700082751 -0.5342105682  2.0403758001
##  [561]  3.1349739827 -1.1275411747  0.2492512201 -0.1598922969  0.7528092635
##  [566] -0.7259845315 -0.8149871807 -0.7820424454  4.2896252187  1.1667348464
##  [571] -0.2753525336  0.3329645593  0.4920103542  0.8833538866  0.7697409381
##  [576]  0.8794851638 -0.9327747399  0.0737231874 -0.9077117186 -1.0268882218
##  [581]  1.4997407150  0.2371546726 -0.5026817603  1.4128771488 -0.8856194521
##  [586]  1.1816385633 -0.8779133496 -0.8570234815 -0.3610358271  1.5251348873
##  [591] -0.2180973224  2.4218481391  0.2874572167  0.9103722286 -0.9969101270
##  [596] -0.2600918750  2.0785798670  0.6801884305  0.0058665153  0.6127169519
##  [601] -0.8833630991  2.3659902067  0.6739644053  2.0663702257  1.4371143454
##  [606]  0.4793255084 -1.1970621667  1.0751452358 -1.3847469607 -0.8646790113
##  [611] -0.8655515298 -0.0086020394 -1.3101056675 -0.9664794476 -0.8739507133
##  [616] -0.6066648769  0.9329448993 -1.0096151141  1.9198099673  0.7614893912
##  [621] -0.7165002850 -1.1056616480 -0.0707500930 -0.6002673765 -0.1994233694
##  [626]  0.4890163485  2.0744003578 -0.5774955476 10.2681136255 -1.5143383224
##  [631]  0.7379205805  1.3127215847  1.2716415480 -0.1328984920  2.2958281212
##  [636] -1.4717995727  8.3850066280 -0.6917527435 -0.6493242793 -0.5972196685
##  [641]  5.7433092011  1.0918970060 -0.2955201365 -1.1070308298 -1.4071949273
##  [646]  1.1087143555 -0.6594630789  0.0823834007  0.1065508773 -0.3072378141
##  [651] -0.7783477930  0.1941232480 -1.0256868783  2.8412861423  1.2973087076
##  [656] -0.5889431174  1.3609299475 -0.4467949634 -1.1316791392  0.1062330722
##  [661]  0.6260525916 -0.8036051529 -0.8763520065 -1.1244309685  1.0318284975
##  [666] -0.5015055388  0.1539308181  0.2157189438 -0.6923602800  0.0719653651
##  [671] -0.7975398284 -0.7083779363  0.6886062483 -1.0809751487 -0.6218405541
##  [676] -0.2714522906 -0.9010525375 -0.5705273206 -0.2759357443  2.2418222849
##  [681]  2.1327245708  0.5061217736 -0.6770240889 -0.8266490578 -0.5152647902
##  [686]  0.4782314251  5.0440740122 -1.1803357980 -1.4484400149 -0.9755441118
##  [691]  0.0816296000  0.3956582640  2.1710194069 -0.8264889194  0.7250695415
##  [696] -0.3292022504  0.1124980722  0.5949051344  0.0023431626  4.0757324111
##  [701]  0.0528477566  1.6723115152 -0.0165131754 -0.3938666364  0.9627100111
##  [706] -0.9289496667 -1.3421344743 -1.0398959887  0.6804034132  5.3045681588
##  [711] -0.7354832260  2.2395142200  3.0562367353 -1.6315068637 -1.4235666232
##  [716]  0.8044026935 -0.1539872716 -0.9759385428  1.7083234355  0.1513751067
##  [721]  0.1550159421  0.2042877141 -0.6644689728 -0.3073220488 -0.3855695528
##  [726]  0.8344597547 -0.3649572652 -0.9742196273  2.1375693389 -0.9077442731
##  [731] -0.7391004723 -0.7413473269 -0.4695845518 -1.0752464157  1.0351352023
##  [736]  0.0314681628  3.5185147743 -0.4535425077 -1.1741709051  9.8237981698
##  [741] -0.6600872651  1.2100916412 -1.2739150973  0.3724844006 -1.1061977300
##  [746]  1.0101990705 -1.1694375272  0.4410917633  0.9036149849 -0.6438814897
##  [751]  0.0936483474  1.1074855098 -1.6880707475 -0.9189442245 -1.1070670671
##  [756] -0.3115777666  3.1635395276 -0.0740790131  1.7077818811 -0.1038528559
##  [761] -0.3073707220 -0.3699971385  0.6043748118 -0.5930178672 -0.2578933580
##  [766]  1.7585313002 -0.5792986620  4.8073334932 -0.6269355379  0.6587391698
##  [771]  2.8896065788  0.1189702623 -0.1917310694  0.9977580891 -0.7120443236
##  [776] -0.9787325532  0.9528300151  0.6859434849  0.1930871028  1.0489625262
##  [781] -1.1928273721 -1.0501994833 -0.4770659864 -0.2387685373 -0.4954802018
##  [786] -0.4892952316  0.3330680935  0.6055366991  2.4580795539  2.1139043117
##  [791] -1.0754352137  2.6097939818 -1.2840604112  1.5699795175  0.2349464161
##  [796] -0.7997714941 -0.1289108371 -0.2617431203  5.8426079929  1.6990914273
##  [801]  0.8154265610 -0.6487991572  0.2354485992 -0.1127465719 -0.9700224484
##  [806]  0.7403285346  4.6547792973  2.8812847000 -0.5361605917 -0.0730639503
##  [811] -0.0088894816 -1.3811221440  2.6007459317 -0.4610804141 -0.7784881164
##  [816]  0.5166820309  0.3570987372  0.4357869694  0.5396419684  2.0732561231
##  [821] -1.4482381166  2.9512149145 -1.4392275000  1.4432751760 -1.2280160855
##  [826] -1.2960552718  1.6595300013 -0.1375351157 -1.2228812671  1.1846598343
##  [831]  1.9252016116 -0.8984892831  0.1664951067  1.6489236883  3.7642317140
##  [836] -1.0403483870 -0.8951810407 -0.9007770289 -0.0102371580  2.4612439678
##  [841]  1.2491750802 -1.1311610039  1.6074347058 -0.6103953781 -0.1031838051
##  [846]  8.2277525709  1.7277062862 -0.8215825722  0.5539174825 -1.4434101795
##  [851]  0.6861326227 -0.0919131292 -0.9975280055 -0.2482631753 -0.0059564437
##  [856]  0.1295431529  1.4329937796 -0.9584424735  3.3139088047 -0.9695515420
##  [861] -0.0055013877 -0.1657532304  2.3339250170  2.1626267473  1.4818012830
##  [866] -1.0504657481 -0.4953963444  1.8778617521  3.2458331308 -1.3901003967
##  [871] -0.2424391498 -0.1448773185 -1.8110724091  0.2371129704  0.1380165053
##  [876] -0.8479757663  2.5946135042  1.9940498570  0.0302435705  4.9917951592
##  [881] -0.5619566829  1.5155128477 -0.4775352582 -0.3118023073  0.9691631013
##  [886]  0.5768142424 -0.6033188389  4.1041260420 -0.0709717741  0.5212938727
##  [891] -0.6737028782  0.6389492224 -0.4970857778 -0.0628270316 -0.3320959795
##  [896]  3.2827895467 -0.7356214735  0.0692654357  2.8377411043 -0.0243537944
##  [901]  0.3175231700  2.5390552964  1.3599732410 -0.0697128546  1.4717632623
##  [906] -0.9488156873 -0.9416859702 -1.1865566077 -1.1738052433  0.4714575614
##  [911]  2.6857554064  0.9827858366  0.3530430731  0.9674449938  0.5521526891
##  [916] -0.1563052362  4.2084637682 -0.1754718663 -1.2825327485 -0.1683950833
##  [921] -0.9913175831  0.0591808367 -0.4319409082 -0.4299820043 -0.8028259982
##  [926] -2.0392948620  0.0732561159 -0.5042021873 -0.7515539900 -0.6300224247
##  [931] -0.9932409695  0.7410578762 -0.4882792830  0.0608794610 -0.7564716509
##  [936] -0.6232561841 -1.5127366139 -0.1611951735 -0.8363445612 -1.6094506972
##  [941]  0.1934459615  0.1948004248 -0.5157139519 -0.8214642590 -1.4292457835
##  [946] -1.5479335815  0.9476340693 -0.4501590155 -0.5630420657  7.3845230432
##  [951]  2.2516849701  1.6711011897  0.9251279245 -1.5770877148  8.9827529029
##  [956] -0.7176346903 -0.9487046927 -0.1132346396 -1.0248226614 -0.5286545764
##  [961] -1.3391992901 -0.4918765323  0.8243715550  1.5584416218  0.4387514570
##  [966]  3.1659286356  0.7516625989  0.0439328925  0.8264779825 -0.0194888654
##  [971]  1.5154149749  3.5970347536  1.8418411079 -1.0809270788 -1.0253700269
##  [976] -0.8352498288 -0.9506211783  0.3435008980  2.8269751548  1.0810538931
##  [981] -0.8371082395  5.0827527048  0.3026838667 -0.2788953380 -1.3886507392
##  [986] -0.5529166446 -1.0754845072 -1.3563171495  0.2215800285 -0.5218595468
##  [991]  1.6496352808  1.0279561343 -0.0044909225  1.6113147976  2.0234695030
##  [996] -1.2990056860 -0.6066648769  0.1469533953  0.1063713766  0.7133840810
## [1001]  5.4354023622  0.8352507093 -1.4733670781 -1.3068088769 -1.3400825282
## [1006]  0.5186273373 -0.8029226351 -0.8449907919  3.6274636513  1.8942995366
## [1011] -1.1172436973 -0.3832574115 -1.3758651827 -1.4159933804 -0.9260541631
## [1016] -0.8130954077  0.8068572930 -0.3026998290  7.1961070912 -0.6566388946
## [1021] -1.1497724589  3.1830179440 -0.7784881164  1.7895239677 -0.6489239089
## [1026] -0.3695219661  0.9808346868  2.5969276449 -0.2805724188  4.3571980889
## [1031]  1.1462118344 -1.0123397142 -1.1315134950 -0.4117965995 -0.4700284402
## [1036] -0.5882756889 -0.4535425077  0.7848339477  3.1694483490  0.9505822789
## [1041] -0.3799771362  0.0576987433 -0.5844792302  0.2181906925 -1.0397710752
## [1046]  1.9051494802  2.4026829245  0.8237965820  1.5243768500 -1.3512829619
## [1051] -0.3225496628  4.7459888153  0.5750661366 -0.7097061404 -0.9640375626
## [1056] -1.1475734804 -0.5297118007  1.0266687978  1.3923968670  0.6444225010
## [1061]  2.9946122052  2.4514297678  0.2628437619 -1.0758867807 -1.8903325823
## [1066] -0.4134772666  1.1481667240  4.5767092135 -0.6026652481  0.4947266168
## [1071]  2.6289782349  4.1016756663  0.0138318126  1.2535161424  1.7146520918
## [1076]  0.3742915130  3.2043120038  3.2076274489 -1.1916290320 -0.8880180592
## [1081]  0.3739103120  0.1210495130 -1.1965725024 -1.0498210635 -1.0751570400
## [1086] -1.2221585547  3.6557567251 -0.9897956988  4.9486776897  0.2775457021
## [1091]  0.4542797708 -0.5817904436 -0.7517411487  0.1675727897 -0.7591917326
## [1096] -1.0503289367  2.6145834982 -1.7610564622 -0.2536966944 -1.5409895315
## [1101]  2.2933063407  3.2512989950 -0.9509251492 -0.8353267633  1.4280260095
## [1106] -0.8515677043 -0.2103249740  1.3538866482  0.8462701607  0.0603254740
## [1111] -1.5360276253  2.0208079001  0.6501600177  2.9247145322  1.8218738951
## [1116]  0.2044436068  0.5310476585 -0.6765783581 -1.5589912492  1.4643291027
## [1121] -1.2057922962  0.6611189250 -1.0407623344 -0.2428167056 -0.0784901724
## [1126]  0.0946783165 -0.4310583110 -0.5532423596 -0.4002817015  1.4038344995
## [1131]  1.4161203197  1.1651886845 -0.7407503643 -0.1539304741 -0.2385943766
## [1136] -1.0481854340  1.8405870964  0.6007178674  4.4076030682 -1.0622989476
## [1141] -0.9364208027 -1.2040108035 -0.4968737501 -0.6436941320 -1.1314742857
## [1146]  1.8418652647  0.2401268472 -1.1000736821  0.3114238635 -1.0864408017
## [1151] -0.4471295670 -0.9583410635  0.3788652961 -0.2783114057 -0.8151523325
## [1156] -0.8762648714 -0.8625556704 -1.3558389506 -1.6475410708 -0.9987283083
## [1161]  1.8656078771  1.0950711038 -0.7984071151  0.3278326493 -1.4556434980
## [1166] -1.7195605270 -1.2227631769  0.1690300532  0.7678739644 -1.5510454256
## [1171]  1.7538917220 -0.3993919479 -0.6517438443 -1.1746453271 -0.3418594899
## [1176]  0.2040148801  7.5141372630 -0.5212572851  1.9330035598  0.9822085162
## [1181] -0.7169672499 -0.3953168825  0.3660799690  1.8591983275  0.3849019071
## [1186]  1.1985362333 -0.7205300600 -1.1010575709  0.8214228754 -0.3667106547
## [1191] -0.2185354140  1.7733716581 -0.6169482631 -0.6094477506  2.6080242115
## [1196]  0.4553232817 -0.2052496951 -0.6119722602 -0.6246103445  1.1990491579
## [1201] -0.0017960181 -0.9007404733 -1.1872703857  1.4853142538 -0.4777145618
## [1206]  0.0721056240  0.2956440178  0.7982382071 -1.4230180376  5.4967541650
## [1211] -1.1318518477 -0.8017318314  0.5399964660 -0.8215825722 -0.4052870746
## [1216] -0.6026262274 -1.0398211956 -1.1568347340 -0.4117082546 -0.5346272731
## [1221] -0.8042426095  1.1388480052 -0.9777661056 -0.3544181363 -0.4513381070
## [1226]  1.0957556917 -0.9322476494  2.3513770658 -0.3045348348  1.7854277306
## [1231] -0.7356570374  3.8907638350  1.2248837881  2.4680856476  0.3576178187
## [1236] -0.5779113577 -0.7768159670  0.4186169103  0.7930144939 -1.3281255251
## [1241]  1.0262693523 -0.2406708691  0.4490488248 -0.4287453038 -0.2627689459
## [1246]  0.8398585182  1.9848381284 -1.1492347272  0.9891988555 -0.9896247793
## [1251] -0.3954170045  1.6491194528  1.6958591883 -0.3397499419  1.1371842094
## [1256] -0.6623831856  4.0318773844  0.9497868515  0.8215992533 -1.0250557843
## [1261]  0.9122023349  5.1476333604 -0.2064031775  0.6091077399 -0.2362335188
## [1266]  3.5700576719 -0.2602354542 -1.2468845091  1.2111177826 -0.8322319617
## [1271]  1.0637574629 -0.3578106750  1.9780105678 -0.1763892266  1.3833895690
## [1276] -1.1869773850 -1.2840133627  4.7326987262 -0.5882616733 -0.4217246354
## [1281]  1.8660994919 -1.2743769180  0.9381246152  0.5715465883 -0.1786628609
## [1286] -0.2540112461 -1.1594503902  2.6460379841 -1.0506099224 -0.1439653673
## [1291] -1.6249246580 -0.9505556291  1.4978789978 -0.8460093216 -0.1324501507
## [1296] -0.9759861682 -1.1915252086 -0.6262864907 -0.8874212811  1.2940258476
## [1301] -0.3727533935 -1.0272851537  1.5373899994 -1.0745933299  2.6793469104
## [1306] -0.7417607906 -0.4881706381 -0.4123365496  0.8153262713  0.3551108356
## [1311]  1.6605480247 -0.8313138897 -1.1249011835 -0.4324593325 -0.7271968658
## [1316] -1.7299207763  0.2686582852 -1.3143349482  0.2260349028 -1.2991457005
## [1321] -1.0410220227 -0.3588900382  0.5563736936 -0.6241034501  2.6295628136
## [1326]  0.0904634558  0.6232106634  1.1277677485 -0.7471346415 -0.6589867148
## [1331]  2.6103845009 -0.8490257226 -0.4986642815  3.2664635490 -0.5584936260
## [1336]  0.5564182945 -0.9010947002 -0.1553163582 -1.0191197681 -1.1518952391
## [1341] -0.2026805901 -0.6522931745 -0.8879790329  2.1425064657 -0.5749885826
## [1346]  3.6236878170 -1.0614842321  1.2647684161  0.6005533367 -1.6052488475
## [1351] -1.3195928729 -0.7427232471 -0.1531251398 -0.0759653244  3.1758276024
## [1356] -0.4040903728 -0.7170563733  0.9028301796  1.4727831625  0.6809149410
## [1361] -0.1467373378 -1.1574677906 -1.2535096792 -0.7602868176  0.9924924280
## [1366]  0.7057953980  0.4010494400  2.1177988296  1.5722091185 -0.7994722831
## [1371] -1.7363378634 -0.5238831251 -0.1423938715  0.6036927082  0.6045498072
## [1376] -0.0892234483 -1.4726938397 -0.3463509708 -0.9076182954  2.2958281212
## [1381] -1.4917664828 -0.5421063545  1.8341486084 -1.0645188545  0.2928630223
## [1386] -0.9077117186 -0.3394298541  1.2220030925  0.4278761443 -0.4947258306
## [1391]  1.1084319116  0.2212476287  0.0938605303 -0.2385981685  0.2039190366
## [1396] -1.5897254282 -1.7801125597 -1.0402243589  4.2721974143  3.1088115790
## [1401] -0.0241606009  0.6469519050 -1.5486494949  0.0516378598 -1.0183748820
## [1406]  0.0319643624  0.7296597449  2.3843063401  1.5073458554 -1.2178458432
## [1411] -1.5218529077 -1.1701907309 -0.0438263592 -0.6234849213 -0.5629714486
## [1416]  0.5251674469  1.8940838274 -1.9078347819  4.0225156199 -0.5521115659
## [1421]  0.7035247722 -1.1697383882 -0.4940227945  0.2616539698  0.2339316343
## [1426] -0.7692248021  1.3495435409 -1.1499593148  0.1961546133 -0.8894628989
## [1431]  1.4769331658 -1.1937181630  0.2505413695 -0.1873798494 -1.2000473873
## [1436] -1.1620512874 -0.0229179716  0.4962534034 -0.4701152607  0.8484521864
## [1441]  0.3010812663 -0.9976235773  2.0830315873  3.8400488719 -0.6736347934
## [1446]  0.3972599122 -0.9261441379 -0.1534816640  0.7093732194  0.8610052038
## [1451] -0.8877593920  0.6673252767 -0.5630876643 -0.1266047282  0.8857002694
## [1456]  0.1337440455  0.7235703684 -1.4484400149  2.1399834530  4.8527959386
## [1461]  1.0066624836  1.4211166902  2.2863186263  0.6590480030  1.6386694174
## [1466]  0.6959727039  1.6545795015 -1.4913985491 -0.6957906752  1.9886722942
## [1471] -0.4642122664 -1.4322948536  1.8817718444 -1.4503458929  1.1356851591
## [1476] -0.9902252953 -0.2479443861  0.6097963302 -1.2536017785  1.8601173988
## [1481]  0.7620261221  1.2109287141  1.0696214122 -0.7293805736 -0.6194256311
## [1486]  0.0132695460 -0.7052360026  1.3552367962 -1.0707220633  0.4843573583
## [1491] -1.1829622165 -0.5237715778 -0.4975918428 -1.0000153971 -1.0569720472
## [1496] -0.3372387698 -1.3144249491  1.2764876567 -1.2839222653  0.8189878589
## [1501] -0.6525744694  1.9811334389 -1.0839030453  0.5762364092  1.1493770872
## [1506] -0.7230475267 -0.2713377801  2.6953106327  2.0535329765  0.4714890524
## [1511]  3.5501949716 -0.9570477308 -0.4784944733  1.5589592674 -0.9758455731
## [1516] -1.0091128377  0.2261271491 -0.2007307707  1.1371553416  0.4158505713
## [1521]  3.1466323735 -0.3502911314 -0.4356237831 -1.6856659993  0.3531626560
## [1526] -0.8759813845 -0.2974881082 -0.5018703901  2.8850605339 -0.5131839298
## [1531]  1.2076615517 -0.7765738323  0.7506959757 -1.4726823522  2.3824180407
## [1536]  0.7710508094  0.6303516089 -0.1005744322 -0.0116067566 -1.1309917227
## [1541]  5.5318588246 -0.0397141171 -0.0902459320 -0.7909282557  0.7536487755
## [1546] -0.4309965085  0.2799437665 -0.4592215748 -1.0449386214  8.2340724744
## [1551]  0.7671159645  0.6797582517  1.1288114895  0.2133600837  2.1181622844
## [1556] -1.4597347345 -1.0706810910 -1.1747371879  4.9652907556 -0.3382123577
## [1561]  5.3515053946  0.1931533671 -0.7105741423  0.7401742128  0.3068118227
## [1566]  1.3545528038  0.5237993361 -0.4972233116 -0.6747088410 -0.4811474822
## [1571] -1.8990320505 -0.5748389509 -0.3599293772 -0.7178238963  3.3333083654
## [1576]  0.1780680141 -0.8271809217  0.3035284450 -0.9510643751  0.6918816698
## [1581]  0.7955621841  1.2562492752 -0.1153549258 -1.1328576929 -0.5969958437
## [1586] -1.2347194267  0.6764030925 -0.5868010897  0.8724885793  1.6274768275
## [1591]  1.7722948846 -0.9261902074 -0.4282036295  1.6522956975  0.5534387421
## [1596] -0.8880981870 -1.0289387724  0.4813066331  2.1475207609  0.2922092013
## [1601] -1.5870635482  0.5504741496 -0.8551231611  1.6458756455 -0.8218451330
## [1606]  0.9956818683  0.5909465456  0.8330649162 -0.7353399509  1.2843507781
## [1611]  1.3080228849  0.6260525916  1.1535765490 -0.0460192057  0.3788537254
## [1616] -0.9504968562  0.6920441835 -0.8918342486 -1.0452881603  1.5729459435
## [1621] -0.8009950800 -1.5464562864 -0.7909701534  0.3598451869 -0.4528365415
## [1626]  0.2687504887  0.3246655808  1.8386810913 -0.8735112811  0.7030806763
## [1631] -0.8177490395  0.3243339548 -0.8216137496  1.5205401249  0.5957294838
## [1636] -0.3375357649  9.6322274257 -0.3117327936  1.1989870399  0.1958013436
## [1641]  0.5366110383  0.3585603920  0.7081953652  0.3467523973 -1.1620512874
## [1646] -0.5180152189  1.5230185554 -0.2782110126  5.7241795736  0.5877233201
## [1651]  0.9758816478  1.3590376691 -1.3889226027  1.4340184088 -1.5791665191
## [1656] -1.1486448949  0.3842298911 -0.7974883742  0.9001658394  1.9601060565
## [1661]  0.4460045601  3.6910669438  0.4458663448 -0.3947416053 -0.0381087217
## [1666] -0.6914654597  0.7835516352  0.7361835408  0.3179968197 -0.2313739879
## [1671]  0.8770093496 -0.9077117186 -1.3197511113  0.0946391209  0.6915824106
## [1676]  1.7850639382  5.4317081188 -0.8729864052 -0.9508095348 -0.3221051183
## [1681] -0.5525899381  0.4061555032  0.0822664367 -1.0476578089  0.5842469328
## [1686]  0.5518108598  1.0261837300  4.4693548556  0.7238871376  0.1405760947
## [1691] -0.5172713004  0.2749969789  0.1660430373 -0.8214362792 -1.1991847958
## [1696] -1.0053409752  0.9054894184  0.6115663171  0.3870795435  1.7517205114
## [1701]  1.7251509276 -0.6920829501 -0.9487779507  3.4557014680  1.4739344408
## [1706]  0.3087625694 -0.3539383177  0.0096972128 -0.7393219360  0.0887101162
## [1711]  1.2417775400 -0.0011445371  0.5656563735  3.2252979123 -1.9441720603
## [1716] -0.5310520522  3.1968796429  0.6950343699  0.6382873025 -1.3497499584
## [1721]  3.8844392046  0.7494523465 -0.6513117973  0.3488064193 -0.1051883987
## [1726]  0.4095005547 -0.8879503774  1.6936660308 -1.0403483870  1.5916934917
## [1731] -1.2603995407 -0.6426317598 -0.7204912259 -0.6090526992  1.9143360706
## [1736] -1.0351967314 -0.1320924982 -0.7241561588  0.9052518475  0.5664584624
## [1741] -0.6790889679  5.9702587888 -0.8214089385 -1.0331267662 -1.7303200432
## [1746] -1.4685438172  1.1576176050 -0.5853394912  3.7474265714 -0.2827659209
## [1751]  0.3811649140  4.0522820664 -0.4126214315  5.4185817826  3.0673822584
## [1756] -1.4981867982  0.0244185996  3.7419069341  3.1876730725  0.2766559387
## [1761] -0.5731085795  0.0920117342  0.2918909497  0.7095452816 -1.3321312056
## [1766] -1.3240730565 -1.0112226727 -0.4774778868  0.4381334247 -1.4516865089
## [1771] -0.1697860252 -1.1264333960  1.4408873848  0.4676695487 -0.9794321431
## [1776] -1.0941001332  0.7952230841  1.2844904756  4.5959914572 -1.2237518502
## [1781]  0.3974268341 -0.2369775211  1.2431312293 -0.2774528357 -1.1683847784
## [1786] -0.2205518973  1.2058646581 -1.0703833063 -0.6066648769 -0.4087278137
## [1791] -1.4678383575 -0.4643524056 -1.1918478151 -0.2227066615  0.6128364103
## [1796] -1.6872339618 -0.2864939856 -0.5998001447 -0.4155219048  1.4352375674
## [1801] -0.2406708691 -1.6556073936  1.5174030100 -1.1268913315  2.4559701252
## [1806]  0.6691798225  4.6299243819  2.9893157726  1.0607349681  1.5253980605
## [1811] -1.5491623667  1.7556956617 -0.4400171148 -0.6314539009 -1.4490231194
## [1816] -1.1745571227 -0.4588032264  2.2328130099  1.0581953707 -1.0725611307
## [1821]  2.2674195635 -0.7477611896 -0.4369180241  0.7956236076  4.3247277734
## [1826]  2.1077392162 -0.8069982664 -1.3209002161 -0.4299355773 -1.2531803080
## [1831]  2.2357498429 -0.5024542229  0.8595517750  2.2142272881 -0.5225945954
## [1836]  1.0497334390 -0.4969716918  0.6226670195  1.6681896648  1.4855029183
## [1841] -0.8268838499  1.2982165386 -0.8716066695 -1.1990408734 -0.0674894664
## [1846] -0.0931642193 -0.5036297823 -0.9081911730  0.2587488569 -0.6224984766
## [1851] -0.3696683000 -0.5694401270 -0.9184756942 -0.7967222891 -0.7601668742
## [1856]  1.6320112419 -0.7264787680  1.8016492348  3.5421196588  0.0007573665
## [1861]  1.3635441858  0.8867156998  1.7343334011 -0.9262369987 -0.6104300247
## [1866]  0.3722581929 -1.0055760456 -0.1464718194  0.5104485297 -1.2897396675
## [1871] -1.1484868502  1.2247856669  1.2136043865 -0.3111284830  0.8619805914
## [1876]  0.2500947475  3.5497352988 -0.6023662197 -1.2917348352  0.2363949261
## [1881] -0.3108611492  1.0243879018  1.9312510359 -0.9469905348  0.0257724808
## [1886] -1.4503458929 -0.1212441403 -0.7817342738  2.7943940958  2.1648993377
## [1891]  1.0683398051  0.5391473881  0.2712337053  3.6581079399  0.4806784613
## [1896]  1.6702380229  0.9403356290  2.2193265589 -0.7355182179  0.8738528998
## [1901] -0.4310272418 -0.8583031183 -0.2898690200  0.9002312024  1.2460248273
## [1906]  0.3142514994  0.7032344444 -0.8720164334 -0.7266834835  1.1578148804
## [1911]  0.4806550126 -0.3703014323 -1.4060503571  1.3585429564 -1.4912398521
## [1916] -0.0524379722  0.6768644753  3.6533923698 -1.5852783188 -1.2524889747
## [1921]  4.1499278496 -1.5364807175 -1.0643209757  0.6612117680  0.2730564811
## [1926] -1.7602349383 -0.6244118294 -1.0717028017  0.3511516235 -0.4777795813
## [1931] -0.0622913846 -1.0387832041  1.5466761382  2.9826831459  0.4947786468
## [1936]  0.1584675490  0.3983051510  1.6084520588 -0.4336095214  4.1240141609
## [1941]  0.2542570555 -0.9081735327  3.3377313133  0.4556732193  0.2812875835
## [1946] -0.2106007752  1.8176138150  0.8349273684 -0.9131305269  0.9361525047
## [1951]  0.5767772825 -1.6270489840  0.2743389396 -0.7255656815  0.2797662712
## [1956] -1.7188199773  0.2358392458 -0.7013955097 -0.0834691970 -1.3903910215
## [1961] -1.8275932163 -0.8644700840  1.3397090388  3.4537476536  4.4903542541
## [1966] -0.4503465094 -1.0504657481  1.0691459102  0.3677495465 -0.4376323059
## [1971] -0.5525203156 -0.3235707472 -1.2047489125  1.4628507593  0.5196848658
## [1976]  0.6480054994 -0.9763299216  1.0406063239  0.8640702971 -1.1299774120
## [1981] -0.6138644874 -0.9206911138  1.4669120208 -0.4969225278 -0.6190121036
## [1986]  0.9878422795 -0.7267195802  4.6983217126 -0.2966382236 -0.4769432149
## [1991] -1.4043392657 -0.5277614120  2.6669727270 -0.8261293927 -0.1121239147
## [1996] -0.6443928015  2.1402990700 -0.5658456683 -0.6524924019  0.5134135268
## [2001]  0.1407451197  0.1860459307  0.3647547655 -0.2272490433  2.0031146528
## [2006] -0.8622367536 -0.1549901500 -0.3882970655  0.3142514994 -0.6444291260
## [2011] -0.8880180592 -0.9509271957  0.2959902189 -1.1015149169 -0.1135254360
## [2016]  0.3928215971 -0.5418590547 -0.3365527353 -0.5314873670  1.7164420641
## [2021]  2.1324063688 -0.1999614377 -0.0999045319  2.2038547457 -0.5159538371
## [2026]  0.1493089262 -0.5961425497  1.1811215522 -0.2015189633  0.0270144721
## [2031]  4.9124503761 -0.9576817119 -1.6065598921 -0.5826072550  1.6270708978
## [2036] -0.9118542407  1.3211545179  1.2695490679  1.1517201882 -0.6243674293
## [2041]  0.9491549901 -1.0997410808 -0.1104027701 -0.8567715463 -0.0516952149
## [2046]  0.3437106323  1.3974570338 -0.7052003053 -0.8209259070  0.1476173630
## [2051]  0.8674745821 -0.6693912712 -1.2020293217  0.0673899009  1.0496308684
## [2056] -1.7798315588  0.9905366462 -0.8334551054 -0.5857106691 -0.0009516889
## [2061]  1.7842365022  2.7302717192  0.7381276048 -0.7956020246 -0.7783477930
## [2066] -1.1620935784 -0.9077974153  2.7315282970 -1.3857666909  7.5567693435
## [2071]  0.4155914246  3.1132370510 -1.4983524479 -0.2061719001  1.0619760738
## [2076]  0.1864550138 -1.0401457228 -0.1523480091 -0.6919963312 -0.2938868628
## [2081]  1.1022717512  1.0498191439  0.5076059398 -1.4724479379 -0.7096793569
## [2086]  1.1546503584  1.1822077619  0.4171460395  0.7499408765 -1.4916391927
## [2091] -1.6115140612 -1.3732390497 -0.3296602523  0.3624135807 -1.2496066004
## [2096] -1.7417271308  0.7250146541 -0.3910107312 -1.3447849108 -0.4731395205
## [2101]  1.4190013721 -0.4383199295 -0.3598747102  0.1441052670 -0.2010399217
## [2106]  1.2104719167 -0.1608361283 -1.0908703709 -0.8235211905 -0.5858665589
## [2111] -0.8163440788  2.0170385405 -0.0703595093 -1.4502865993  1.6825175944
## [2116]  3.1854616237 -0.9088202403 -0.9666928719 -1.0447567428  0.9853780885
## [2121]  0.8461970310 -1.3920154977 -0.4313172041 -0.0961195494  0.1265902717
## [2126]  0.6735203704  0.8168845050  0.3349533482 -1.1520124841 -1.0287639146
## [2131] -0.0610267976 -0.7390880688  1.3683369456 -0.9577698499  1.2361448693
## [2136]  2.5918259726  0.1662752491  5.6413822314  0.6766148874 -0.2149907484
## [2141]  1.2205062479  1.5102869864  0.7380718006  0.7264773752  1.3691382345
## [2146]  0.4363235843 -0.8877593920  0.7135209574  0.6041205174  0.8455365056
## [2151]  0.0596940658  0.2391180698  0.2759342078 -0.3659999655 -1.5231702323
## [2156]  0.2630736953  0.1130616530  0.6001819211  3.2816700783  1.1530611830
## [2161] -1.5871058529  0.7236245178 -1.5921822915 -1.0180350332  1.0810732250
## [2166] -0.7174544316 -1.2993027230 -1.0402243589 -0.3737537086  1.1999899286
## [2171]  1.3277677486 -1.1689170507  0.6022302375  1.2509076922 -0.5225456837
## [2176] -1.1222139916 -0.2091752859  0.7288250598 -1.2576048426  0.4217797885
## [2181] -0.8646790113  0.8261952552 -1.1335416140  2.5031597956 -1.2245756432
## [2186] -1.0988255337  1.1148303623  1.4226377397  0.5905673350  1.6375991488
## [2191] -0.7387438084 -0.6564600907  1.3419254706 -1.5731024149 -0.9794740849
## [2196] -1.6001716977 -0.3240836311  0.8279597436 -1.4339223387  1.0170956905
## [2201]  0.2077800245 -1.8844828087  1.2961665827 -0.0850177606 -0.3794274729
## [2206]  0.3607057508 -0.8159748383 -1.2344642170 -0.6060787800 -0.1489044867
## [2211] -1.5040517870  6.5962098709  1.7017274212  2.3051153614 -1.2536017785
## [2216]  0.3065038226 -1.0906103693 -1.0503737227 -0.0121601574  0.4632270982
## [2221] -0.1356132842 -0.4916696401 -0.5669981040  0.0063041102 -1.5728069732
## [2226]  0.3144241070 -1.5353038686  0.5919623708 -1.2536017785  2.1252288421
## [2231] -1.1162193826 -1.2210131937 -0.3722999656 -0.9234017310 -0.7040721346
## [2236]  8.7941983278  0.5995232558  1.2025321832 -0.8255066580 -0.2208582788
## [2241]  0.0509542097  0.8369679371 -0.8552356799 -0.1553660278  0.2625387469
## [2246] -1.5441400288  0.9287444166 -1.1622258806  0.6560250519 -0.5630664810
## [2251] -1.3734846707  0.7247619624 -0.0058947988 -0.0786717822  0.6865758849
## [2256]  3.3805581647  0.5487711311 -1.0097676267 -0.1713908988 -1.2228409523
## [2261] -0.4119908625 -0.4369517223 -0.6139704933 -1.1560848563 -0.3564948721
## [2266] -1.3512584282  0.4632715146 -0.8319018374  1.9719129194  0.2533223346
## [2271]  0.5205256350  0.0676190310 -0.0804696256 -1.4486808837 -0.0927865959
## [2276]  0.6998884504 -0.0032833314  0.6617250501  0.6109256462 -0.3231775378
## [2281] -0.9978240427 -0.7746317883 -0.6269670720  0.9781027607  0.2860578159
## [2286]  0.2732839571  0.8147411903 -0.5818424290  0.5755477980 -0.6758878740
## [2291]  3.3942025576 -0.9831105353  1.3926599193 -1.5461343930 -1.0803985639
## [2296] -0.1197244500 -0.8700589779 -1.3277033977 -0.2369261819  0.7623490986
## [2301] -0.7729393670  0.9121718891  0.8987923748  0.5376501921 -0.0458957266
## [2306] -0.0673242257  1.9985212083 -1.3375004461  0.5573893125 -1.7303200432
## [2311] -1.8299567050 -0.6919499650 -1.6845904478 -0.4657036849 -0.5831792828
## [2316] -1.2314433304  1.0846077174 -1.0631584588 -1.5788757777 -0.5834765576
## [2321]  0.7034214912  3.6204645038 -0.7860987057 -0.8293403233  0.6046114603
## [2326] -1.3062210868  1.6019349343 -1.3624766365 -0.5293194098 -0.7158386963
## [2331] -1.3722504183  1.4845242312 -1.3140894921 -0.7144605771 -0.4814647261
## [2336] -0.5123484161  3.4082971749 -0.3987903832 -0.0277520006 -0.5842035686
## [2341] -0.3014324454  2.4850652173  0.0438313338  4.3867820982  0.6930221953
## [2346]  0.3955644380  0.5633983046  1.3278183253  1.9750632289 -0.3776685216
## [2351]  3.4553013171  0.4248332539  0.5785235403 -0.4324593325  0.7867002301
## [2356]  2.4776790630  1.6158453325  3.6453557527  0.0520424414  1.4010659738
## [2361]  0.6319897131 -1.6236512513 -0.4529096626 -1.2230079219 -0.2973290694
## [2366]  0.5630809749 -0.8768909395 -0.7683525185  5.4038243831  0.4462925401
## [2371] -0.4466969587 -1.5246182583  1.4530591418  0.1307434838  0.5743759486
## [2376]  0.3693178635  0.1257476759  0.5558669297  1.1254591603  0.4500771411
## [2381]  2.1103037653  1.7085769168  0.5920547044 -0.6916657059  0.5165429404
## [2386]  0.7709207054 -0.3636716242  1.3557277929
## attr(,"gstari")
## [1] FALSE
## attr(,"call")
## localG(x = parqs$Acidentes.y, listw = nb2listw(dnb, style = "B"), 
##     zero.policy = NULL, spChk = NULL, return_internals = FALSE)
## attr(,"class")
## [1] "localG"

Moran Local

Todas as análises feitas até o momento foram de escala global. No entanto, é necessário que seja feita também uma análise local do estudo. Essa análise pode ser feita pelo índice local de autocorrelaçãoo espacial (LISA). Para isso é preciso calcular o índice de Moran local.

ShapePB.mloc <- localmoran(parqs$Acidentes.y, listw=nb2listw(dnb, style="W")) 
head(ShapePB.mloc)
##            Ii          E.Ii       Var.Ii       Z.Ii Pr(z != E(Ii))
## 1  4.34592493 -5.661581e-02 15.896248419  1.1042212      0.2694972
## 2  0.33734579 -1.764543e-04  0.210561019  0.7355521      0.4620033
## 3  0.25349508 -6.391487e-05  0.030472618  1.4525267      0.1463552
## 4  0.63910522 -2.825616e-04  0.674566371  0.7784881      0.4362813
## 5 -0.02347798 -6.672876e-06  0.001985997 -0.5266815      0.5984148
## 6  0.53435912 -3.129735e-04  0.106466852  1.6386278      0.1012908

Mapa das probabilidades (Signific?ncias do I de Moral Local)

Por meio dos valor-p do éndice de Moran local é possível construir um mapa de probabilidades.

library(classInt)
INT4 <- classIntervals(ShapePB.mloc[,5], style="fixed", 
                       fixedBreaks=c(0,0.01, 0.05, 0.10))
CORES.4 <- c(rev(brewer.pal(3, "Reds")), brewer.pal(3, "Blues"))
COL4 <- findColours(INT4, CORES.4)
parqs$COL = COL4  
parqs$p_valor = ifelse(parqs$COL == "#DE2D26", "[0,0.01)", ifelse(parqs$COL == "#EEE5E4", "[0.01,0.05)", "[0.05,0.1]"))
plot(parqs, col=COL4)
title("P-valores do I de Moran Local por Distäncia de Centróides")
TB4 <- attr(COL4, "table")
legtext <- paste(names(TB4))
legend("bottomright", fill=attr(COL4, "palette"), legend=legtext, 
       bty="n", cex=0.7, y.inter=0.7)
A caption

A caption

mapview(parqs, zcol = "p_valor", col.regions=c("red", "orange", "green"))
temp = parqs[parqs$p_valor != "[0.05,0.1]", ]
mapview(temp, zcol = "p_valor", col.regions=c("red", "orange"))

Montando matrix W de vizinhança

ShapeCG.nb1.mat <- nb2mat(dnb)

Incidência de acidentes padronizada

Acidentes_SD <- scale(parqs$Acidentes.y)

Média das incidências de acedentes padronizada

Acidentes_W <- ShapeCG.nb1.mat %*% Acidentes_SD

Diagrama de espalhamento de Moran

plot(Acidentes_SD, Acidentes_W,xlab="Z",ylab="WZ")
abline(v=0, h=0)
title("Diagrama de Espalhamento de Moran por Distancia de Centróides")
A caption

A caption

Q <- vector(mode = "numeric", length = nrow(ShapePB.mloc))
Q[(Acidentes_SD>0  & Acidentes_W > 0)] <- 1            
Q[(Acidentes_SD<0  & Acidentes_W < 0)] <- 2
Q[(Acidentes_SD>=0 & Acidentes_W < 0)] <- 3
Q[(Acidentes_SD<0  & Acidentes_W >= 0)]<- 4
signif=0.05
parqs$Q = Q

Mapa LISA

Q[ShapePB.mloc[,5]>signif]<-5
CORES.5 <- c("blue", "green" , "red", "yellow", "gray", rgb(0.95,0.95,0.95))
#CORES.5 <- c(1:5, rgb(0.95,0.95,0.95))
parqs$cores5Q = CORES.5[Q]
plot(parqs, col=CORES.5[Q])
title("Mapa LISA por Distancia Centroides")
legend("bottomright", c("Q1(+/+)", "Q2(-/-)", "Q3(+/-)", "Q4(-/+)","NS"), 
       fill=CORES.5)
A caption

A caption

CORES.5[Q][1:5]
## [1] "gray" "gray" "gray" "gray" "gray"
head(CORES.5[Q])
## [1] "gray" "gray" "gray" "gray" "gray" "gray"
#save(parqs, file = "parqsFinal-975.Rds")
parqs$cores5 =  ifelse(parqs$cores5Q == "blue", "A-A", ifelse(parqs$cores5Q == "green", "B-B", 
            ifelse(parqs$cores5Q == "red", "A-B", ifelse(parqs$cores5Q == "yellow", "B-A", "NA"))))
mapview(parqs, zcol = "cores5", col.regions=c("red", "orange", "green", "yellow", "grey"))
temp = parqs[parqs$cores5 == "A-A", ]
mapview(temp, zcol = "cores5", col.regions=c("red", "orange", "green", "yellow", "grey"))
mapview(temp, zcol = "Acidentes.x", col.regions=brewer.pal(9, "YlOrRd"))