Clusters de Acidentes por Affinity Propagation: N=18776 = (25%) | APCluster Parameter: q=0.999 | 3639 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-99925.rda")
load("data/AZURE/apres2-20000-99925.rda")
names(x2) = c("LONGITUDE", "LATITUDE" )
head(x2)
dim(x1)
## [1] 75102     2
dim(x2)
## [1] 18776     2

Treino

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

A caption

summary(apres)
##   Length    Class     Mode 
##     3639 APResult       S4
#save(apres, file = "data/apres2-20000-99925.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] 3639    3
exemplars = poly
#save(exemplars, file = "data/exemplars-20000-99925.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-99925.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] 15173.3
median(poly$area)
## [1] 4853.773
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% 
##    82.58996  1489.41598  4853.77307  9714.14970 99754.09196
poly = poly[(poly$area < maximoquantil) & (poly$area > minimoquantil), ]
dim(poly)
## [1] 16095    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    : 16095 
## extent      : -51.26617, -51.08242, -30.23944, -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  : 601007, AC A AV A J RENNER, AC DOIS VOLUNTARIOS-PRES CASTELO BRANCO,     0, Cruzamento, ABALROAMENTO, 0 AV PRESIDENTE JOAO GOULART, 01/01/2015,     DOMINGO, 00:00,          0,   1,      1, 82.9790161279961,         6, ... 
## max values  : 683134, VDT LEONEL BRIZOLA,                             VDT OBIRICI, 90100, Logradouro,   TOMBAMENTO,           VDT LEONEL BRIZOLA, 31/12/2020, TERCA-FEIRA, 23:59,         23,  13,   3639, 17152.2759325802,       230, ...
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    : 2585 
## extent      : -51.26617, -51.08242, -30.23944, -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 B VILA NOVA BRASILIA,     0, Cruzamento, ABALROAMENTO,                                    0 R CEL CLAUDINO, 01/01/2015,     DOMINGO, 00:00,          0,   1,        1, 82.9790161279961,         6, ... 
## max values  :   3639, 683107, VDT COMPLEXO VIARIO TELMO T FLORES-AC B, 21010, Logradouro,   TOMBAMENTO, VDT ABDIAS DO NASCIMENTO & AV EDVALDO PEREIRA PAIVA, 31/12/2017, TERCA-FEIRA, 23:57,         23,  13,     3639, 17152.2759325802,       230, ...
class(spDF)
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"
spDF@data$group = 1
spDF@data$box_id = NULL
dim(spDF@data)
## [1] 2585   18
dadostemp = unique(dadostemp)
spDF@data = merge(spDF@data, dadostemp, by = "box_id")
dim(spDF@data)
## [1] 2585   24
plot(spDF,col=spDF$box_id+1)
A caption

A caption

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

Acidentes por Cluster

