The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
which was just loaded, will retire in October 2023.
Please refer to R-spatial evolution reports for details, especially
https://r-spatial.org/r/2023/05/15/evolution4.html.
It may be desirable to make the sf package available;
package maintainers should consider adding sf to Suggests:.
The sp package is now running under evolution status 2
(status 2 uses the sf package in place of rgdal)
Loading required package: leaflet
Loading required package: Matrix
5.2 Shapefile
# Pacoteslibrary(sf)
Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
library(sp)# Abra o arquivo 'gm10.shp'brmicro.shp <-st_read("data/br_micro.shp", options ="ENCODING=WINDOWS-1252")
options: ENCODING=WINDOWS-1252
Reading layer `br_micro' from data source
`/home/raphael/projects/ecoespacial/data/br_micro.shp' using driver `ESRI Shapefile'
Simple feature collection with 558 features and 5 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -73.99095 ymin: -33.75086 xmax: -32.37889 ymax: 5.272225
CRS: NA
brmicro.shp <-st_make_valid(brmicro.shp)brmicro.shp <-as_Spatial(brmicro.shp)# Plotar o mapaplot(brmicro.shp)
5.3 Dados
dados <-read.csv2("data/Dados_GWR.csv", header =TRUE)str(dados)
'data.frame': 558 obs. of 17 variables:
$ ID : int 110001 110002 110003 110004 110005 110006 110007 110008 120001 120002 ...
$ X_COORD: num -64.5 -63.8 -62.6 -62.5 -62.8 ...
$ Y_COORD: num -9.42 -11.68 -9.53 -10.54 -11.67 ...
$ P9303 : num -0.0492 0.0584 0.2066 0.0747 0.157 ...
$ Q9303 : num 0.881 0.148 0.195 -0.627 0.366 ...
$ P93 : num 8.3 4.64 2.54 3.1 1.82 ...
$ G0 : num 0 0.44 0.694 0.626 0.781 ...
$ CT9303 : num 1.91 1.71 1.66 2.21 3.08 ...
$ CI9303 : num 1.147 2.03 -1.385 -0.294 1.647 ...
$ CC9303 : num 1.206 -0.165 1.662 1.975 2.734 ...
$ WP9303 : num 0.2632 0.0802 0.1186 0.0738 0.0905 ...
$ WQ9303 : num 0.853 0.146 1.075 0.42 -0.171 ...
$ WP93 : num 3.79 3.54 3.96 2.65 2.89 ...
$ WG0 : num 0.409 0.544 0.372 0.546 0.612 ...
$ WCT9303: num 1.62 2.49 1.15 2.08 2.23 ...
$ WCI9303: num -0.817 0.809 0.718 1.654 0.824 ...
$ WCC9303: num 1.64 2.09 1.02 1.33 1.42 ...
5.4 Especificação
Q9303 : Taxa de crescimento da produção agrícola microrregional no período de 1993 a 2003
P9303: Taxa de crescimento da produtividade da terra no período de 1993 a 2003
G0: medida de gap tecnológico
CI9303: taxa de crescimento do crédito para investimento agrícola no período de 1993 a 2003.
esp <- Q9303 ~ P9303 + G0 + CI9303
5.5 Modelo OLS
mod1 <-lm(formula = esp, data = dados)summary(mod1)
Call:
lm(formula = esp, data = dados)
Residuals:
Min 1Q Median 3Q Max
-8.2571 -0.3653 -0.0417 0.2531 12.1204
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.255015 0.054681 4.664 3.9e-06 ***
P9303 1.692115 0.124878 13.550 < 2e-16 ***
G0 0.041733 0.033751 1.236 0.217
CI9303 -0.002689 0.019658 -0.137 0.891
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.9564 on 554 degrees of freedom
Multiple R-squared: 0.2672, Adjusted R-squared: 0.2632
F-statistic: 67.33 on 3 and 554 DF, p-value: < 2.2e-16
Saiba mais em: https://cran.r-project.org/web/packages/mgwrsar/vignettes/mgwrsar-basic_examples.html
5.10 Usando o pacote spgwr
library(spgwr)
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')`
NOTE: This package does not constitute approval of GWR
as a method of spatial analysis; see example(gwr)