KM Wambui/E Musenge/Zvifadzo Matsena-Zingoni
.shp - This contains all of the actual lat/lon locations of each point that goes into your vector data set
.dbf - The data attached to each point. If you want to see what’s there you can open this type of file in excel–however, look but do not touch; NEVER change any of the actual data by hand if you do this; despite appearances, this is not a .csv under the hood, and it’s very possible you will be very sad that you have corrupted your file if you do this.
.prj- This simple text file contains a string that describes what spatial projection your data is presented in.*This may or may not exist, but hopefully it does, or you’ll need to figure out via research or guesswork what the projection information was before you analyze it.
.shx- Shapefiles break without this one (.shp, .shx, and .dbf are the only requried extensions), and it deals with spatial indexing, but there’s no reason you need to interface with this in R.
most of the programatic ways of manipulating spatial data depend on the GDAL (Geospatial Data Analysis Library) and GEOS (Geometry Engine- Open Source) libraries
1 Non-spatial model
My House Value is a function of my home Gardening Investment.
SAR model
My House Value is a function of the House Values of my neighbours.
is more suitable where there are second order dependency or a more global spatial autocorrelation
CAR model
My House Value is a function of the Gardening Investment of my neighbours
first order dependency or relatively local spatial autocorrelation
## load the packages needed for this module
library(R2OpenBUGS) ## Help in connecting R to OpenBugs
library(tidyverse) ## package for data manipulation
library(rgeos) ## Geomegry Engine- Open Source (GEOS)
library(maptools) ## R package with useful map tools
library(broom) ## for converting a map to a data frame
library(rgdal) ## Geospatial Data Analysis Library (GDAL)"
library(rgeos) # # "Geomegry Engine- Open Source (GEOS)" -- check your shape file
library(mcmc)
library(spdep)
library(data.table)
library(haven) ## read in stata files
library("PerformanceAnalytics") ## EDA
library(INLA) ## inla
library("coda")## install many packages at a go
packagesLoad <- c("R2OpenBUGS", "tidyverse", "rgeos", "maptools", "broom", "rgdal",
"rgeos", "mcmc", "spdep", "data.table", "haven", "PerformanceAnalytics")
for (i in 1:length(packagesLoad)) {
if (require(packagesLoad[i], character.only = TRUE) == FALSE) {
install.packages(packagesLoad[i])
}
}
## install INLA for later
install.packages("INLA", repos = c(getOption("repos"), INLA = "https://inla.r-inla-download.org/R/stable"),
dep = TRUE)rm(list = ls())