#carregamos os dados SpatialPolygonsDataFrame
parqs <- geojsonio::geojson_read("data/myParq-99925.json", what = "sp")
#Verificamos o objeto
dim(parqs)
## [1] 2585   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% 
## 117879.1
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,] 480682.3 6680702
## [2,] 480644.7 6675696
## [3,] 480055.4 6677661
## [4,] 482067.8 6680599
## [5,] 480547.1 6677103
## [6,] 477890.7 6676124
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] 27 17 24 11 13 18 20 15 13 19  8  1  8 14 19 18  5 12 19  1 13  9  8  3
##   [25] 21  6  3 13 27 25 21 14  9  9  1 13  5 15  3 11  1 21 12 21 18 10 30 12
##   [49] 14  5 12 13 10 13 16 21 10 24 22 13 23 31  7  6 13 14 18  8 23  4 13 22
##   [73] 17  2 18  5  2 20 16 20 16 21  7  5  5 23 23  2 18  7  7  4  7 12 10  4
##   [97] 35 16  2 20  7  3 18 18  9 16  1  5 18 16  9  8  3  9  1 22  8  4 25  8
##  [121] 29  9 12 16  9 14 20  3  6  8 11 13 15  3 16 23  2 14 13  5  7  1  8 11
##  [145] 17 17  4  4 10  9 21  5  3  3 15  7  6 21 16 16 16 11  5 10  1  6 13 14
##  [169]  3 16 11 10  4 16 24  4 10 19  6  3 12 11 12 30 14 16 21 18 15 18 13  6
##  [193]  7  4 20 25 12  5  1 21 15  7 15  5 16  5 24  6 12  3 15 10 10 14  3  8
##  [217]  8  7 23  3  3 24 18 18 14  9 23  8 24 11 15 16 20 19  9  6  4  5 12 16
##  [241]  1  4  9 30  8  3 11  7 16 13  5  2 19  3 18 22  8  7  5 10  3 22 23  6
##  [265]  9  9  9 11  7  5 12 10 15 24 16  8 14 25  7 20 20  6 10 16 14 21 18  6
##  [289]  3  9 10  8  8 10  9  1 10 26 16  8  7  7 12 15 12 23  4 12 10 13  1  6
##  [313]  6 13 32  3 12 12 14  4 14 12 16 13 18  7 13 11 11 23 20 22 24 20 21 18
##  [337]  4  9  5 20  9  6  7 11 10 16 25  2 17  9  5 15  3 22  9  6  4 18 10 18
##  [361] 14 15  8 24  3 15  8  7 12 29  8  6 10 11 16  6 11  3 14  5  3  7 25 14
##  [385] 20 20  1  4 11  8 23  2  3  2 14 17 30 11  7 11 10  9 14 10  8  7 23  6
##  [409]  1  8 21  7 16  8  7  4  4 18 13 10 29  6 20  7 22 16  3 18 10 26  6  3
##  [433] 12 11  6  4  3  3 13  3 12  2 26  9 16  1 18  7 17  3  3  6 12 20 21 16
##  [457]  3 12 23 12  4 12 10 26 11 15  5 35 18  8  7  6  8 17  1 17  1 11  9 16
##  [481] 22 14  2  5 15  6 14 20  5  4 11  2 25  9 18 11 24 13  3  6  9  8  2 24
##  [505] 11  2 16 14 12 20 20  9  3 22 15 12 13 12 19 10 14 23  4 14 14 15  8 17
##  [529]  6 25 14 18 19 21  5  4 21 20  6  3 11  6 12  4 16 13  1  9  5 18 13  5
##  [553]  7 10  6 13  2 17  3  4  4  8 18  7 15  8  9 11 15 14 17 13 14  5 12  8
##  [577]  7 15  7  4 10 15 17  7 31  9  8  2 17 23 17 17  6 16  7 10  1  7  7 17
##  [601]  4 21 30 12  4  6 21 19  3 14 13 16 13  6  9 19 18  2 12  3 16 15 29 11
##  [625]  6 21 17  9  9  6 19 14  1  8 12  6  5 17 20 12 10 20 17 17  4  3  4 10
##  [649] 17  9  6 15 13  8  7 17 16 17 23  5  7  7 21 14  8 18  5 13  9 18  6 14
##  [673]  4 23 27  1 11 22  8 18  2 10  3  8 15  2 11 17 15  6 10 18  5 32 17  4
##  [697]  9 19 12  5 26 15  7  5 15  4  5 25 20 15  9  4  3 14 21 14 10 16  4  7
##  [721] 19 22 20  1  8 11 14  7  7 15 19 11 16  5  9 11 17  7 18 28 20  5 14  4
##  [745]  8  1 18 20 13 14 15  9 10  8  5 23  9  3 15 10  6  7 11 11 22  9  9 15
##  [769]  2 10 10 22  8  6  3  7 15 19 15 17 11 10 13  7  5 21  4 26  8  8 20 11
##  [793]  5 12 13 10 18  8 20  1 18  3  3 11  4  6 14 17 11  9  3 14 16  8 21 18
##  [817] 15  9 25  3 11 17  7 16 10  1  6  7  8  8 19 17  7 21  6  6 18  1 19 11
##  [841] 25 16 15 13  8 21 17  7  2  9  8  6 18  6 23  9 11 21 11 10  7  1  2  7
##  [865]  8 12 11 11  7  3 34 14 25 23 19 18 18  8 12  5 22 26 23 11 18 23 31 11
##  [889] 11 20 15  9  4  4 12  1  6 11 15  9  4  5 22 10  4  4 21  7 17 17  4  6
##  [913] 26  2 15  1 15 27  5 20 17 12 17 12  1 16  9  4 16  9 21  7 13  3 18  2
##  [937] 16  3  5  4  3 14 25 17  3  3 16 15 10 13 15  8  8 13 18  5 13 16 15  9
##  [961]  3  7 18 23  8 24  9  3  7 11 16 18  8 18  9  9  7  5 13  6  2 18  9  2
##  [985]  6 30  2 10 17 10 11  4 18 14 10 15 14 16 11 13  5  3 17 10 18  8  2 16
## [1009]  7 12 11 13  4 28  1 11  8 18  2  4  8 20  3  8 11 12  9  1 13 13  7 11
## [1033]  7 13  6 14 16  5  8  3  4 12 24  2 21 12  2 16 22  8  9 25  4 21 20  2
## [1057] 19 17 12  4 23  7  4  6  8  7 25 25  9  4 11  9 19 18 24 14  7  5  9  1
## [1081]  2  7  1 18 11 14 14 10  4  5 18 28  5  1  4  7 22 12 12 22  7  6  4 18
## [1105]  1  4  4 14 19  9  5 15  6  6 15  4  6  8 21  3 15 13  9  1 18 15 15 13
## [1129]  6  6  2  5 19  1  6 13  4  3  4  6 14  9  5  8 29  7 30 19 18  3 13  3
## [1153] 11  7 10 22 16 10  5 21  7  7 11 10 22 20 12  6 13 22  6 10  3 18  9  6
## [1177]  2 21 13 21 11  3 17  5 28 14 22 23 13  2  1 19  5  9  7  3 24  3  6  5
## [1201] 19  1  9 10  5  6  8  8  1 21  8 12  1 21  8  2 16 23  6 21 16 22 11 15
## [1225] 19  7  7 17 12  8 14 24 18 16  4  7 21 12 13 30 22  5 15  7 25  2 21  6
## [1249] 16  8  2  8 15 10 15 24 18  4 22 12 18 24  8  5  2 19  2 16 13 16 14 18
## [1273]  8 33 13  1 24 14  7  6 14 17 10  2  7  1  3 17 21  8 13  1 23  2  3 18
## [1297] 33 11 10  8 10  3  4 20  1 15 12  1  9 13  6 21  5 10  7 11  2 18  4 13
## [1321]  4  2 21  2  5 12  1 26 31  7 22 17  8 17 11  5 24 10 16 20  3 13 17 18
## [1345]  3 11 21 19  6  2 15  7 11 29  3  7  8 17 20 13 17  1  8 10  5 14 20  6
## [1369]  4 23  3 15 15  7 13 11 13  8 18 12  6 10 13 15 14 17 10  4  5  5 17 15
## [1393] 19 11  7 20  6  8 11 18  5 10 29 21  7 13  8 19 19  2 15 32 25  5  6 13
## [1417]  7  2  6 11 10 13 19 19  8  3 20  2  3  7 22 34  5 10  4  3 19  3 11 14
## [1441] 20  6 12  3 25  3 10  2  3  7 22  2  8  8  2 19 24  2 12 18  3 13  9  1
## [1465] 17 15  9 23  3  4 15 10 16 10  4  6 19  1  5 27  1  5 10  4 21  7 20  1
## [1489] 10  4 17  4 18 12  6 17 17  5  4 22 14 11 10 10 13 15  3  5 17  8  5 28
## [1513]  3  5 23 14 15  5 31 20 13 17  8  7 12 19  2 10 12  6  9 17 21  2 20  4
## [1537] 18 23 13  8  3 22 12 20  3  9  2 16 19 21  3 10  4 32 19  9 25  9 12 23
## [1561]  7  5 14 14 14  8  2  3 17  7  5  1 17 15 12  5  4  7  8  3  6 18  2  3
## [1585] 21  1 15 15  1  4  8  1  4  7  3 12  1  8 17 23  7  8 16 13  6 21  1 15
## [1609] 10 14  7  6 11  8  2  4 15  8 11 14  8  3  4 32  5  2  7 24 14 10 17 21
## [1633] 12 12  5 19 14 15  7  6 24  8  1  8  3  4 18 18  9 18  6 18 13 15  1 12
## [1657]  5 14  3  1 11  8  3 12  6 17  6 17 20 25 10 19  7 16 10  4 14 12 19 24
## [1681] 14  5 15  3 14  1 30 24 21 11 15 10 24  6 21 20  9  2  1 32  4 13 16 10
## [1705] 15 27 10 12  4  5 12  2 17  5 21 13  6 21  7  9 33  5  6 18 16 14 11  8
## [1729]  3  2 27 14  8  9  2 14 13 22 38 14  3  4 18 10 20  6 21  7  4  4 17  5
## [1753]  2  8  5  9 20  3  1  9  7 14 18 10  1 17 11  6 11 15  1 19 19 20  6  1
## [1777] 18  4 18  4 11 21 13  7 25 19  4  4 19  7 12  5 31 10 12 17  7  7 15 15
## [1801] 11 16  7 12 26 11 23  3 23  8  5 11  9  7 10  1 17 19 15  5 15 16 12  4
## [1825]  1  6  1 14 15  1 17 18 11 32  7 10 11  9 20 17 27 10  1 19  9  1  8 13
## [1849]  2 12  3  5 18  4 17 26 23 11  6  9 12 15 13 17  1  9 10 17  9  2  7 24
## [1873]  4  5 16 14 18 17 13 24 12  2 21  3  3  6 10 15 17  8  9 11 21  6  8 14
## [1897] 18 11  6 19  2 17 16  8 14  8 23  4  9 16 15  8 16  4 13 17 12  2 18  4
## [1921]  2  4 15 13 18 16  3  5 18 21 18  4 20  9 18  5 12 27 11  8 16 17 11 16
## [1945] 16  6  5 18 29 18 16 17  2  5 13  2  3 17  5 16  3  2  2 11 20  3 20  6
## [1969] 21  1 14  5  6 12  4  6 21  9 21 15 21 26  8 21  5 16 29  8 21 12 13  1
## [1993]  2  7 14  9  1 17  3  9  6 22 11  6 21 13  2 14 19  6 10  3 21  8 23 19
## [2017]  7 21  4  7  8  2 18 17 12  4  2 21  3  3  5 10 21  9 15 11 16  1 34 25
## [2041]  8  4 18  6 17  6  4  9 14  1 31 17 18  1  8 11  2  7 17  9 13 16 14 17
## [2065]  4 13 22 16 21  4  8  3 11 22 10  8 18  4  3 13  3  4 21 16  5 24 15 33
## [2089] 11 14  5  8 15  2 15  4 11  1 19  8  5 23  9  8 21  4  5  9 14 12  4 21
## [2113] 16  8  9 12  5 21 20  9 21 14 17  8  2  3  2  4  7  5 21  1  7  6  4 19
## [2137] 15  5  2 34 17  7 13  9 13  4 22 15  6 12  9  9  7 10  7  8 11  5  9 13
## [2161] 16 21 21  1 12 10 14 15 22 25 12  5 11  5 15  2  9 23  5 27 18  2  6 14
## [2185]  9 31  7 17 14  4  8  8  9 18 13 22  9  5 22 13  1 17 11  7 11  3  5 11
## [2209] 21  3 18  3  5  9 19  8 27 12 11  3 18 11 17  2 25 22  8  1  2 15 20  7
## [2233] 11 17 16  9  8  7 27  9  6  5  5 18 11 21  7  4  2  3 21 22  8 12  7  4
## [2257] 16  5 24 14 21  5  6 17  6 10 15 19  5 13 12  4  3  5  9  7 21 12  8  6
## [2281] 19 10  8  4  6  9 25 10  7  2  5  4 25 17  4 19 26 12  3 21 15 14  8  3
## [2305] 13 13  4 10 15  1  4  4  4  7  6  6  3 10  1 10  6 23 13 16 21  7 13  3
## [2329]  8 13 10  8  4  7 12  1 17 14 20  2  6 23 13 15  2  2 23 11  4  3 17 15
## [2353] 10 15  5  6  2  3 19  4  6  2 26  7  9  2 19  4  4 12  8 14  8 14 22 20
## [2377]  6  4  2 19  3  9  3  5 10 17  1  6 19 11 13  6  9 22  6  4 11  5  8 17
## [2401] 22 23 10 15 20  9  7 14 10 14  8 11  8  8  9 13  6  7  4 14 30  6 15 20
## [2425] 13 12  1 10  3  1 16  4  4  6  2  6  9 12 14 14 27 22 10 13 17  6 18 13
## [2449] 14  8 14 21 17  2 12  7 22  9 21 10 13  2 16 12  3  8 12 14 11 23  2 22
## [2473]  9  5  1 20 11  8  4  3 23 17 15 14 12  8 27 37  8  6  4 17 11 22 19  9
## [2497]  3 14 10  6  1 22  7  1  9 22  3  2 24  7 18  6 12 13 11  7 14 17  4 16
## [2521]  6  8 14  7 11 31 35  1 20  8 13  7  9  6  6 17  4 19  9  8 13  3 18 16
## [2545]  4 11  5 21 14 14  8  3 13  3 13  8 10 20  3 10 19 11  6 10  2  1  1  7
## [2569] 30 18  6 15 12  7  2  5  6  7 10  3  1 15  7  3 17
parqs$n = 1
sub = which(subsets == '0')
sub
##  [1]   20  107  142  199  296  475  477  547  826 1028 1083 1134 1209 1305 1362
## [16] 1478 1572 1586 1597 1643 1686 1699 1765 1825 1846 1865 1992 2038 2098 2132
## [31] 2319 2430 2501 2567
parqs$n[sub] = 0
length(parqs)
## [1] 2585
parqs = parqs[parqs$n > 0,]
length(parqs)
## [1] 2551
length(dnb)
## [1] 2585
#dim(ccods)
ccods = ccods[-sub, ]
dim(ccods)
## [1] 2551    2
points = cbind(ccods[,1],ccods[,2])
head(points)
##          [,1]    [,2]
## [1,] 480682.3 6680702
## [2,] 480644.7 6675696
## [3,] 480055.4 6677661
## [4,] 482067.8 6680599
## [5,] 480547.1 6677103
## [6,] 477890.7 6676124
#dnb = dnearneigh(points,0,2000)
dnb = dnearneigh(points,0,distNeighbors)
dnb
## Neighbour list object:
## Number of regions: 2551 
## Number of nonzero links: 29732 
## Percentage nonzero weights: 0.4568811 
## Average number of links: 11.65504
length(dnb)
## [1] 2551

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,]  865  342 2140  894
## [2,]  570 1441  600 1763
## [3,] 1317  449 2229 1144
## [4,] 1015  943 1883  243
## [5,] 2188 1804 1368  299
## [6,]  152 2505 1578 1670
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 = 14.498, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.1548239001     -0.0003921569      0.0001146223

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 = 14.544, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic       Expectation          Variance 
##      0.1548239001     -0.0003921569      0.0001138924

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.15482, 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.053332, 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.046465, 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 = 12.313, p-value < 2.2e-16
## alternative hypothesis: Expectation greater than statistic
## sample estimates:
## Geary C statistic       Expectation          Variance 
##      0.8624473737      1.0000000000      0.0001248084

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 = 9.5493, p-value < 2.2e-16
## alternative hypothesis: Expectation greater than statistic
## sample estimates:
## Geary C statistic       Expectation          Variance 
##      0.8624473737      1.0000000000      0.0002074876

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.86245, 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 = 18.259, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Global G statistic        Expectation           Variance 
##       6.266128e-03       4.570603e-03       8.623279e-09

