Wrapper function to calculate global and local Moran's I by discrete area.
Usage
moran_stats(
dat,
project,
varofint,
zoneid,
spat,
cat,
lon.dat = NULL,
lat.dat = NULL,
lon.spat = NULL,
lat.spat = NULL
)Arguments
- dat
Primary data containing information on hauls or trips. Table in FishSET database contains the string 'MaindataTable'.
- project
String, name of project.
- varofint
Numeric variable from
datto test for spatial autocorrelation.- zoneid
Variable in
datthat identifies the individual zones or areas. Define if exists indatand is not named `ZoneID`. Defaults to NULL.- spat
Spatial data containing information on fishery management or regulatory zones. Shape, json, geojson, and csv formats are supported.
- cat
Variable or list in
spatthat identifies the individual areas or zones. Ifspatis class sf,catshould be name of list containing information on zones.- lon.dat
Longitude variable from
dat.- lat.dat
Latitude variable from
dat.- lon.spat
Variable or list from
spatcontaining longitude data. Required for csv files. Leave as NULL ifspatis a shape or json file.- lat.spat
Variable or list from
spatcontaining latitude data. Required for csv files. Leave as NULL ifspatis a shape or json file.
Details
Measure degree of spatial autocorrelation. Function utilizes the
localmoran and knearneigh functions
from the spdep package. The spatial input is a row-standardized spatial
weights matrix for computed nearest neighbor matrix, which is the null setting
for the nb2listw function. The function requires a map
file with lat/lon defining boundaries of area/zones and varofint for
to test for spatial autocorrelation. If zonal centroid is not included in the
map file, then the find_centroid function is called to calculate
the centroid of each zone. If the variable of interest is not associated with an
area/zone then assignment_column is called to assign each observation
to a zone. Arguments to identify centroid and assign variable of interest to
area/zone are optional and default to NULL.