Getis e Ord Local

localG(parqs$Acidentes.y, nb2listw(dnb, style="B"), zero.policy=NULL, spChk=NULL, return_internals=FALSE)
##    [1]  0.7463196433 -1.3303063059  2.6664717639  1.3219826089  1.0090333113
##    [6]  3.3960891244  0.4700678650 -0.6206941309 -0.5629422413  0.5679593409
##   [11]  0.8609934613 -0.8929921304  1.6143150692 -1.7560601353 -0.7466117379
##   [16] -0.9898838779 -0.2455720424  0.9980359391 -0.9081702925  0.0285873240
##   [21] -1.2812380757  0.2260380378 -0.5940942074 -0.4707597725  1.2228164864
##   [26] -0.7836617664  1.6327266900  3.9606642618 -0.1062423190  1.5572497237
##   [31]  8.0680439117 -1.4700969858 -0.1908933313 -0.8930533149 -1.4576011325
##   [36] -1.1968066762  0.3056996189 -0.7031082020 -0.0167019375 -0.6103078080
##   [41]  1.8254065028  2.2319027075  1.4121355493  0.1371507900  4.2103943363
##   [46]  4.4048674691 -0.9981725139  1.0113487553 -1.5557711622  2.0041316762
##   [51]  3.1207077511  0.5334093013  0.9169716806 -0.4123761267  5.8581213312
##   [56] -0.4384783480  2.3494770809 -0.0214144890 -0.0797807401  8.2842209390
##   [61]  3.4704681224  3.1511958963 -1.3220023317 -1.2055244329 -1.9726577001
##   [66]  3.5957245344 -0.5757372738 -0.3700503982  1.3992896436  1.0741484531
##   [71]  1.4913501867 -0.2162817064 -1.2633123962  2.3017215537 -1.5546830840
##   [76] -1.2962515201  0.5556772350 -0.1285271618  5.7908854501  0.2658028234
##   [81]  0.8422438582 -0.6497457348 -0.6042104854  5.9222113561  2.4171500852
##   [86]  0.7970546270 -0.1620002606  0.8280172714 -0.5607378965  0.1155628768
##   [91] -1.4334168717 -0.5260224912  0.4754683973 -0.7667346267 -0.7248828198
##   [96]  4.4503784567  0.3584991640  1.8733397102  3.9486543070  0.0442382752
##  [101] -0.3761795861  0.5826548291  1.2411603357 -1.6582772564 -0.2237782284
##  [106] -1.2813462601  1.3643269594  8.3656925136 -0.4623784895  3.7364628780
##  [111]  0.6051080798 -0.4296134414 -0.9405230276 -0.1364456085 -0.6414958531
##  [116] -1.2210671129  4.4548078848 -0.7095724825  1.3330240071  0.2471798514
##  [121] -0.5065373527  0.7427871482  1.0991939213 -1.0110806211  2.0177600182
##  [126] -0.8113681130 -0.6473799096 -0.2911347522 -1.2289445575  0.4714482524
##  [131] -1.0987080485 -0.9757839382 -0.7445965718  1.0355009816 -0.9965689877
##  [136] -1.6039543127  2.5080406643 -0.0141626405  0.5453972557 -0.1904901400
##  [141] -1.3012796506 -0.1915561205  2.1171822356  0.5021371533  0.2894844855
##  [146] -0.5579967253 -0.5568889418  4.3677744566 -0.5420560158 -1.0563630643
##  [151] -1.1658760686  1.9474951658  1.1332217705  0.5862331592  1.8386570542
##  [156]  1.8227504316 -0.5181777587  2.0830058594  1.3674930330 -1.5767022594
##  [161]  0.4289431459 -0.5159872452  0.2777132705 -1.5621295483 -0.3290591893
##  [166] -1.3028408575 -0.7791110381 -0.0160272153  2.7636639292 -1.1505118766
##  [171]  3.7622709905  3.2281161618 -1.6221095041 -0.6168409796  1.4605251801
##  [176] -1.0904521870 -0.5942175323  0.1756757932  0.0248926343  0.9259172133
##  [181]  2.7158931438  1.4545896613  0.3389311666  1.9189410951  2.1285189246
##  [186]  1.6156047590  0.2252666134  6.4655473688 -0.6281985790  2.2587751169
##  [191] -1.1736622652  0.0830519651 -0.9075987415 -0.2613654872 -0.8801277947
##  [196]  2.2267180553 -0.3622768550  2.6172185438  0.8192478847 -1.2167132524
##  [201]  0.3766951038 -0.8585808526 -0.5740505484  1.5698386243 -0.7396661692
##  [206] -1.0024435718  1.0016369407  0.8769114246 -0.9606049805 -0.3035594727
##  [211] -0.4851586853 -1.6602973662 -0.6244035591 -0.5985400818  0.6678384589
##  [216] -1.3297003846 -1.2211294154  5.0316639964  1.0667866343 -0.7979849648
##  [221]  0.3431911343 -1.2499062575  0.0993443908  1.0459473045  3.1330224062
##  [226] -0.8864117217 -0.5232866439  1.6022001173  1.4977341011  1.1824921174
##  [231]  0.1041363992  3.3459927700 -0.8898956287 -0.5837303741 -1.2310853532
##  [236]  0.1789851910 -0.9403794733  1.0925454930  0.5780974626  3.8749463352
##  [241] -1.3592646087  0.2234532336  0.4816206693 -0.8476205010 -0.0805373415
##  [246]  1.8775632661 -1.0064049974 -0.9964958806  1.3731012586 -0.0210633572
##  [251]  1.1348214550  0.9548976783  2.2342078628 -0.9024437122 -1.0699758918
##  [256] -0.7667988843 -0.0760475147  0.6214086216  0.9849627151  2.0712411537
##  [261]  0.2321314744 -0.8867012345 -0.5414904196 -0.7301299427  0.8300635395
##  [266]  0.5570270941 -0.4663791271 -0.3478082832 -0.0468529102  0.9054894657
##  [271]  1.3860181976 -0.9422677252 -1.2633285283  0.8724581734 -0.2060423653
##  [276]  0.9888267064  1.2323995175 -1.6696842474  0.1596160798  0.8460740073
##  [281] -0.8858830826  0.0264245018  2.2695055386  1.4772471993 -0.4566549084
##  [286]  0.2628744894 -0.5417638839 -0.5252701386 -0.9435313438 -0.0325956332
##  [291] -1.1707118078  0.7736467984  1.4096635994  0.0490000523  2.3983487056
##  [296] -1.5438336156 -0.2771509033 -0.1448905892  1.7504396594 -0.4114447516
##  [301]  2.7015548346 -0.8909322952 -0.7530994667  0.1454183267 -1.1809639007
##  [306] -0.9404926723 -1.8627155557 -0.3189288679 -0.7234022330  2.0935711627
##  [311] -0.9483896897 -0.2318419332 -1.4356038879  1.3048400833 -0.0874930574
##  [316] -0.9596716460 -0.6157959584 -0.4839016046 -0.4738545571  7.9902000045
##  [321]  0.0637674058  2.1906931230 -0.7011772455  1.3946909636  1.9733921154
##  [326]  1.2753538507 -0.3353007459  0.7806027849 -0.0056477144  0.4620696258
##  [331]  2.3265603674 -0.2754460860 -0.7465889958 -0.8371755120 -0.5470998744
##  [336] -0.3357580894 -1.4174544738 -1.2940099959 -0.8728716747 -0.7217686694
##  [341] -0.8504094798  0.9984587506 -0.7965678908  1.0460789080 -0.5403791835
##  [346] -1.1963077076 -0.9530220458 -1.1111001089  0.3391702718 -1.1537370123
##  [351]  0.7601985178 -1.1968206271  0.1486227789  0.9966772693 -0.6216703889
##  [356]  1.2384264386 -1.2691291544 -0.2241067481  3.9667278515 -0.9756892510
##  [361]  2.5798388782 -0.9752907695 -0.8292291303  1.9518510442  5.7196112206
##  [366]  0.2295114710  1.3769614844  0.2498102559 -1.4993125887  1.9703312956
##  [371] -0.9758294525  5.3989264632 -1.0566817901 -1.7563184291 -0.4145037458
##  [376] -0.6751141822  0.3312453905  0.7314130030 -0.0375884323  3.0683673393
##  [381]  2.8538605781 -0.8462765212 -1.1028470750  0.2390685198 -0.4082270042
##  [386]  1.0821738392 -0.5294767350 -0.0762116201 -0.0290027669 -0.8350673551
##  [391]  1.6235197948  1.3962395033 -0.0023253279 -1.1695437005 -1.4294976539
##  [396]  0.1310032602  2.8344655734  1.0743685411  1.7291058102 -1.7118016298
##  [401] -0.2581612373  4.6518896103  3.3632655204 -0.0440984688  1.3294565293
##  [406]  1.2376291299  0.6695584499 -0.8848407461 -1.2267993691  0.4589529739
##  [411] -1.1972673286 -1.5045066473 -1.9717001306 -1.2870724330 -0.5571152429
##  [416]  3.6848928896  1.5889988393  0.4811386706 -0.5087399535 -0.0739151051
##  [421]  6.8644174900 -1.0301501856  0.2048082186 -1.2751999286  2.8811757172
##  [426]  1.0892823382 -1.3023201348 -0.1528921488 -1.7137888433  0.1814734574
##  [431] -0.7019683323  0.1175722794 -0.3761414670 -0.3539142223 -1.1111829747
##  [436]  2.3184062946 -0.9961825908  0.3906390370  2.2780193876 -1.0759695607
##  [441] -0.8934645980  0.3607804374 -1.8842406626  3.4802527659  0.9320480913
##  [446] -1.0024803825 -0.4341718860  1.4585982826  0.3220510479  3.0875052476
##  [451] -1.5249197287 -0.7849560356 -1.0675953166  0.1741344514  0.8986172850
##  [456] -1.2681299866  0.7210530434  1.4460460237  4.3510781166 -0.0324359817
##  [461] -1.5487505992 -0.4993964099  4.5876081682  0.5528871863  1.2295146055
##  [466] -0.5086898653  1.0109296167  0.5773269735  1.9079968840 -0.7557532448
##  [471] -0.8144148895  1.2566786208  0.8882760254  1.2404356476 -1.4654882845
##  [476] -0.8966885593 -1.3861162001  0.1961722023 -0.3190594735  0.5323125148
##  [481]  1.0953317432 -1.2597638374 -0.5593309335  4.9377187427  0.2718407082
##  [486]  0.8511542316 -0.6982636383  0.4826667080 -0.7876971740  4.7406491329
##  [491]  1.8374558472 -0.5665732207 -0.4350562950 -0.9813523231  0.4610163998
##  [496] -0.4628323293  1.2676574241 -0.8154566877 -0.3960204631 -1.6080093293
##  [501] -0.9734426357 -0.2596775630  0.8094142784 -0.4060084799  0.0582095070
##  [506] -0.4303876637  3.6858175858  1.4228554741 -0.1657533653 -1.1821316948
##  [511] -0.4940979366 -0.6269337018  0.5339056814  0.8588540883  2.6203050238
##  [516] -0.7478520337  1.3159233790 -0.0491940688 -0.6683787446 -0.0580205520
##  [521]  0.7379638731  0.5672663555  5.3752453563  2.8080422221  0.4506102184
##  [526] -0.5357416100 -0.8319173433 -0.9853923278 -1.1977832981  0.4922608363
##  [531] 10.7967416194 -0.5697069343 -1.3837793723  6.0689326492 -1.1871891921
##  [536] -1.2029134977 -1.2442573995  2.0847895112  0.3837821940 -1.0617931103
##  [541] -0.9008675074  0.9090928727  0.4062692350 -0.5832025237  0.5812745445
##  [546] -0.3774677691  0.4511783085 -1.1410715204 -0.9298645245 -0.6964496831
##  [551] -0.6752351721 -0.6782204876  6.3563403541 -0.8923143711 -0.3875955271
##  [556] -0.6697928046  0.7593406899  1.3122320299 -1.7235264406 -0.7868856521
##  [561] -0.4874022616 -0.3414858155  1.2052100823 -0.0531449160  1.2009147904
##  [566] -1.4282160357 -0.0700777684  1.7151959819 -0.0607560414 -0.6960523058
##  [571] -0.1701233431 -1.4333667907 -1.7082366495  0.2088149049  2.3411705391
##  [576]  0.2945337567  5.4597888623  0.1525532946 -0.7589034101 -0.9298645245
##  [581]  1.2081352333 -0.0625577743 -1.2154043241 -0.1910362593  0.2204769128
##  [586] -1.4176281866 -1.8306744964 -0.5574813114 -0.2328539794 -1.4020130280
##  [591] -0.9203001570 -0.9956232452 -0.7719081812  0.0881869302  5.9202728749
##  [596]  0.8587411997  2.0133623162  1.4558920320  0.2727507953 -1.5823309035
##  [601]  1.3136047255 -1.1627828707  0.0002572051  1.9675589183  0.2738576243
##  [606] -0.5496637701  0.8759435802 -1.1050152999  3.4171893666 -1.2302049815
##  [611]  0.0927645478  0.2237792172  3.9883356404  0.2450356079  2.9558663116
##  [616]  0.7660856454  0.1431758604  2.3404316050 -0.9853491673 -0.8409763492
##  [621] -0.3027157328  0.7019281175 -1.5509403998 -0.1520656821 -0.7047427558
##  [626] -0.2750910882  0.4205116158 -1.2451369476 -0.2032573979  0.2198813268
##  [631]  0.1976827481 -1.5589538745  0.7577198276  1.3698701207  2.6546577356
##  [636] -0.5261573223  0.0307136295 -1.3026851720 -1.2684933100 -0.1687487412
##  [641] -0.6183319044  1.5535258651 -0.6284040351  0.0148769016  1.4417629688
##  [646]  1.6126797397  1.4554636833 -0.0208928302  6.7683969037  3.9852903325
##  [651] -0.1118715273 -1.0912097410 -1.5803061912 -0.3843341502  2.0824846765
##  [656]  1.2547700603 -0.3085600691 -0.1639552652 -0.0986415484 -1.5873306968
##  [661] -0.7923682474  0.1817044960 -1.0515292254  0.7324761169 -1.1025129047
##  [666]  1.0048135098  0.9043567232 -0.7043723289 -0.2166197643 -0.8642518548
##  [671] -0.3242773391  0.4044084102 -0.5291075946  1.8985112275 -1.1937203686
##  [676] -0.6582506936  2.2739618914 -0.7963095484  2.9044336775 -0.0901578374
##  [681]  1.2238065765 -0.4346143036  2.8654801913  9.7292514448  0.2631848959
##  [686]  3.7144355464 -0.7212301266 -1.0559763668  0.2689236760  0.1337382072
##  [691]  2.6482036084 -0.2856996603  0.7148431352  1.3449370677 -0.5809114766
##  [696] -0.9426683253 -1.6488485252 -1.0317001520 -0.8368330044  3.9144226348
##  [701] -0.3862149889  0.9285014250 -1.0772008409 -0.0402475671 -1.4391710619
##  [706]  0.8222689366  0.7074726171  0.7349998616 -0.0051588179 11.9384046884
##  [711] -0.9605223090 -0.7417357091  2.3726199000  0.8513855928  2.8765919071
##  [716] -0.4216094899  0.4272916343  0.0533412328 -1.5413992636 -0.5988841507
##  [721]  1.4556855222  1.8517067725  0.0804714755  1.0085677368 -0.9311438644
##  [726] -0.3939453441 -0.0354787185  1.1507477539  0.6230916322 -0.7047440581
##  [731]  1.9783585285  1.8372585977  0.2377442438 -0.0773092186 -0.7976258251
##  [736] -0.7727909972 -0.9924311971 -0.7989964396  0.1388215267  1.2124816987
##  [741] -1.1297424355  2.5924587215  0.2455334701  0.3571570354  0.1297781331
##  [746]  0.4936604256 -1.4704921351  2.3102922420  0.9872270404 -0.7025173733
##  [751]  0.6378169184 -0.3170638719 -0.7614694677 -0.9725969673 -1.2710241545
##  [756]  2.0071807506  3.5922025298 -1.5648812454 -0.3049748820  2.5917612057
##  [761] -0.9968523203  0.3843279793 -0.1089628030  1.5408391987 -0.2748117192
##  [766] -0.2040159609 -1.3563341044  0.9390378130 -0.7802947797  1.9162230162
##  [771]  0.5258637555 -0.3974063964 -0.7020277819  0.2204442096  1.9531098844
##  [776]  0.9189136566 -0.3512780439 -0.0988952259 -1.2446730773  0.2494428953
##  [781]  1.3134120586  1.6460642592 -1.0228391114  0.3839426062  0.1338728998
##  [786] -0.0562354325  0.8647504876 -1.1082422099 -1.1913403069  1.1116936529
##  [791]  0.9354509121 -0.4213918334  1.2220824895 -0.6756935738 -0.5941759036
##  [796]  0.9088926610 -1.6218064244 -1.0903654043 -2.0104975073 -0.3420838424
##  [801]  0.5664099858 -0.9345391528  0.0055467439 -0.9867014134 -0.4603192972
##  [806]  1.4457546170  3.4077114133  0.7840862520  1.0033476889 -0.3687571542
##  [811] -0.1816239703 -1.2482281480 -0.8146264923  0.2773548846 -0.9022554541
##  [816]  1.4230026829 -0.4950531961  0.8561880619  1.2583409148  1.0978880556
##  [821]  1.4123815649 -0.2228811188  8.5429411831 -1.0623105280  1.2479674369
##  [826] -1.3023687425  0.2015160218 -0.5442285378 -0.8934645980 -0.7781502947
##  [831]  0.1535451652  1.4292383877  2.2501532462  6.3915367668 -0.0378387597
##  [836] -1.1416675315  3.1482784264 -0.6055598975 -0.1523702234 -0.4293606387
##  [841]  0.7185494075 -1.2250582206 -1.4769283249  2.4243865063 -1.1876948266
##  [846] -0.0737842757 -0.5406927216 -0.0028786530  2.0928910612 -0.6590599544
##  [851] -0.5131529923 -0.7417973155  0.2390347971  0.8055070241  0.0628731185
##  [856] -1.1930390264 -0.4251605210  2.4069770849  0.2527360724 -0.3825771735
##  [861] -1.2753824248  6.0145211706 -1.2892724247  0.4621624096  1.6367359520
##  [866]  1.7436459384  1.7443584501  2.6705478506 -1.2097429353  1.0354045231
##  [871] -0.2464342594  0.1570981271  2.3224627571  4.9486056820 -0.7151313538
##  [876]  2.2581538597  1.1931049231  3.5462849493  2.3365628669  1.6667056412
##  [881] -1.4874080936 -0.9159490697 -1.4073072825 -0.3471397205 -1.2200838263
##  [886]  1.3405587587 -0.2328315226 -0.2607870340  0.8529034376 -0.7172221401
##  [891]  0.5450748014 -1.0083388055 -0.5206504895  1.4405754216 -0.2881414348
##  [896] -0.6764639534 -1.2686071030  3.4784144909 -0.6699598992  1.0481544908
##  [901] -1.4334370885 -0.4415938797  0.4719392359  5.4491960173 -0.8633150031
##  [906] -0.1951763434 -0.9403794733 -0.6460625017  3.8644027056 -1.6612374481
##  [911]  1.7405374391  5.8567123440  0.8844402769  1.3567217728 -0.7122925123
##  [916] -0.6574666120  1.8317366142 -0.7922275560 -1.0079863363 -0.5784677424
##  [921]  2.1840670735  0.1852936953  1.8652878679 -0.8148391112 -1.2756398270
##  [926] -0.7660891298 -0.6295928312  1.8701678725  0.0882030049 -1.0067898092
##  [931]  0.5021998719 -0.8937527164  0.7328391180  1.9608693897  2.0943913262
##  [936] -0.8934049835 -0.2397987251  0.6401575918  0.0122888131  5.2902646489
##  [941] -0.2639704360 -0.1933082613  0.2113310163 -0.6905680937  1.6251807554
##  [946]  1.7095990025 -0.8162958286 -0.5392237492  0.6073173875 -0.0605052312
##  [951] -1.6596363558 -1.5207670449 -0.4729825043  0.6303690927 -0.7523704797
##  [956]  0.1106585624  3.0441176838 -1.0289969754 -0.8937527164 -1.7948920865
##  [961] -0.5157597227  2.6038391485 -0.4995938159 -0.2064365831  8.8625390892
##  [966] -0.2064659994 -0.0848426490  1.3124814412 -1.2389259920  0.0639074895
##  [971] -0.7637123422  0.0377965799  0.7851896385  0.9860566094 -0.7294702842
##  [976]  1.0694592860  3.5265506699 -0.7296028233 -0.5422889611  1.7203533661
##  [981]  0.6829853355 -0.8162069505  0.0065539304  5.4370139601  2.5407178329
##  [986] -0.0192838957  1.5894710992  1.7441373141  1.1839973478 -1.1700727465
##  [991] -0.8662334366 -1.5348504426 -0.7845468112 -0.3082816376 -0.7222205860
##  [996]  0.8061839618  0.0099044169 -0.9633531490  0.0245995836  0.2054573546
## [1001]  1.0769275731 -0.1878675124 -0.2905624402 -1.2438123928  1.6404917359
## [1006] -0.8460948631  1.1240074552 -1.1605758019  6.0217145168 -0.6630736662
## [1011] -1.1505118766 -0.6927395014  0.7158454989 -1.5203732045  0.3621723367
## [1016] -0.0317554364  0.5026494489  0.0881117567 -0.5124257970 -1.1156485592
## [1021] -0.9379050591 -1.1298144921 -1.6699059403 -1.1029617403 -0.1458961429
## [1026]  2.6194052623  0.1315906917 -1.4908692500  1.5820648873 -0.3489248428
## [1031]  0.0067018562  0.0253399351  0.7122920367 -0.1621614745  0.6872773458
## [1036] -1.4623880175 -1.1636770085  0.1545984407  0.4002955049  1.1791218360
## [1041]  2.2308168079  1.4215440406 -0.1117407258  2.2583469089  1.1159800953
## [1046]  0.2049753525  1.4694479134  1.5405252234  0.8708882215 -1.6700073705
## [1051] -0.8421739552 -1.5452018342 -0.7720533922 -0.9174140005 -0.6923157903
## [1056]  0.5804817257  0.9747659703  0.5797709054 -0.8391086843 -0.1820593561
## [1061] -0.9861261506 -0.5734956250 -0.8875623859 -0.2089846498 -0.1781262080
## [1066]  0.1638584611 -1.1703592635 -0.9009194805 -0.5875860149 -0.8934982663
## [1071]  0.6051723560  0.1513680013  1.4566859686 -0.4173407281 -1.1130476404
## [1076] -0.5161564654  1.1319889172 -0.7962531815 -0.2024790735  0.9763433812
## [1081]  2.1402183260  0.2818542714 -0.8934645980 -1.2212789188 -1.9554463758
## [1086]  0.7329303456  1.3764730370 -1.2712954558  0.8430252835 -1.6693411145
## [1091]  2.5349890917 -0.5586877816  0.0144921534 -0.5628718869 -0.5131989254
## [1096] -1.0089198184 -1.6068445011  0.4508036417  0.4824099768  0.5400893907
## [1101] -0.5351753147 -0.8387997434 -1.5730272736 -0.2934407425 -1.0550007964
## [1106]  0.1047043860  0.0099568436  1.7519327880  0.0600210141  1.5528241615
## [1111] -1.1559779506  0.5491746717 -0.8462765212 -1.1245718769  1.1251287679
## [1116]  1.0031950842  0.1031958974 -0.2429140418 -1.6699586506  0.0043713557
## [1121] -1.0484384790  0.2552632647  0.1813008052 -0.0533458602 -0.7722500785
## [1126] -1.1390249320 -1.2684380786  0.0662338051 -0.1492111144 -0.5104168661
## [1131] -1.2592845861  1.4289144379  2.5130093294  2.5800426562  1.4884497002
## [1136]  1.4231780394  4.5355804917 -1.1938742096 -0.9573173950 -1.0028511108
## [1141]  0.7375758689 -0.2764446795 -0.7663035887  1.0654153229 -0.4466981299
## [1146]  0.8776148524 -1.3441278141 -1.2237921923  5.7757104910 -1.1165230062
## [1151]  2.3499594503 -0.9469362017  0.3886685815  1.0652301291  0.2161815343
## [1156] -0.5322044445 -0.6440160807 -0.5704380327 -0.4737102247 -0.2141947720
## [1161] -0.6755419010 -0.1743302131 -0.7462704989 -1.0334369608 -1.0965699481
## [1166]  1.6913250042 -0.5529375611  4.3369665233  2.1379585528 -1.2207823372
## [1171]  0.1286442308 -0.7737358016  4.3027104258 -0.8460102163 -0.4486858358
## [1176]  2.0538424882 -1.2577694897 -1.2971241783 -0.9403532284  0.1581605923
## [1181] -0.9010801302 -1.0293247531  0.3658558630 -1.2206927821  4.5393184734
## [1186] -1.3572964316 -0.5707164237 -0.6260080402  3.0671013416  0.1449835557
## [1191] -0.6363168152  0.7129318781 -0.9222546447 -0.6286182931  0.2261855359
## [1196]  0.7952076040  0.9883319299 -0.4253860024  2.3317406235  3.2116924302
## [1201]  4.9499462066  0.1433780107 -0.6629648633 -0.7446821446 -0.3692179871
## [1206] -1.1871381997 -0.5945322297  0.2871913741  0.0072412415  0.2385384336
## [1211]  1.1397765214 -1.3117205558 -0.0451356219 -0.1346165861  1.0728982701
## [1216]  0.7227408041  0.7107764369 -0.0002181399  1.2169389069  0.5379475009
## [1221]  0.1909619535 -0.4414834639 -0.2589883949  1.3512410810  1.2266795100
## [1226] -1.0747440668  1.0690822210  2.5575636412 -0.3942225569  0.0616549743
## [1231]  0.1873622451  1.7324884049 -0.3959570970 -1.3268643480 -1.3803928359
## [1236] -0.1168468185  0.2601494206 -0.8633150031 -0.4418605592  2.9215006123
## [1241] -0.0185220387  0.6001517661  0.7129661034  1.4732603405 -1.3394309079
## [1246]  1.0087247352  4.1472042696  1.5338346826  2.3098752844 -0.3755020723
## [1251] -0.8585808526 -0.2287905521  1.1880373955  1.3393744845  0.0719976478
## [1256] -0.9458599273  1.1749150982 -0.3797748296  0.0467128226 -0.8908781097
## [1261]  4.3101971341  0.3141834498 -0.6102527521  0.2212975558 -0.6700350345
## [1266]  0.3489420474 -0.1658318197  0.4076890706  0.3700097110  0.9076201511
## [1271] -0.8963177678 -0.6156642297 -0.3272317346  0.1144663367  0.4607515133
## [1276]  1.9087102237  0.9611104347 -0.9329760720 -0.3743957530  0.4215917391
## [1281] -0.5292533040 -1.1659116171  5.9391738898  2.2437707871 -0.5311778346
## [1286] -0.7074076840 -1.1591739029 -1.0361148510 -1.1938742096 -1.0791099315
## [1291]  0.9830671757 -1.3798354514  4.9141387971 -0.8460671766 -0.0515623693
## [1296] -1.1818925888  0.9142458286  0.3355888437 -0.5617032824  1.5352545134
## [1301] -1.0262508221  1.1086102551  0.2387164943  0.5100704416 -0.2297363765
## [1306]  1.4937168882 -0.8428661449 -0.7286813502  0.1392763713 -0.1957276025
## [1311] -1.1531806587  0.0254040700 -0.8933682834  4.3869596229  1.8361535101
## [1316] -0.1521155582  2.4202507382 -1.0764359100  1.3456411603  0.6107000140
## [1321] -0.2317565322 -0.0346145018  2.9105033768 -0.3913311918  0.0715585921
## [1326]  4.1923447934 -0.8395565340  0.6149193210  5.7116022595  2.6923193658
## [1331] -1.3836888975  0.7945446365  0.7698080966  0.6224976289 -1.0135638613
## [1336]  0.0715005954  0.0242912779 -0.3655208661 -1.6838750319  1.9476841221
## [1341] -0.7847022642 -0.5449752187  0.1094519280 10.4370460068 -0.3248722210
## [1346] -0.9588251778  2.0021873109 -0.7596918617 -0.3774677691 -0.7313738057
## [1351] -0.4643523159  4.2959353387 -0.9951750875 -1.2207375560  0.2839803734
## [1356] -0.6759388173  3.2011267530  0.0370798583 -1.0082154423  0.2082688364
## [1361] -0.7005384094  3.1891047907  1.7966644198  0.9519891512 -0.7939782660
## [1366] -0.6851471657  0.4291672204  2.5850158711  1.3078146817 -1.2634517352
## [1371] -0.3296080474 -0.1988214199 -0.4885508828 -0.2672401987 -1.0276287515
## [1376]  1.0131457742  0.7732651949 -0.4205303406  0.8515156833 -0.8130379887
## [1381] 10.7105197131 -1.5734060622 -0.2083786898 -0.5736691921  0.6525983642
## [1386]  2.8581156356 -0.7369053335  2.9017426182  5.2353803237  0.7233109385
## [1391]  2.5863623321 -0.7262789422  0.1551474165  2.1884250063 -0.6630736662
## [1396]  0.3688038612  5.6418839737 -0.0753068333  1.9289823208  2.6880755879
## [1401] -1.1821316948 -0.0791371075 -0.4291745193 -0.5893931468 -1.2440916252
## [1406] -0.8568153647 -0.2111535723  8.4973168368  0.8724209213 -0.1413891564
## [1411] -0.8392477796 -0.8856249271  0.8721099168 -0.6757329693 -0.5092653100
## [1416]  0.8943797778  3.4085644453 -0.2040624693  1.1907489710 -1.0081341835
## [1421] -1.3022020276  2.6380647963 -0.1854315944  5.4286837342 -1.7819627794
## [1426]  0.5035871426 -1.1300328792  1.3076863900 -0.6212280325  0.8713303155
## [1431]  0.5505048885 -0.9158865054 -1.1632390086  0.1155567439 -0.3479081575
## [1436]  1.0094016197 -1.3304055050 -1.2769755712  0.6443404747 -0.6961983233
## [1441]  0.0138415275 -0.3155276349  1.6063333186 -1.4487385488  0.1263858710
## [1446]  4.2576505857  1.7827433208 -0.9511799253 -0.8462443942  0.0029845672
## [1451]  1.1987226727 -0.5728749219  0.1737833871 -1.2750285771 -0.1797563278
## [1456]  1.8453736449  1.3103397499  4.0708083692  0.0853414961  1.3285301144
## [1461] -0.4744087282  0.2529186618  0.3666396693  2.1443773445 -0.6575538781
## [1466]  0.8736004928 -0.1686300628 -1.1265457269  1.2040220099 -0.5785701026
## [1471] -0.9697145289 -0.7515998461 -0.0645373643 -1.6462084396 -0.0546404559
## [1476]  0.3367959905  1.3640349371  0.2707189355 -0.9753104816  1.5404586859
## [1481]  2.3666516773 -1.4713587077 -0.9847774832  1.2675225933  0.2546070282
## [1486] -1.8854990131  1.9276526361 -0.8568153647  0.6149193210  1.0042497802
## [1491] -1.2479891986 -0.2465252323  0.5989332524  0.4771504562 -0.3309585454
## [1496]  2.6033452337  1.2048170462 -0.6897874623  0.3540710381  1.6689251290
## [1501] -0.3663597960 -0.9210404026  2.9377258522  0.9893571554 -1.1034261412
## [1506] -0.7905372250 -0.0408377487 -0.9733179410 -0.5079647410 -0.8979799976
## [1511] -0.9632356864 -1.3194369079  0.0655885059  1.1068909269 -0.7764288420
## [1516] -0.4906169317 -0.2741001525 -1.0629752066  1.3458639843 -0.9381489665
## [1521]  1.2076842943  4.1778371816 -0.7102053887 -0.9594104312  0.0328946471
## [1526]  0.7746566995 -0.5204435517 -0.2607220541  0.6876465742 -1.4238294098
## [1531] -0.3959886066  1.3497494332  7.1491691724  0.7279926883 -0.4578653469
## [1536] -0.4380320470 -1.2206123193  5.2677872083  2.5349818640 -0.0850694777
## [1541]  5.9994842346 -0.3369467653 -1.2176767566  0.2629741758 -1.3307236115
## [1546] -0.8800158706 -0.0375190448  0.4935089812  2.6454729853  0.3596409419
## [1551] -0.8631970558 -0.1025668530  0.9887939224 -0.0621029578  5.4227105997
## [1556] -0.7997020894  2.6515036778  1.9375532008 -0.4782794073  0.8800088003
## [1561] -1.1519821501 -0.8933435398 -0.2395560833 -1.1670842503  1.5930241122
## [1566] -0.6293931480  0.4147204001  9.3439557567  2.4435005459  4.3021319412
## [1571] -0.3744206123  0.3144903885  0.5452226514 -0.9403278053 -1.6460308056
## [1576] -0.7408895192 -1.4391710619  3.3555464011 -0.2751476874  0.7619371615
## [1581]  1.3404014757 -0.7950619492 -1.5947847801 -0.0796541801 -2.0206178509
## [1586] -1.4570660615  2.9208772252 -0.8457571810 -0.8060006877 -1.3946335468
## [1591]  1.0121178060 -0.2048361962  0.4127706995 -0.9428609071 -0.2416792151
## [1596]  0.3052619586  1.1633274562  2.9202541522 -1.3254776948 -0.2440510084
## [1601] -0.7579017137 -0.9429452611 -0.4851586853 -0.3472901629  2.7537941590
## [1606] -1.3861162001 -1.1967163326 -1.6685657674  1.9161584848 -1.0744323199
## [1611] -0.1394552169 -0.0978543628  3.0961359285  0.5577333490 -1.7487581591
## [1616] -1.0474346838  1.7635251760 -0.1627140566  2.7132325660 -1.7588489192
## [1621]  1.2224751447 -0.5450259043 -0.8427169574 -0.2249176405 -1.4108854084
## [1626]  0.9275651442 -0.6214285232  8.7039912009  0.2781738925  0.3709330662
## [1631]  0.4719910263  2.6036872637  0.3793057238  1.9554425790 -0.7518398099
## [1636] -0.9845894340  1.3164442732  0.1912414474 -1.2202146612 -0.7989385979
## [1641]  1.4218988956 -0.2743240378 -0.8117607134  1.7348965410  0.2201666573
## [1646]  2.6313927431  0.3354399564  3.5957093321  0.6552180341  5.8518333608
## [1651] -0.9611734922  1.3827832368  0.0439478618  1.7189866223  0.5654515873
## [1656] -0.9853656377  0.4302996156 -2.0761590635 -0.0178571472 -1.2188266707
## [1661] -0.0126518987 -1.2807255083 -0.4635586391 -0.5395090159 -1.2884370394
## [1666]  1.1658833577  2.1167655283 -0.5418228834 -1.2279963475  2.1157085478
## [1671]  2.4769261380  1.2764179056 -0.8007616549 -0.6129278114  0.4623064575
## [1676] -0.9509871523 -0.7631180834  1.3186006755 -0.3478976393  0.5760570655
## [1681] -0.0553321658 -1.0806811672 -1.1595552456  1.5063096015 -0.4536242388
## [1686] -0.9296688275 -0.7008641416 -1.7451459645  1.2289336374 -0.1622439976
## [1691] -0.2139240951  0.4081974156  0.0676845721 -0.4311356273 -0.9173618821
## [1696]  1.3272185536  0.4725857709 -0.9032547413  2.2090367878 -0.5628390055
## [1701] -0.9747259592  1.1970079974  0.3560829161  1.0129939168  0.7709477630
## [1706]  2.5323708794 -1.1391641802 -0.7961459103  5.6921262023 -0.3155022014
## [1711]  0.1592132744 -0.9041884655  0.4050472829  1.9847814756  0.0647699414
## [1716]  1.9952377986  1.8091060283  1.0536690103 -0.6204464987 -1.4336860767
## [1721]  0.8850419535 -0.3775255337  3.6575840636 -1.3612986386  1.2565347029
## [1726] -0.2230804602 -1.2686071030 -1.2917352443  1.6905750765 -0.5843952693
## [1731] -0.9965689877 -0.2081016972 -0.9640683121 -1.7391176551  0.2390075150
## [1736] -1.4113250450 -0.5629176695 -0.4786622845  1.7062384207 -0.1771383302
## [1741]  0.8416754125 -0.1684531524 -1.8219805429  0.2830058457 -0.8020501621
## [1746] -0.4028151912  1.7752220594 -0.8930533149  0.2777590140  2.6317890602
## [1751]  1.2122243604  0.1828975726 -0.7989671694  1.3655881425 -0.5355950440
## [1756]  2.1347229772 -1.6698156351 -1.6557676078  1.6067190668  4.2249756585
## [1761] -0.8488116970  0.5301077081 -1.4288201508  0.0563629790  0.2898170230
## [1766] -1.2234277012 -0.8480644386  2.1408106301 -0.8584816525  0.9914537020
## [1771]  1.1029531918  0.7906324413 -0.6160208745  2.3496667263 -0.8659713939
## [1776]  2.9704614457  0.0994514913  1.2223835380  2.8758465049  1.9550300166
## [1781]  0.9939515077  2.5936380444 -0.5023972584  0.8947877066 -1.5750152699
## [1786]  2.4975842692 -1.2102207377 -1.4499929883 -0.7725689743  0.3090292305
## [1791] -0.0785235660 -1.7092397869 -0.8934317115 -1.2725258687 -1.5934757862
## [1796] -1.3915771014 -1.3236495885  0.3174449571  0.0841221134  0.1203802289
## [1801] -1.5041825638 -1.5920299924 -0.8934317115  1.2162179333  1.1485788220
## [1806] -0.3743957530  1.2656860760 -1.4003528193  0.6094449079  4.8118945402
## [1811] -0.7239405677  0.5041285885 -1.5712488700 -0.1629833685  3.1489272284
## [1816]  0.3700097110  4.7836169908  0.5485719266 -0.3743231427  1.2850790955
## [1821]  0.5014194580 -0.2908696462  1.2968519122 -0.8961329045 -0.8076282301
## [1826] -0.4033575675 -1.6824200050  2.9495836236  0.0061844581  1.4482472493
## [1831]  5.4762117078 -0.7031136926 -0.2834563860 -1.4182630801 -0.7466546562
## [1836]  2.0874515389  1.3451581816 -0.6970095784 -1.3161296133 -1.4533482061
## [1841] -0.5431152265 -1.0315342383  1.8372804719 -1.0301827839  0.3831777979
## [1846] -0.4964616411 -1.1975122208  0.8944349228  1.8235909962 -1.2633895804
## [1851] -0.2985738129 -1.0187308721  1.0877956970  2.0782679123 -0.5898000783
## [1856] -0.8965690879 -0.3887846395 -0.3214153299 -1.1666190038  0.8946276022
## [1861] -0.3331600712 -0.9403820435  0.1401234899  0.0768778607 -0.9357642544
## [1866]  0.2676360562  0.6701299287  0.3981907058  0.0260849182  1.9082748565
## [1871]  0.8309740635  1.2940192334 -0.7053226914  1.8745564419 -0.3289794245
## [1876]  0.3726051545  2.2373943498  0.3938838873  0.9744967598 -0.5089741996
## [1881] -0.3395757735 -0.8198597203  1.8531275928  0.2740671744  0.0975261052
## [1886] -0.4246592177  1.6465001894 -1.7873437318 -0.9848369118  0.4083130762
## [1891] -0.0156086292 -0.3957462325  2.7026675526  0.0535459059 -0.5627817436
## [1896] -1.2213345415  0.6844751450 -0.9586764873 -0.1307984525 -0.7088506655
## [1901] -0.9750545956 -1.1752416313  1.8908295407 -0.5432070732  0.7834477515
## [1906] -1.0794313260  1.4228225948  0.1202160780  0.9972790880 -0.7525755790
## [1911] -1.4346357084  1.5868646322 -0.5877230540 -0.2238979706  1.3140325123
## [1916]  1.5763920917  0.1398408928 -0.7787316443 -0.4813854959 -0.8981857342
## [1921]  0.7700622352  1.0739152894  3.4001721382  0.8504696755  0.9007714596
## [1926] -0.9269742244 -0.9301040752 -1.4076419620  3.6743948868  0.0377710130
## [1931] -0.8932391209  0.3575699630 -0.0561910068  0.4150976642  3.5229680246
## [1936] -1.0302264428 -0.7631558750  0.1243176776 -0.8116785192 -1.2483313710
## [1941]  0.8730319354  2.0999968390  0.6364411300  0.2392219396  1.7947583333
## [1946] -0.8370854980 -1.7665231241 -0.1648582817 -0.9608134698  1.0103580345
## [1951]  1.6708540548  0.6239844145  2.0312490380 -1.7586184260  0.9006374623
## [1956]  1.8868451637 -0.6087929645  1.2042602608 -0.4154374533 -1.3474599812
## [1961]  0.9367723971 -0.8758894494  0.5837495547  0.2974152874  0.2080771686
## [1966] -0.8633150031  0.0267737597  0.6454982689 -0.5096337156 -0.9405230276
## [1971]  1.1157209589 -0.9758325631 -0.4461822209  0.7792392493  0.0662771334
## [1976] -0.7158106381  0.5287045831  0.6176226718  1.2320158569 -1.0301827839
## [1981]  2.2244385009  0.0800669457 -0.5688217365 -1.1113735227 -0.6759817621
## [1986]  0.5523393223 -0.4411002827  0.5225479917  0.3513106328 -1.1872338132
## [1991]  1.2678116650  0.7384781098 -1.0265498673 -0.9095973112 -0.9299411200
## [1996]  0.1473022639  0.3577869792 -0.0150946672 -1.4102547128 -0.5955658308
## [2001]  9.6496000790 -1.1391641802 -1.2208287158 -0.6682415346 -0.5128298245
## [2006] -0.7384632868  0.7675174029  1.2617719087 -0.6719751836 -0.0585191057
## [2011]  1.2978368548 -0.2300606157 -1.0092414855 -0.8904910000  0.1817825555
## [2016] -0.2224371297  1.4716492819  4.8123843752 -1.2449420964  1.7273808673
## [2021] -0.4561595365 -0.7989671694  4.3658150186  0.5299839211  2.4584632309
## [2026] -0.4685079073  1.4457913329 -0.7727603692 -0.8633558302 -0.5442983251
## [2031]  1.3455871779  0.1512880572 -1.3654535948  1.1741031795 -0.6583807573
## [2036] -0.4906169317 -0.7964484037 -0.1979680255  1.4413236519  0.9856012584
## [2041]  6.2926702423 -0.9608873993 -0.2415122196 -0.8666291938 -0.9447260857
## [2046]  2.6732327735 -0.3611789499 -0.5577278273  0.9516054275 -0.6765232527
## [2051]  0.4961498484 -1.3391416071 -0.9485773572 -0.9135691909  3.7779462857
## [2056]  1.0904883562 -0.8795989844  2.1650403934 -0.3169674713  3.3667968000
## [2061]  2.2494912732  0.2148354134  1.6756548638 -0.8429016234  0.5031887444
## [2066] -0.5293782001  0.7957556465 -1.0556369483 -0.5884095043 -0.9416969207
## [2071]  0.2262848494 -0.8378319932 -0.0344363240 -1.4533955396  0.8944455431
## [2076]  0.0972571346 -1.3387172051 -0.3518918150  1.3686442406 -0.7195861207
## [2081] -1.2306294591  1.3285904151  2.1132348265 -0.6225147077 -0.7078373770
## [2086] -0.4300612207 -0.3706284899 -1.9148658356 -0.9247710522  1.5935305161
## [2091]  0.6112324399  0.1708773778  1.2015991389  0.4387335091 -0.9430070792
## [2096] -0.9633531490  0.2508218358 -0.8632749319 -1.3628655061 -0.2410338520
## [2101] -1.3234614412  0.9257716727 -0.6867550013 -0.5511243711 -0.7962061186
## [2106] -1.1446291825 -1.4287831555 -0.5836867124 -1.0302264428  1.6480605898
## [2111]  2.0571597669 -1.4738499455 -0.9332168669 -1.8653966899 -0.1192663992
## [2116]  0.0774790765  0.2783084824 -1.3440694669  1.0879278541  1.2266178770
## [2121]  0.8937568384 -0.3998983574 -1.4917063903  0.0845914536  1.1519503551
## [2126] -1.5941698930 -1.3001455091 -0.8369984094  4.6095161900  2.2421139831
## [2131] -0.0815054759  0.9868763955  1.8992807737 -0.8462443942  1.9771135042
## [2136] -0.9460946113  1.0242578949  0.0614410760  0.9541498310  1.1667460583
## [2141]  2.1133759578  2.5202059570  0.1576926830 -1.2177494111 -1.0496900607
## [2146] -1.0967603276 -0.3840858052  0.5687785932  0.5990442468  3.3590380920
## [2151]  1.9138220984 -0.1952382826 -1.1102242815  1.8708841782  0.3572713901
## [2156]  3.0342847950 -0.4737203498  1.2413691948  1.7949737271 -0.4888400168
## [2161] -1.3253860755 -0.0907393056 -0.9823056189  2.0229155913 -0.5379315098
## [2166]  5.0658304154  0.6079970691 -0.5409684751 -0.3078997484  1.3762383337
## [2171] -0.9406526748 -0.4348121583 -0.5735352663  0.4024531409  0.9973160351
## [2176] -0.3486675025  0.3874791474 -1.8135668247  1.8133963306 -0.9755101216
## [2181]  1.6676438064 -0.9755536238  1.8655320988 -0.3684527056  0.3669876642
## [2186] -0.7234299078  4.2542232994  1.9941224349  1.4505985647 -0.5388018474
## [2191]  0.1821752303  0.4096574675  1.5512963707 -0.6627951274  1.8305362460
## [2196]  2.5707034683 -0.2064858251 -0.7515998461 -0.6628952293 -1.3548554499
## [2201]  0.8036022248 -1.4379243344 -1.0300302743  1.7478889255  0.1887599111
## [2206] -1.2032904139  0.2939767256  0.1333710479  0.8377591396  0.2173548083
## [2211] -1.5535756836 -1.5135974818  1.7181322149 -1.4457971866  0.1534245827
## [2216]  0.4940387247 -0.9203001570 -1.3621983880 -1.1302590835 -0.5939370560
## [2221] -0.3344347318 -0.2470251373 -0.3910405164  1.6084664121  0.7058694546
## [2226] -0.1822881314  1.3259182597 -0.4352330460  3.1806697885  0.4289708820
## [2231]  1.1108384736 -0.3719936602 -0.4543366835  2.8498025143 -1.0522246215
## [2236]  2.0431130829  0.3916258250 -0.7572038970 -0.0134151445  0.3400204168
## [2241] -1.1348007689 -0.9851557962 -1.1937706042 -0.3303735798 -1.2663720047
## [2246] -0.1684672134  1.1626759354  0.2564600556 -0.4406514101 -1.4960218145
## [2251]  0.7655728656  0.3250687547 -0.8930174070 -0.4653121677 -0.9564253785
## [2256]  0.2783982848  0.9929413639 -1.0947815452  0.8127811231 -0.7964160859
## [2261] -1.1124487343 -0.0880570183  0.4146668309  1.5992601874 -0.2296563272
## [2266] -1.7015492801  1.9892274376  0.2182116443 -1.4663693172  0.3063753336
## [2271]  1.1292921137 -0.2908463184  0.5270698602 -0.3758483787  0.4740951474
## [2276]  0.3796327343 -1.3630388429 -0.6760639446 -1.1355962484 -0.3267333077
## [2281] -1.4338025361  0.5727845129 -1.2449991680 -0.5802055733 -0.9758913866
## [2286] -1.3803928359 -1.0844761629 -0.0190491798 -0.4672612048 -0.7052721339
## [2291] -0.2199376438 -0.8930196190  1.9427379951  1.2246178656 -0.0987521336
## [2296]  1.7701128792 -1.0294023506  2.4155730739  0.6155347014 -0.5429174186
## [2301]  0.1926751346 -1.6227906993 -1.1521697241 -1.5452163774 -0.7046532109
## [2306] -1.0988623206  0.2295401136  0.6928490086 -0.7964529917 -0.7057493721
## [2311]  0.1151154175 -0.6179275256  1.1732506453 -0.8631592507 -1.2970334730
## [2316]  2.8515012103 -0.5166516452  0.2898170230 -0.6485604025  5.9829039024
## [2321] -0.5126505986  1.9083773554  0.9652696704 -1.5347168688 -1.2835410075
## [2326] -0.9968523203 -1.4658703483  0.9806366625 -0.7252526913 -1.0707749573
## [2331] -0.3622375378  1.3763350815  1.9024310491  0.6409849078 -0.9634781977
## [2336]  0.5797398937 -1.6690149262 -0.3949843745  1.7179972794 -0.3081107914
## [2341]  0.5244347838 -1.1258605057 -1.1890691194  1.5709921887  0.1858014242
## [2346]  2.3415017062 -1.6226012440  1.2398767097  1.5140678341 -0.4846789663
## [2351]  1.2861166244 -0.4850802128 -0.0351984426 -0.3478082832 -1.0537194610
## [2356] -0.5159331735 -0.8215038670  0.6368748392  0.4096018521  0.1689155637
## [2361] -1.3604678808 -0.3680980356  1.3302124931 -0.0688199972 -0.1582320278
## [2366]  0.3127894699 -1.6185975508 -1.5105880276  0.4275575821  2.0468900343
## [2371] -0.4553424269  1.4451875081  0.3191899120  1.3298037588 -0.1165194188
## [2376] -0.9191287116  0.5687464105  0.7289992700  1.9473243905  0.3276560881
## [2381]  0.5530088013 -0.3419148343  0.1100226686  0.5607813439  1.0609230783
## [2386] -0.2606211008  1.0094467389 -0.3242897043 -0.4797790120  4.4370155626
## [2391] -0.3389831576 -0.0465675959  5.3325091818 -0.3948626792 -0.4385471582
## [2396] -0.4215585390 -0.1352500560 -0.7299010033 -0.2108900564 -0.2062905624
## [2401]  2.1311162235  0.4924053111 -0.5960870983 -0.8214459904 -0.2735282568
## [2406]  0.7620603483 -0.8722339897  2.7808446088  4.7547911232  1.4007255497
## [2411] -1.3947048627  0.5758075426  1.5283346127 -0.6849254719 -0.3759550677
## [2416] -1.0899956349  1.6561529122  0.3105213857  0.0385405683 -0.4084748946
## [2421] -1.2492075711 -0.8965308331 -0.6576196465  5.4007798347  1.5825412455
## [2426] -0.2101824971  1.2651910384 -0.6624312022 -0.5506761265 -0.8629157484
## [2431]  0.4519680129  0.0800659379 -1.2208287158 -0.5413752097 -0.0845712713
## [2436] -0.7461826180 -0.7876257574  4.3829439738 -0.5961197411  1.5005128978
## [2441]  0.0104516790  0.0916768092 -0.0436654510 -0.0911979001  0.6962442894
## [2446] -0.1414435960  1.5411631955  0.0329264083 -0.1015460396  0.6456601611
## [2451]  1.7107599750  2.0222325994 -1.3405365190 -0.8091886780  1.5988177766
## [2456]  2.0682411074 -0.0237654045 -0.7829377405 -0.4423293792  2.3938626039
## [2461] -0.5312469498  4.1673428973  1.2432707017 -0.1007660378  0.3056553494
## [2466]  2.1361094693 -0.5275879807  0.3955521187  0.1274028823 -0.8663059810
## [2471] -0.8931458155 -0.9500853144  3.6823657694  0.3603161393 -0.3957462325
## [2476]  0.8479092233  2.2045776816  5.3714061274 -0.7826042851  0.4068023245
## [2481]  1.8227159581  0.5246856232 -0.4016678557  0.1400977291 -0.6531200206
## [2486] -0.6774559112  0.1553246292 -0.0097558606 -0.2915721752 -0.8601949470
## [2491] -0.6877583753  0.0109448340  2.4058563034  5.8566974852 -0.7519316334
## [2496]  3.8173222222  1.0948324086  1.1399596219  0.1511798310 -0.7136548570
## [2501] -0.4930379836 -0.7043903073 -0.3420053941 -0.6070582839  2.8951761498
## [2506]  0.4034428322 -0.3075734926 -0.6178544869 -0.1579022942  0.1366831793
## [2511]  1.4444550079 -1.5991823637 -0.4592436785 -0.2881400855  2.2064576573
## [2516] -0.3900545546 -1.5044824747  1.3121915727 -0.7572955837  1.1007880014
## [2521] -0.2398699441 -1.7335293056 -0.1720136647 -0.2863192267  3.9057150252
## [2526] -0.8394198026  1.1023426770  1.4808153173  0.1406523007 -0.8392551419
## [2531] -1.7978484227 -1.0629192871 -0.8934317115  0.0265783606  3.8320104450
## [2536]  0.3926607922  1.4930260570 -0.2555224710  1.2184275592  0.7224560067
## [2541] -1.0302264428  0.1363787581  0.4137940234 -0.5094316085 -1.3336753549
## [2546]  0.0328946471 -0.8461524554 -1.3419572862 -1.2417862548 -0.2669459434
## [2551] -0.3068754199
## 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  0.41458508 -3.364872e-03 0.313616428  0.7463196    0.455474348
## 2  0.27182263 -2.806463e-04 0.041837357  1.3303063    0.183417370
## 3 -0.50986262 -3.467603e-04 0.036512489 -2.6664718    0.007665205
## 4 -0.29923310 -2.215186e-04 0.051159294 -1.3219826    0.186173942
## 5 -0.06494364 -2.119679e-05 0.004139794 -1.0090333    0.312958659
## 6  0.22865530 -3.221135e-05 0.004534472  3.3960891    0.000683561

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"   "yellow" "gray"   "gray"
head(CORES.5[Q])
## [1] "gray"   "gray"   "yellow" "gray"   "gray"   "blue"
#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"))