diff --git a/DESCRIPTION b/DESCRIPTION index f3111b5..8f203cb 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: spmodel Title: Spatial Statistical Modeling and Prediction -Version: 0.11.0 +Version: 0.11.1 Authors@R: c( person(given = "Michael", family = "Dumelle", diff --git a/NEWS.md b/NEWS.md index 3b0956c..02cfd15 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,15 @@ +# spmodel 0.11.1 + +## Minor Updates + +* Added a warning message when `splm()` or `spglm()` converts a non-`POINT` geometry to a `POINT` geometry using `sf::st_centroid()`. +* Updated a warning message when `splm()` or `spglm()` compute distances using a geographic coordinate system (and not a projected coordinate system). + +## Bug Fixes + +* Fixed a bug in the cloud semivariogram (i.e., `esv(..., cloud = TRUE)`) that incorrectly doubled the semivariance. +* Fix `\textbf`, `\textsf`, and `\textttt` LaTeX rendering issues in vignettes ([#36](https://github.com/USEPA/spmodel/issues/36)). + # spmodel 0.11.0 ## Major Updates diff --git a/R/get_data_object.R b/R/get_data_object.R index f19f5b8..8d319de 100644 --- a/R/get_data_object.R +++ b/R/get_data_object.R @@ -17,6 +17,9 @@ get_data_object_splm <- function(formula, data, spcov_initial, xcoord, ycoord, e is_sf <- TRUE sf_column_name <- attributes(data)$sf_column crs <- attributes(data[[sf_column_name]])$crs + if (!inherits(spcov_initial, c("none", "ie")) && any(sf::st_geometry_type(data) != "POINT")) { + warning("At least one geometry type in data is not equal to \"POINT\". Attempting to coerce all non-\"POINT\" geometries to \"POINT\" geometries via their centroids using sf::st_centroid().", call. = FALSE) + } data_sf <- suppressWarnings(sf::st_centroid(data)) # store as data frame data <- sf_to_df(data_sf) @@ -93,13 +96,12 @@ get_data_object_splm <- function(formula, data, spcov_initial, xcoord, ycoord, e # check if coordinates are projected if (is_sf) { if (!is.na(st_is_longlat(crs)) && st_is_longlat(crs)) { - warning("Coordinates are in a geographic coordinate system. For the most accurate results, please ensure - coordinates are in a projected coordinate system (e.g., via sf::st_transform()).", call. = FALSE) + warning("Coordinates are in a geographic coordinate system and will be used as is. For the most accurate results, please ensure coordinates are in a projected coordinate system (e.g., via sf::st_transform()).", call. = FALSE) } } else { # possible revisit this later and add explicit warning # if (any(abs(c(data[[xcoord]], data[[ycoord]])) <= 360)) { - # warning("Coordinates may be in a geographic coordinate system. For the most accurate results, please ensure + # warning("Coordinates may be in a geographic coordinate system and will be used as is. For the most accurate results, please ensure # coordinates are in a projected coordinate system (e.g., via sf::st_transform()).", call. = FALSE) # } } diff --git a/R/get_data_object_glm.R b/R/get_data_object_glm.R index bae24a0..f8b405f 100644 --- a/R/get_data_object_glm.R +++ b/R/get_data_object_glm.R @@ -18,6 +18,9 @@ get_data_object_spglm <- function(formula, family, data, spcov_initial, xcoord, is_sf <- TRUE sf_column_name <- attributes(data)$sf_column crs <- attributes(data[[sf_column_name]])$crs + if (!inherits(spcov_initial, c("none", "ie")) && any(sf::st_geometry_type(data) != "POINT")) { + warning("At least one geometry type in data is not equal to \"POINT\". Attempting to coerce all non-\"POINT\" geometries to \"POINT\" geometries via their centroids using sf::st_centroid().", call. = FALSE) + } data_sf <- suppressWarnings(sf::st_centroid(data)) # store as data frame data <- sf_to_df(data_sf) @@ -94,13 +97,12 @@ get_data_object_spglm <- function(formula, family, data, spcov_initial, xcoord, # check if coordinates are projected if (is_sf) { if (!is.na(st_is_longlat(crs)) && st_is_longlat(crs)) { - warning("Coordinates are in a geographic coordinate system. For the most accurate results, please ensure - coordinates are in a projected coordinate system (e.g., via sf::st_transform()).", call. = FALSE) + warning("Coordinates are in a geographic coordinate system and will be used as is. For the most accurate results, please ensure coordinates are in a projected coordinate system (e.g., via sf::st_transform()).", call. = FALSE) } } else { # possible revisit this later and add explicit warning # if (any(abs(c(data[[xcoord]], data[[ycoord]])) <= 360)) { - # warning("Coordinates may be in a geographic coordinate system. For the most accurate results, please ensure + # warning("Coordinates may be in a geographic coordinate system and will be used as is. For the most accurate results, please ensure # coordinates are in a projected coordinate system (e.g., via sf::st_transform()).", call. = FALSE) # } } diff --git a/R/get_esv.R b/R/get_esv.R index 23aec32..6ad4f78 100644 --- a/R/get_esv.R +++ b/R/get_esv.R @@ -64,7 +64,7 @@ get_esv_robust <- function(residual_vector12, dist_vector, bins, cutoff, formula get_esv_cloud <- function(residual_vector2, dist_vector, formula) { - esv_out <- tibble::tibble(dist = dist_vector, gamma = residual_vector2) + esv_out <- tibble::tibble(dist = dist_vector, gamma = residual_vector2 / 2) # set row names to NULL # row.names(esv_out) <- NULL diff --git a/R/sf_to_df.R b/R/sf_to_df.R index b246f95..f596b1d 100644 --- a/R/sf_to_df.R +++ b/R/sf_to_df.R @@ -1,7 +1,7 @@ #' Turn an \code{sf} object into a data frame #' #' @param data An \code{sf} object with all \code{POINT} geometries or geometries -#' coercible to \code{POINT} geometries via sf::st_centriod(). +#' coercible to \code{POINT} geometries via sf::st_centroid(). #' #' @return A data frame with coordinates added as columns #' diff --git a/docs/404.html b/docs/404.html index a689570..75f8099 100644 --- a/docs/404.html +++ b/docs/404.html @@ -39,7 +39,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/LICENSE.html b/docs/LICENSE.html index b99ee70..7b9ff1d 100644 --- a/docs/LICENSE.html +++ b/docs/LICENSE.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/articles/SPGLMs.html b/docs/articles/SPGLMs.html index 00c0904..d2ebaea 100644 --- a/docs/articles/SPGLMs.html +++ b/docs/articles/SPGLMs.html @@ -40,7 +40,7 @@ spmodel - 0.11.0 + 0.11.1 @@ -116,9 +116,9 @@

Michael

Introduction

-

spmodel is an package used to fit, summarize, and -predict for a variety of spatial statistical models. The vignette -provides an introduction spatial generalized linear models for +

spmodel is an R package used to fit, +summarize, and predict for a variety of spatial statistical models. The +vignette provides an introduction spatial generalized linear models for non-Gaussian response distributions in spmodel. Before proceeding, we load spmodel by running

@@ -309,9 +309,10 @@ 

The Spatial Generalized Linear Mod (2024) provide the methodology’s full details.

spmodel accommodates the binomial, beta, Poisson, negative binomial, gamma, and inverse Gaussian distributions. The -binomial and beta response distributions (specified by ) use the logit -link, while the Poisson, negative binomial, gamma, and inverse Gaussian -distributions use the log link – see the following table.

+binomial and beta response distributions (specified by +family) use the logit link, while the Poisson, negative +binomial, gamma, and inverse Gaussian distributions use the log link – +see the following table.

Spatial generalized linear model response distributions available in spmodel alongside their corresponding link functions and @@ -377,29 +378,37 @@

The Spatial Generalized Linear Mod

Model fitting

Spatial generalized linear models in spmodel are fit -using (for point-referenced data) or (for areal data). These functions -are similar in structure both to one another and to the function in base -R. They generally require the following four arguments: -, a formula that describes the relationship between the response and -explanatory variables; , the response distribution, which can be , , , , -, or ; , a or object (Pebesma 2018) whose -rows index observations and whose columns contain the response variable, -explanatory variables, and spatial information; and , one of 19 spatial +using spglm() (for point-referenced data) or +spgautor() (for areal data). These functions are similar in +structure both to one another and to the glm() function in +base R. They generally require the following four +arguments: formula, a formula that describes the +relationship between the response and explanatory variables; +family, the response distribution, which can be +binomial, beta, poisson, +nbinomial, Gamma, or +inverse.gaussian; data, a +data.frame or sf object (Pebesma 2018) whose rows index observations and +whose columns contain the response variable, explanatory variables, and +spatial information; and spcov_type, one of 19 spatial covariance types (e.g., spherical spatial covariance, Matérn spatial covariance, simultaneous-autoregressive spatial covariance etc.). The -binomial and beta response distributions (specified by ) use the logit -link, while the Poisson, negative binomial, gamma, and inverse Gaussian -distributions use the log link. Other arguments to and are either -required only in specific situations or have default values specified. -All arguments to the and functions are summarized in the following -table. Models for several hundred observations can take anywhere from a -few seconds to a few minutes to fit, depending on the shape of the +binomial and beta response distributions (specified by +family) use the logit link, while the Poisson, negative +binomial, gamma, and inverse Gaussian distributions use the log link. +Other arguments to spglm() and spgautor() are +either required only in specific situations or have default values +specified. All arguments to the spglm() and +spgautor() functions are summarized in the following table. +Models for several hundred observations can take anywhere from a few +seconds to a few minutes to fit, depending on the shape of the likelihood surface and how quickly the covariance parameters converge. Models for several thousand observations can utilize spmodel’s large data set options.

-@@ -413,103 +422,103 @@

Model fitting -

+ - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + - + - + - + - + - + @@ -523,12 +532,13 @@

Model evaluation and diagnosticsspmodel that are used for these purposes, and their main argument is the fitted model -object returned by or . The names of these functions are meant to be -illustrative, describing the purpose of the function itself. The -functions for evaluating model fit (see below) return likelihood-based -statistics like AIC, AICc, BIC, and deviance (McCullagh and Nelder 1989), return coefficient -estimates and confidence intervals, perform cross validation, and -more.

+object returned by
spglm() or spgautor(). The +names of these functions are meant to be illustrative, describing the +purpose of the function itself. The functions for evaluating model fit +(see below) return likelihood-based statistics like AIC, AICc, BIC, and +deviance (McCullagh and Nelder 1989), +return coefficient estimates and confidence intervals, perform cross +validation, and more.

Arguments to spglm() and spgautor(), their purpose, and whether -the argument applies to both spglm() and spgautor() or just one of +Arguments to spglm() and spgautor(), +their purpose, and whether the argument applies to both +spglm() and spgautor() or just one of them.
\(\texttt{formula}\)formula Fixed effects formula Both
\(\texttt{family}\)family Response distribution Both
\(\texttt{data}\)Data Frame or objectdataData Frame or sf object Both
\(\texttt{spcov_type}\)spcov_type Spatial covariance type Both
\(\texttt{spcov_initial}\)spcov_initial Initial or known spatial covariance parameters Both
\(\texttt{dispersion_initial}\)dispersion_initial Initial or known dispersion parameter Both
\(\texttt{estmethod}\)estmethod Estimation method Both
\(\texttt{random}\)random Random effects formula Both
\(\texttt{randcov_initial}\)randcov_initial Initial or known random effect variances Both
\(\texttt{partition_factor}\)partition_factor A partition factor formula Both
\(\texttt{...}\)... Additional arguments Both
\(\texttt{anisotropy}\)anisotropy Whether to model anisotropy\(\texttt{spglm()}\)spglm()
\(\texttt{xcoord}\)xcoord An x-coordinate name\(\texttt{spglm()}\)spglm()}
\(\texttt{ycoord}\)ycoord A y-coordinate name\(\texttt{spglm()}\)spglm()
\(\texttt{local}\)local Options for large data sets\(\texttt{spglm()}\)spglm()
\(\texttt{W}\)W A neighborhood weight matrix\(\texttt{spgautor()}\)spgautor()
\(\texttt{row_st}\)Whether to row-standardize \(\texttt{W}\) +row_stWhether to row-standardize W \(\texttt{spgautor()}\)spgautor()
\(\texttt{M}\)M A symmetry matrix\(\texttt{spgautor()}\)spgautor()
\(\texttt{range_positive}\)range_positive Whether the range parameter is restricted to be positive
\(\texttt{cutoff}\)cutoff Distance cutoff if using distance-based neighbor definition
@@ -543,73 +553,73 @@

Model evaluation and diagnostics

- + - + - + - + - + - + - + - + - + - + - + - + - + @@ -621,119 +631,122 @@

Model evaluation and diagnostics

---- - + - + +hatvalues(); - +
Model evaluation functions available for models fit using spglm() or spgautor() and their purpose.
-\(\texttt{AIC()}\); \(\texttt{AICc()}\) +AIC(); AICc() Return AIC and AICc
\(\texttt{anova()}\)anova() Perform an analysis of variance
\(\texttt{AUROC()}\)AUROC() Compute the area under the receiver operating characteristic curve
\(\texttt{BIC()}\)BIC() Return BIC
-\(\texttt{coef()}\); \(\texttt{coefficients()}\) +coef(); coefficients() Return parameter estimates
\(\texttt{confint()}\)confint() Return confidence intervals
\(\texttt{covmatrix()}\)covmatrix() Return the fitted covariance matrix
\(\texttt{deviance()}\)deviance() Return the deviance
-\(\texttt{glance()}\); \(\texttt{glances()}\) +glance(); glances() Glance at model fits
\(\texttt{logLik()}\)logLik() Return the log-likelihood
\(\texttt{loocv()}\)loocv() Perform leave-one-out cross validation
\(\texttt{pseudoR2()}\)pseudoR2() Return the pseudo R-squared
\(\texttt{summary()}\)summary() Summarize the fitted model
\(\texttt{tidy()}\)tidy() Tidy the fitted model
\(\texttt{varcomp()}\)varcomp() Compare sources of variability
\(\texttt{vcov()}\)vcov() Return variance-covariance matrices
Mode diagnostic functions available for models fit using spglm() or spgautor() and their purpose.
Function Purpose
\(\texttt{augment()}\)augment() Augment model data with diagnostics
\(\texttt{cooks.distance()}\)cooks.distance() Return Cook’s distances
-\(\texttt{fitted()}\); \(\texttt{fitted.values()}\) +fitted(); fitted.values() Return fitted values
-\(\texttt{hatvalues()}\); Return hat (leverage) values
\(\texttt{plot()}\)plot() Plot model diagnostics
-\(\texttt{residuals()}\); \(\texttt{resid()}\); \(\texttt{rstandard()}\) +residuals(); resid(); +rstandard() Return residuals
-

The functions , , and , popularized by the broom +

The functions tidy(), glance(), and +augment(), popularized by the broom R package (Robinson, Hayes, and -Couch 2021), are particularly useful. The function tidies -parameter estimate output, returning a special called a (Müller and Wickham 2021) that is much easier to +Couch 2021), are particularly useful. The tidy() +function tidies parameter estimate output, returning a special +data.frame called a tibble (Müller and Wickham 2021) that is much easier to manipulate and work with than the parameter estimate output printed by -to the R console. The function glances at the model -fit, returning a with the sample size, number of estimated parameters, -and several model-fit statistics. is an extension of that glances at -multiple models simultaneously. The function augments the model fit, -returning a with the data used to fit the model as well as model -diagnostics. The function can also be used to augment prediction data, -as we discuss next.

+summary() to the R console. The +glance() function glances at the model fit, returning a +tibble with the sample size, number of estimated +parameters, and several model-fit statistics. glances() is +an extension of glance() that glances at multiple models +simultaneously. The augment() function augments the model +fit, returning a tibble with the data used to fit the model +as well as model diagnostics. The augment() function can +also be used to augment prediction data, as we discuss next.

Prediction

Often a priority of a spatial data analysis is using the fitted model to make predictions at unobserved locations and quantify uncertainties -in those predictions. The function in spmodel is used to -predict the mean process at unobserved locations. It is similar in -structure to for objects fit using in base R and takes -two main arguments: , the fitted model object returned by or ; and , a -or object whose rows index locations requiring prediction and whose -columns contain the explanatory variables and spatial information at -these locations. Other arguments to are either required only in specific -situations or have default values specified. All arguments to the -function are summarized in the following table. The function can also be -used to augment with predictions, taking the same arguments as .

+in those predictions. The predict() function in +spmodel is used to predict the mean process at unobserved +locations. It is similar in structure to predict() for +objects fit using glm() in base R and +takes two main arguments: object, the fitted model object +returned by spglm() or spgautor(); and +newdata, a data.frame or sf +object whose rows index locations requiring prediction and whose columns +contain the explanatory variables and spatial information at these +locations. Other arguments to predict() are either required +only in specific situations or have default values specified. All +arguments to the predict() function are summarized in the +following table. The augment() function can also be used to +augment newdata with predictions, taking the same arguments +as predict().

- ---- + - + - - + + - + - + - + - + - + - + - + @@ -747,9 +760,10 @@

Simulationrpois() is used to +simulate Poisson data in base R, while +sprpois() is used to simulate spatial Poisson data in spmodel. These functions are summarized in the following table.

Arguments to predict() and their purpose. Arguments to predict() and their +purpose.
Argument Purpose
\(\texttt{object}\)object Fitted model object
\(\texttt{newdata}\)New data frame or objectnewdataNew data frame or sf object
\(\texttt{type}\)type Whether predictions are on the link or response scale
\(\texttt{se.fit}\)se.fit Whether standard errors should be returned
\(\texttt{interval}\)interval Interval type (prediction or confidence)
\(\texttt{level}\)level Prediction or confidence level
\(\texttt{local}\)local Options for large data sets
\(\texttt{var_correct}\)var_correct Whether prediction variances should be adjusted
\(\texttt{...}\)... Additional arguments
@@ -760,31 +774,31 @@

Simulation -

+ - + - + - + - + - + - + @@ -796,21 +810,24 @@

An application to binary (presence/absence) data

In the next two sections we to show how to use spmodel to analyze data collected on moose in the Togiak region of Alaska, USA. -The data in spmodel contain information on moose counts -from a survey of sites in the Togiak region. The data are stored as an -sf object, a special built to store spatial data. has -several variables: ; a stratification variable with two levels ( for low -and for medium) based on surrounding landscape metrics; , the site -elevation; , whether or not at least one moose was observed at the site; -, the number of moose observed at a the site; and , the spatial -coordinates in an Alaska Albers projection (EPSG: 3338). We load -spmodel and the data by running

+The moose data in spmodel contain information +on moose counts from a survey of sites in the Togiak region. The data +are stored as an sf object, a special +data.frame built to store spatial data. moose +has several variables: strat; a stratification variable +with two levels (L for low and M for medium) +based on surrounding landscape metrics; elev, the site +elevation; presence, whether or not at least one moose was +observed at the site; count, the number of moose observed +at a the site; and geometry, the spatial coordinates in an +Alaska Albers projection (EPSG: 3338). We load spmodel and +the moose data by running

-

We are interested in quantifying the effects of and on moose and -begin with some visualizations. First, we visualize the presence for -observed sites:

+

We are interested in quantifying the effects of elev and +strat on moose presence and begin with some +visualizations. First, we visualize the presence for observed sites:

 ggplot(moose, aes(color = presence)) + 
   geom_sf(size = 2) + 
@@ -846,9 +863,9 @@ 

An application to binary (presence/absence) data eastern and southwestern parts of the domain. This spatial pattern seems to have a directional orientation, seemingly strongest in the northwest-to-southeast direction.

-

To quantify the effects of , , and spatial dependence on moose -presence, we fit three binomial (i.e., ) logistic regression models -using :

+

To quantify the effects of elev, strat, and +spatial dependence on moose presence, we fit three binomial (i.e., ) +logistic regression models using spglm():

 # model one
 bin_mod <- spglm(
@@ -874,13 +891,15 @@ 

An application to binary (presence/absence) data )

All three models have the same fixed effect structure, using elevation, strata, and their interaction to explain moose presence. The -three models vary in their covariance structure. The first model, , has -no spatial covariance (\(\sigma^2_{de} = -0\)). The second model, has a spherical spatial covariance. The -third model, , has a spherical spatial covariance that incorporates -geometric anisotropy. Geometric anisotropy allows the spatial covariance -to vary with direction by evaluating the spatial covariance with \(\mathbf{H}^*\) (instead of \(\mathbf{H}\)), a matrix of distances -between transformed coordinates that are rotated and scaled +three models vary in their covariance structure. The first model, +bin_mod, has no spatial covariance (\(\sigma^2_{de} = 0\)). The second model, +bin_spmod has a spherical spatial covariance. The third +model, bin_spmod_anis, has a spherical spatial covariance +that incorporates geometric anisotropy. Geometric anisotropy allows the +spatial covariance to vary with direction by evaluating the spatial +covariance with \(\mathbf{H}^*\) +(instead of \(\mathbf{H}\)), a matrix +of distances between transformed coordinates that are rotated and scaled appropriately (Schabenberger and Gotway 2017). We evaluate the three models using AIC by running

@@ -889,13 +908,16 @@ 

An application to binary (presence/absence) data #> bin_mod 0 717.1627 #> bin_spmod 3 686.9031 #> bin_spmod_anis 5 677.9403

-

The spatial models (, ) have a much lower AIC than the non-spatial -model (), which suggests that the models benefit from incorporating -spatial dependence. has a lower AIC than , which suggests that the model +

The spatial models (bin_spmod, +bin_spmod_anis) have a much lower AIC than the non-spatial +model (bin_mod), which suggests that the models benefit +from incorporating spatial dependence. bin_spmod_anis has a +lower AIC than bin_spmod, which suggests that the model benefits from incorporating directionality in the spatial dependence. -Next we inspect and later use it to predict moose presence probability -at unobserved sites.

-

We summarize using :

+Next we inspect bin_spmod_anis and later use it to predict +moose presence probability at unobserved sites.

+

We summarize bin_spmod_anis using +summary():

 summary(bin_spmod_anis)
#> 
@@ -927,22 +949,24 @@ 

An application to binary (presence/absence) data #> Coefficients (Dispersion for binomial family): #> dispersion #> 1

-

The output from an model is very similar to the output from a -base-R model, returning the original function call, -deviance residuals, a fixed effects coefficients table, a pseudo -R-squared (which quantifies the amount of variability explained by the -fixed effects), and covariance parameter coefficients. The fixed effects -coefficients table provides some evidence that elevation and strata are -associated with with moose presence and that the effect of elevation -varies across the two strata (all \(p~\)values \(<\) 0.05).

+

The summary() output from an spglm() model +is very similar to the summary() output from a +base-R glm() model, returning the original +function call, deviance residuals, a fixed effects coefficients table, a +pseudo R-squared (which quantifies the amount of variability explained +by the fixed effects), and covariance parameter coefficients. The fixed +effects coefficients table provides some evidence that elevation and +strata are associated with with moose presence and that the effect of +elevation varies across the two strata (all \(p~\)values \(<\) 0.05).

The area under the receiver receiver operating characteristic (AUROC) curve quantifies the effectiveness of a classifier (Robin et al. 2011). It ranges from zero to one, -and higher values indicate better model performance. The AUROC of is

+and higher values indicate better model performance. The AUROC of +bin_spmod_anis is

 AUROC(bin_spmod_anis)
#> [1] 0.9403199
-

The function returns graphics of several model diagnostics. -Running

+

The plot() function returns graphics of several model +diagnostics. Running

 plot(bin_spmod_anis, which = c(7, 8))
@@ -954,10 +978,9 @@

An application to binary (presence/absence) data

shows that the spatial dependence is evident and appears strongest in the northwest-to-southeast direction. These findings are supported by the clear spatial patterns in the data.

-

Recall that the , , and functions are particularly useful tools for -manipulating and understanding fitted model objects. The function tidies -model output, returning a of parameter estimates (and confidence -intervals):

+

Recall that the tidy(), glance(), and +augment() functions are particularly useful tools for manipulating and understanding fitted model objects. Thetidy()function tidies model output, returning atibble` +of parameter estimates (and confidence intervals):

 tidy(bin_spmod_anis, conf.int = TRUE)
#> # A tibble: 4 × 7
@@ -968,7 +991,8 @@ 

An application to binary (presence/absence) data #> 3 elev:stratM -0.0140 0.00693 -2.02 0.0432 -0.0276 -0.000431 #> 4 stratM 3.82 1.18 3.25 0.00116 1.52 6.13

By default, the fixed effects estimates are returned, but covariance -parameter estimates are returned via the argument:

+parameter estimates are returned via the effects +argument:

 tidy(bin_spmod_anis, effects = "spcov")
#> # A tibble: 5 × 3
@@ -979,19 +1003,20 @@ 

An application to binary (presence/absence) data #> 3 range 179082. FALSE #> 4 rotate 2.72 FALSE #> 5 scale 0.215 FALSE

-

The column indicates whether covariance parameters were assumed -known, which is possible to specify using the argument to . Here, all +

The is_known column indicates whether covariance +parameters were assumed known, which is possible to specify using the +spcov_initial argument to spglm(). Here, all parameters were assumed unknown and then estimated.

-

The function glances at model fit, returning a of model fit -statistics:

+

The glance() function glances at model fit, returning a +tibble of model fit statistics:

 glance(bin_spmod_anis)
#> # A tibble: 1 × 10
 #>       n     p  npar value   AIC  AICc   BIC logLik deviance pseudo.r.squared
 #>   <int> <dbl> <int> <dbl> <dbl> <dbl> <dbl>  <dbl>    <dbl>            <dbl>
 #> 1   218     4     5  668.  678.  678.  695.  -334.     161.            0.112
-

can be used to glance at multiple models simultaneously and sorts -models by ascending AICc:

+

glances() can be used to glance at multiple models +simultaneously and sorts models by ascending AICc:

 glances(bin_mod, bin_spmod, bin_spmod_anis)
#> # A tibble: 3 × 11
@@ -1001,7 +1026,8 @@ 

An application to binary (presence/absence) data #> 2 bin_spmod 218 4 3 681. 687. 687. 697. -340. 161. #> 3 bin_mod 218 4 0 717. 717. 717. 717. -359. 294. #> # ℹ 1 more variable: pseudo.r.squared <dbl>

-

The function augments the data with model diagnostics:

+

The augment() function augments the data with model +diagnostics:

 aug_mod <- augment(bin_spmod_anis)
 aug_mod
@@ -1025,14 +1051,18 @@

An application to binary (presence/absence) data #> 10 0 430. L -1.62 -0.600 0.0871 0.00941 -0.628 #> # ℹ 208 more rows #> # ℹ 1 more variable: geometry <POINT [m]>

-

where are fitted values (the estimated \(f^{-1}(\mathbf{w})\), or moose presence -probability), are response residuals, values indicate leverage, values -indicate Cook’s distance (i.e., influence), and are standardized -residuals.

-

The data contains survey sites that were not sampled. We can use to -make predictions of the underlying probabilities of moose presence at -these sites using or . and return the same predictions but augments the -prediction data with the predictions:

+

where .fitted are fitted values (the estimated \(f^{-1}(\mathbf{w})\), or moose presence +probability), .resid are response residuals, +.hat values indicate leverage, .cooksd values +indicate Cook’s distance (i.e., influence), and .std.resid +are standardized residuals.

+

The moose_preds data contains survey sites that were not +sampled. We can use bin_spmod_anis to make predictions of +the underlying probabilities of moose presence at these sites using +predict() or augment(). predict() +and augment() return the same predictions but +augment() augments the prediction data with the +predictions:

 data("moose_preds")
 
@@ -1077,9 +1107,11 @@ 

An application to binary (presence/absence) data #> 9 191 L 0.375 0.0410 0.893 (284453.8 1502837) #> 10 105. L 0.142 0.0197 0.577 (391343.9 1483791) #> # ℹ 90 more rows

-

Estimated moose presence probability for the data (obtained via ) and -predicted moose presence probability for the data (obtained via or ) are -overlain below and share similar patterns:

+

Estimated moose presence probability for the moose data +(obtained via fitted()) and predicted moose presence +probability for the moose_preds data (obtained via +predict() or augment()) are overlain below and +share similar patterns:

 aug_mod$type <- "mod"
 aug_pred$type <- "pred"
@@ -1098,7 +1130,8 @@ 

An application to binary (presence/absence) data

An application to count data

-

The data also contain the number of moose observed at each site:

+

The moose data also contain the number of moose observed +at each site:

 ggplot(moose, aes(color = count)) +
   geom_sf(size = 2) +
@@ -1115,13 +1148,14 @@ 

An application to count datacount, albeit using -a slightly different approach than we did for moose -presence. Here, we will model elevation as a fixed effect -and allow this effect to change between strata, but we will model strata -as a random effect to highlight additional flexibility of the -spmodel package. We fit relevant Poisson and negative -binomial models with a Matérn spatial covariance using :

+quantifying the effects of elev and strat on +moose count, albeit using a slightly different approach +than we did for moose presence. Here, we will model +elevation as a fixed effect and allow this effect to change between +strata, but we will model strata as a random effect to highlight +additional flexibility of the spmodel package. We fit +relevant Poisson and negative binomial models with a Matérn spatial +covariance using
spglm():

 count_mod_pois <- spglm(
   count ~ elev + elev:strat,
@@ -1138,22 +1172,25 @@ 

An application to count data spcov_type = "matern", random = ~ (1 | strat) )

-

Random effects are specified in spmodel via the argument -using similar syntax as the commonly used lme4 (Bates et al. 2015) and nlme (Pinheiro and Bates 2006) R -packages for non-spatial mixed models. In spmodel, is -short-hand for . Random effects alter the covariance structure of the -model, building additional correlation into the model for sites sharing -a level of the random effect (here, sites within the same strata). More -formally, when incorporating a random effect, the spatial generalized -linear model becomes \[\begin{equation}\label{eq:spglm-rand} +

Random effects are specified in spmodel via the +random argument using similar syntax as the commonly used +lme4 (Bates et al. 2015) and +nlme (Pinheiro and Bates +2006) R packages for non-spatial mixed models. +In spmodel, ~ strat is short-hand for +~ (1 | strat). Random effects alter the covariance +structure of the model, building additional correlation into the model +for sites sharing a level of the random effect (here, sites within the +same strata). More formally, when incorporating a random effect, the +spatial generalized linear model becomes \[\begin{equation}\label{eq:spglm-rand} f(\boldsymbol{\mu}) \equiv \mathbf{w} = \mathbf{X} \boldsymbol{\beta} + \mathbf{Z}\mathbf{v} + \boldsymbol{\tau} + \boldsymbol{\epsilon}, \end{equation}\] where \(\mathbf{Z}\) is a design matrix that indexes the random effects, \(\mathbf{v}\), and \(\text{Cov}(\mathbf{v}) = \sigma^2_{v}\mathbf{I}\). Then the covariance matrix, \(\boldsymbol{\Sigma}\), becomes \(\sigma^2_v \mathbf{Z} \mathbf{Z}^\top + \sigma^2_{de}\mathbf{R} + \sigma^2_{ie}\mathbf{I}\).

-

Previously we compared models using , but another way to compare -models is by leave-one-out cross validation (Hastie et al. 2009). In leave-one-out cross +

Previously we compared models using AIC(), but another +way to compare models is by leave-one-out cross validation (Hastie et al. 2009). In leave-one-out cross validation, each observation is held-out and the model is re-fit and used to predict the held-out observation. Then a loss statistic is computed that compares each prediction to its true value. We calculate @@ -1185,8 +1222,8 @@

An application to count data#> 1 (Intercept) -0.301 1.50 -0.200 0.841 #> 2 elev 0.00590 0.00300 1.96 0.0494 #> 3 elev:stratM -0.00717 0.00408 -1.76 0.0789

-

The function in spmodel apportions model variability -into fixed and random components:

+

The varcomp() function in spmodel +apportions model variability into fixed and random components:

 varcomp(count_mod_nb)
#> # A tibble: 4 × 2
@@ -1197,7 +1234,8 @@ 

An application to count data#> 3 ie 0.00174 #> 4 1 | strat 0.467

Most model variability is explained by the spatially dependent random -error () and the random effect for strata (). Running

+error (de) and the random effect for strata +(1 | strat). Running

 plot(count_mod_nb, which = c(4, 5))
@@ -1207,9 +1245,11 @@

An application to count data

shows observations of high influence or leverage and that the standardized residuals tend to be spread out around zero.

-

Estimated mean moose counts for the data (obtained via ) and -predicted mean moose counts for the data (obtained via or ) share -similar patterns and are overlain by running

+

Estimated mean moose counts for the moose data (obtained +via fitted()) and predicted mean moose counts for the +moose_preds data (obtained via predict() or +augment()) share similar patterns and are overlain by +running

 aug_mod <- augment(count_mod_nb)
 aug_pred <- augment(count_mod_nb, newdata = moose_preds, type.predict = "response")
@@ -1232,17 +1272,20 @@ 

Discussionglm() function, over a dozen spatial covariance functions, +a variety of tools available to evaluate models, inspect model +diagnostics, and make predictions using ubiquitous base +R functions (e.g., summary(), +plot(), and predict()) and more. Spatial +generalized linear models for point-referenced data (i.e., generalized +geostatistical models) are fit using the spglm() function. +Spatial generalized linear models for areal data (i.e., generalized +spatial autoregressive models) are fit using the spgautor() +function. Both functions share common structure and syntax. Spatial data +are simulated in spmodel by adding an sp +prefix to commonly used base R simulation functions +(e.g., sprbinom()).

We appreciate feedback from users regarding spmodel. To learn more about how to provide feedback or contribute to spmodel, please visit our GitHub repository at https://github.com/USEPA/spmodel.

diff --git a/docs/articles/block.html b/docs/articles/block.html index d5cc270..75a3637 100644 --- a/docs/articles/block.html +++ b/docs/articles/block.html @@ -40,7 +40,7 @@ spmodel - 0.11.0 + 0.11.1

@@ -116,12 +116,12 @@

Michael

Introduction

-

spmodel is a package used to fit, summarize, and predict -for a variety of spatial statistical models. This vignette explores -tools for predicting the average value of a response variable in a -particular geographic region, an approach known as Block Prediction -(i.e., Block Kriging) (Cressie 1993; Ver Hoef -2008). Before proceeding, we load spmodel, +

spmodel is a R package used to fit, +summarize, and predict for a variety of spatial statistical models. This +vignette explores tools for predicting the average value of a response +variable in a particular geographic region, an approach known as Block +Prediction (i.e., Block Kriging) (Cressie 1993; +Ver Hoef 2008). Before proceeding, we load spmodel, sf, and ggplot2 by running

 library(spmodel)
diff --git a/docs/articles/block_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/block_files/figure-html/unnamed-chunk-5-1.png
index c43fd3b..5893bbe 100644
Binary files a/docs/articles/block_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/block_files/figure-html/unnamed-chunk-5-1.png differ
diff --git a/docs/articles/emmeans.html b/docs/articles/emmeans.html
index 6df3d67..a1a5b73 100644
--- a/docs/articles/emmeans.html
+++ b/docs/articles/emmeans.html
@@ -40,7 +40,7 @@
       
       
         spmodel
-        0.11.0
+        0.11.1
       
     
@@ -116,10 +116,10 @@

Michael

Introduction

-

spmodel is an package used to fit, summarize, and -predict for a variety of spatial statistical models. The vignette -provides an estimating marginal means (i.e., least-squares means) of -spmodel objects using the emmeans. +

spmodel is an R package used to fit, +summarize, and predict for a variety of spatial statistical models. The +vignette provides an estimating marginal means (i.e., least-squares +means) of spmodel objects using the emmeans. R package (Lenth 2024). Before proceeding, we load spmodel and emmeans by running

diff --git a/docs/articles/emmeans_files/figure-html/log_cond-1.png b/docs/articles/emmeans_files/figure-html/log_cond-1.png index d93fd48..1d6480d 100644 Binary files a/docs/articles/emmeans_files/figure-html/log_cond-1.png and b/docs/articles/emmeans_files/figure-html/log_cond-1.png differ diff --git a/docs/articles/guide.html b/docs/articles/guide.html index 11790f4..73d2589 100644 --- a/docs/articles/guide.html +++ b/docs/articles/guide.html @@ -40,7 +40,7 @@ spmodel - 0.11.0 + 0.11.1
@@ -115,18 +115,19 @@

Michael

Introduction

-

spmodel is an package used to fit, summarize, and -predict for a variety of spatial statistical models. The vignette -provides an introduction to both the basic and advanced features of the -spmodel package coupled with a brief theoretical -explanation of the methods. First we give a brief theoretical -introduction to spatial linear models. Then we outline the variety of -methods used to estimate the parameters of spatial linear models. Then -we explain how to obtain predictions at unobserved locations. Then we -detail some advanced modeling features, including random effects, -partition factors, anisotropy, big data approaches, and spatial -generalized linear models. Finally we end with a short discussion. -Before proceeding, we load spmodel by running

+

spmodel is an R package used to fit, +summarize, and predict for a variety of spatial statistical models. The +vignette provides an introduction to both the basic and advanced +features of the spmodel package coupled with a brief +theoretical explanation of the methods. First we give a brief +theoretical introduction to spatial linear models. Then we outline the +variety of methods used to estimate the parameters of spatial linear +models. Then we explain how to obtain predictions at unobserved +locations. Then we detail some advanced modeling features, including +random effects, partition factors, anisotropy, big data approaches, and +spatial generalized linear models. Finally we end with a short +discussion. Before proceeding, we load spmodel by +running

If using spmodel in a formal publication or report, @@ -675,10 +676,11 @@

The broom functions: augment()

The tidy(), glance(), and -augment() functions from the broom package (Robinson, Hayes, and Couch 2021) provide -convenient output for many of the model fit and diagnostic metrics -discussed in the previous two sections. The tidy() function -returns a tidy tibble of the coefficient table from +augment() functions from the broom R +package (Robinson, Hayes, and Couch 2021) +provide convenient output for many of the model fit and diagnostic +metrics discussed in the previous two sections. The tidy() +function returns a tidy tibble of the coefficient table from summary():

 tidy(spmod)
@@ -1239,10 +1241,10 @@

Random Effectsspmodel using similar syntax as for random effects in the nlme (Pinheiro and Bates 2006) and lme4 (Bates et al. -2015) packages. Random effects are specified via a formula passed -to the random argument. Next we show two examples that -incorporate random effects into the spatial linear model using the -moss data.

+2015) R packages. Random effects are specified +via a formula passed to the random argument. Next we show +two examples that incorporate random effects into the spatial linear +model using the moss data.

The first example explores random intercepts for the sample variable. The sample variable indexes each unique location, which can have replicate observations due to field @@ -1394,12 +1396,12 @@

Anisotropy -A visual representation of the anisotropy transformation. In the left figure, the first step is to rotate the anisotropic ellipse clockwise by the \texttt{rotate} parameter (here \texttt{rotate} is 0.75$\pi$ radians or 135 degrees). In the middle figure, the second step is to scale the y axis by the reciprocal of the \texttt{scale} parameter (here \texttt{scale} is 0.5). In the right figure, the anisotropic ellipse has been transformed into an isotropic one (i.e., a circle). The transformed coordinates are then used instead of the original coordinates to compute distances and spatial covariances.A visual representation of the anisotropy transformation. In the left figure, the first step is to rotate the anisotropic ellipse clockwise by the \texttt{rotate} parameter (here \texttt{rotate} is 0.75$\pi$ radians or 135 degrees). In the middle figure, the second step is to scale the y axis by the reciprocal of the \texttt{scale} parameter (here \texttt{scale} is 0.5). In the right figure, the anisotropic ellipse has been transformed into an isotropic one (i.e., a circle). The transformed coordinates are then used instead of the original coordinates to compute distances and spatial covariances.A visual representation of the anisotropy transformation. In the left figure, the first step is to rotate the anisotropic ellipse clockwise by the \texttt{rotate} parameter (here \texttt{rotate} is 0.75$\pi$ radians or 135 degrees). In the middle figure, the second step is to scale the y axis by the reciprocal of the \texttt{scale} parameter (here \texttt{scale} is 0.5). In the right figure, the anisotropic ellipse has been transformed into an isotropic one (i.e., a circle). The transformed coordinates are then used instead of the original coordinates to compute distances and spatial covariances.

+A visual representation of the anisotropy transformation. In the left figure, the first step is to rotate the anisotropic ellipse clockwise by the `rotate` parameter (here `rotate` is 0.75$\pi$ radians or 135 degrees). In the middle figure, the second step is to scale the y axis by the reciprocal of the `scale` parameter (here `scale` is 0.5). In the right figure, the anisotropic ellipse has been transformed into an isotropic one (i.e., a circle). The transformed coordinates are then used instead of the original coordinates to compute distances and spatial covariances.A visual representation of the anisotropy transformation. In the left figure, the first step is to rotate the anisotropic ellipse clockwise by the `rotate` parameter (here `rotate` is 0.75$\pi$ radians or 135 degrees). In the middle figure, the second step is to scale the y axis by the reciprocal of the `scale` parameter (here `scale` is 0.5). In the right figure, the anisotropic ellipse has been transformed into an isotropic one (i.e., a circle). The transformed coordinates are then used instead of the original coordinates to compute distances and spatial covariances.A visual representation of the anisotropy transformation. In the left figure, the first step is to rotate the anisotropic ellipse clockwise by the `rotate` parameter (here `rotate` is 0.75$\pi$ radians or 135 degrees). In the middle figure, the second step is to scale the y axis by the reciprocal of the `scale` parameter (here `scale` is 0.5). In the right figure, the anisotropic ellipse has been transformed into an isotropic one (i.e., a circle). The transformed coordinates are then used instead of the original coordinates to compute distances and spatial covariances.

A visual representation of the anisotropy transformation. In the left figure, the first step is to rotate the anisotropic ellipse clockwise by -the parameter (here is 0.75\(\pi\) -radians or 135 degrees). In the middle figure, the second step is to -scale the y axis by the reciprocal of the parameter (here is 0.5). In +the rotate parameter (here rotate is 0.75\(\pi\) radians or 135 degrees). In the +middle figure, the second step is to scale the y axis by the reciprocal +of the scale parameter (here scale is 0.5). In the right figure, the anisotropic ellipse has been transformed into an isotropic one (i.e., a circle). The transformed coordinates are then used instead of the original coordinates to compute distances and diff --git a/docs/articles/guide_files/figure-html/anisotropy_fit-1.png b/docs/articles/guide_files/figure-html/anisotropy_fit-1.png index 9826b4f..0ecd6b4 100644 Binary files a/docs/articles/guide_files/figure-html/anisotropy_fit-1.png and b/docs/articles/guide_files/figure-html/anisotropy_fit-1.png differ diff --git a/docs/articles/guide_files/figure-html/anisotropy_fit-2.png b/docs/articles/guide_files/figure-html/anisotropy_fit-2.png index e75a3f1..27e6803 100644 Binary files a/docs/articles/guide_files/figure-html/anisotropy_fit-2.png and b/docs/articles/guide_files/figure-html/anisotropy_fit-2.png differ diff --git a/docs/articles/guide_files/figure-html/anisotropy_fit-3.png b/docs/articles/guide_files/figure-html/anisotropy_fit-3.png index d1a75b1..df5a7df 100644 Binary files a/docs/articles/guide_files/figure-html/anisotropy_fit-3.png and b/docs/articles/guide_files/figure-html/anisotropy_fit-3.png differ diff --git a/docs/articles/guide_files/figure-html/log_trend-1.png b/docs/articles/guide_files/figure-html/log_trend-1.png index 1148459..ec9def1 100644 Binary files a/docs/articles/guide_files/figure-html/log_trend-1.png and b/docs/articles/guide_files/figure-html/log_trend-1.png differ diff --git a/docs/articles/guide_files/figure-html/log_zn-1.png b/docs/articles/guide_files/figure-html/log_zn-1.png index a70e1ac..00602d4 100644 Binary files a/docs/articles/guide_files/figure-html/log_zn-1.png and b/docs/articles/guide_files/figure-html/log_zn-1.png differ diff --git a/docs/articles/guide_files/figure-html/sim-glm-1.png b/docs/articles/guide_files/figure-html/sim-glm-1.png index 5339086..906e711 100644 Binary files a/docs/articles/guide_files/figure-html/sim-glm-1.png and b/docs/articles/guide_files/figure-html/sim-glm-1.png differ diff --git a/docs/articles/guide_files/figure-html/sim_preds-1.png b/docs/articles/guide_files/figure-html/sim_preds-1.png index aad74d3..ac512c2 100644 Binary files a/docs/articles/guide_files/figure-html/sim_preds-1.png and b/docs/articles/guide_files/figure-html/sim_preds-1.png differ diff --git a/docs/articles/guide_files/figure-html/sim_preds-2.png b/docs/articles/guide_files/figure-html/sim_preds-2.png index 6b6cf9a..b5cbc83 100644 Binary files a/docs/articles/guide_files/figure-html/sim_preds-2.png and b/docs/articles/guide_files/figure-html/sim_preds-2.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index 6b3b93d..1691d7c 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1

diff --git a/docs/articles/introduction.html b/docs/articles/introduction.html index f3ffb90..fa5eb64 100644 --- a/docs/articles/introduction.html +++ b/docs/articles/introduction.html @@ -40,7 +40,7 @@ spmodel - 0.11.0 + 0.11.1

@@ -115,10 +115,11 @@

Michael

Introduction

-

The spmodel package is used to fit and summarize spatial -models and make predictions at unobserved locations (Kriging). This -vignette provides an overview of basic features in spmodel. -We load spmodel by running

+

The spmodel R package is used to fit +and summarize spatial models and make predictions at unobserved +locations (Kriging). This vignette provides an overview of basic +features in spmodel. We load spmodel by +running

If you use spmodel in a formal publication or report, diff --git a/docs/articles/technical.html b/docs/articles/technical.html index 5eb4914..71d0404 100644 --- a/docs/articles/technical.html +++ b/docs/articles/technical.html @@ -40,7 +40,7 @@ spmodel - 0.11.0 + 0.11.1

@@ -354,8 +354,8 @@

anova()

-

Test statistics from are formed using the general linear hypothesis -test. Let \(\mathbf{L}\) be an \(l \times p\) contrast matrix and \(l_0\) be an \(l +

Test statistics from anova() are formed using the +general linear hypothesis test. Let \(\mathbf{L}\) be an \(l \times p\) contrast matrix and \(l_0\) be an \(l \times 1\) vector. The null hypothesis is that \(\mathbf{L} \boldsymbol{\hat{\beta}} = l_0\) and the alternative hypothesis is that \(\mathbf{L} \boldsymbol{\hat{\beta}} \neq l_0\). Usually, \(l_0\) is the @@ -368,9 +368,10 @@

\end{equation*}\] By default, \(\mathbf{L}\) is chosen such that each variable in the data used to fit the model is tested marginally (i.e., controlling for the other variables) against \(l_0 = \mathbf{0}\). If this default is not -desired, the and arguments can be used to pass user-defined \(\mathbf{L}\) matrices to . They must be -constructed in such a way that \(l_0 = -\mathbf{0}\).

+desired, the Terms and L arguments can be used +to pass user-defined \(\mathbf{L}\) +matrices to anova(). They must be constructed in such a way +that \(l_0 = \mathbf{0}\).

It is notoriously difficult to determine appropriate p-values for linear mixed models based on the general linear hypothesis test. lme4, for example, does not report p-values by default. A few reasons why @@ -1059,12 +1060,13 @@

Block Prediction (the default), the size -observations having the highest average covariance with elements of -\(\mathbf{y}_o\) are used to find the -subsets \(\check{\mathbf{X}}_o\), \(\check{\boldsymbol{\Sigma}}_o\), and \(\check{\mathbf{y}}_o\). When -method = "distance", the size observations -having the smallest average distance from elements of \(\mathbf{y}_o\) are used to find the subsets -\(\check{\mathbf{X}}_o\), \(\check{\boldsymbol{\Sigma}}_o\), and \(\check{\mathbf{y}}_o\). Recall that these +observations of \(\mathbf{y}_o\) having +the highest average covariance with elements of the fine grid are used +to find the subsets \(\check{\mathbf{X}}_o\), \(\check{\boldsymbol{\Sigma}}_o\), and \(\check{\mathbf{y}}_o\). When +method = "distance", the size observations of +of \(\mathbf{y}_o\) having the smallest +average distance to elements of the fine grid are used to find the +subsets \(\check{\mathbf{X}}_o\), \(\check{\boldsymbol{\Sigma}}_o\), and \(\check{\mathbf{y}}_o\). Recall that these two methods are equivalent for processes without anisotropy, random effects, or partition factors, but can differ otherwise. The default is size = 1000, which is much larger than for point @@ -1271,12 +1273,12 @@

- + - + @@ -1343,70 +1345,70 @@

- + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -1596,48 +1598,48 @@
Weighted Least Squares (estmethod = "sv \(w_i\) Name
- + - + - + - + - + - + - + - + - +
\(\texttt{sprnorm()}\)sprnorm() Simulate spatial Gaussian data
\(\texttt{sprbinom()}\)sprbinom() Simulate spatial binomial data
\(\texttt{sprbeta()}\)sprbeta() Simulate spatial beta data
\(\texttt{sprpois()}\)sprpois() Simulate spatial Poisson data
\(\texttt{sprnbinom()}\)sprnbinom() Simulate spatial negative binomial data
\(\texttt{sprgamma()}\)sprgamma() Simulate spatial gamma data
\(\texttt{sprinvgauss()}\)sprinvgauss() Simulate spatial inverse Gaussian data
\(\texttt{"car"}\)"car" \((\mathbf{I} - \phi\mathbf{W})^{-1}\mathbf{M}\)
\(\texttt{"sar"}\)"sar" \([(\mathbf{I} - \phi\mathbf{W})(\mathbf{I} - \phi\mathbf{W})^\top]^{-1}\)
\(\texttt{"exponential"}\)"exponential" \(e^{-\eta}\)
\(\texttt{"spherical"}\)"spherical" \((1 - 1.5\eta + 0.5\eta^3)\mathcal{I}\{h \leq \phi \}\)
\(\texttt{"gaussian"}\)"gaussian" \(e^{-\eta^2}\)
\(\texttt{"triangular"}\)"triangular" \((1 - \eta)\mathcal{I}\{h \leq \phi \}\)
\(\texttt{"circular"}\)"circular" \((1 - \frac{2}{\pi}[m\sqrt{1 - m^2} + sin^{-1}\{m\}])\mathcal{I}\{h \leq \phi \}, m = min(\eta, 1)\)
\(\texttt{"cubic"}\)"cubic" \((1 - 7\eta^2 + 8.75\eta^3 - 3.5\eta^5 + 0.75 \eta^7)\mathcal{I}\{h \leq \phi \}\) \
\(\texttt{"pentaspherical"}\)"pentaspherical" \((1 - 1.875\eta + 1.250\eta^3 - 0.375\eta^5)\mathcal{I}\{h \leq \phi \}\) \
\(\texttt{"cosine"}\)"cosine" $ cos() $
\(\texttt{"wave"}\)"wave" \(\frac{sin(\eta)}{\eta}\mathcal{I}\{h > 0 \} + \mathcal{I}\{h = 0 \}\)
\(\texttt{"jbessel"}\)"jbessel" \(B_j(h\phi), B_j\) is Bessel-J
\(\texttt{"gravity"}\)"gravity" \((1 + \eta^2)^{-1/2}\)
\(\texttt{"rquad"}\)"rquad" \((1 + \eta^2)^{-1}\)
\(\texttt{"magnetic"}\)"magnetic" \((1 + \eta^2)^{-3/2}\)
\(\texttt{"matern"}\)"matern" \(\frac{2^{(1 - \xi)}}{\Gamma(\xi)} \alpha^\xi B_k(\alpha, \xi), \alpha = \sqrt{2\xi \eta}, B_k\) is @@ -1414,23 +1416,23 @@

\(\texttt{"cauchy"}\)"cauchy" \((1 + \eta^2)^{-\xi}\), \(\xi > 0\)
\(\texttt{"pexponential"}\)"pexponential" \(exp(-h^\xi / \phi)\), \(\xi \in (0, 2]\)
\(\texttt{"none"}\)"none" \(0\)
\(\texttt{"ie"}\)"ie" \(0\)
\(w_i\) Form\(\texttt{weight =}\)weight =
Cressie \(|N(h)| / \gamma(h)_i^2\)\(\texttt{"cressie"}\)"cressie"
Cressie (Denominator) Root \(|N(h)| / \gamma(h)_i\)\(\texttt{"cressie-dr"}\)"cressie-dr"
Cressie No Pairs \(1 / \gamma(h)_i^2\)\(\texttt{"cressie-nopairs"}\)"cressie-nopairs"
Cressie (Denominator) Root No Pairs \(1 / \gamma(h)_i\)\(\texttt{"cressie-dr-nopairs"}\)"cressie-dr-nopairs"
Pairs \(|N(h)|\)\(\texttt{pairs"}\)"pairs"
Pairs Inverse Distance \(|N(h)| / h^2\)\(\texttt{"pairs-invd"}\)"pairs-invd"
Pairs Inverse (Root) Distance \(|N(h)| / h\)\(\texttt{"pairs-invrd"}\)"pairs-invrd"
Ordinary Least Squares 1\(\texttt{"ols"}\)"ols"
diff --git a/docs/articles/technical_files/figure-html/anisotropy2-1.png b/docs/articles/technical_files/figure-html/anisotropy2-1.png index 3d58888..2031e39 100644 Binary files a/docs/articles/technical_files/figure-html/anisotropy2-1.png and b/docs/articles/technical_files/figure-html/anisotropy2-1.png differ diff --git a/docs/articles/technical_files/figure-html/anisotropy2-2.png b/docs/articles/technical_files/figure-html/anisotropy2-2.png index 7a29d15..6b59a17 100644 Binary files a/docs/articles/technical_files/figure-html/anisotropy2-2.png and b/docs/articles/technical_files/figure-html/anisotropy2-2.png differ diff --git a/docs/articles/technical_files/figure-html/anisotropy2-3.png b/docs/articles/technical_files/figure-html/anisotropy2-3.png index 1efc849..b672bce 100644 Binary files a/docs/articles/technical_files/figure-html/anisotropy2-3.png and b/docs/articles/technical_files/figure-html/anisotropy2-3.png differ diff --git a/docs/authors.html b/docs/authors.html index bf5c972..836bdb4 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1
diff --git a/docs/index.html b/docs/index.html index 580ff9e..34b99f9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -40,7 +40,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/news/index.html b/docs/news/index.html index 1b7ebc1..fc09fd1 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 @@ -72,6 +72,19 @@

Changelog

Source: NEWS.md +
+ +
+

Minor Updates

+
  • Added a warning message when splm() or spglm() converts a non-POINT geometry to a POINT geometry using sf::st_centroid().
  • +
  • Updated a warning message when splm() or spglm() compute distances using a geographic coordinate system (and not a projected coordinate system).
  • +
+
+

Bug Fixes

+
  • Fixed a bug in the cloud semivariogram (i.e., esv(..., cloud = TRUE)) that incorrectly doubled the semivariance.
  • +
  • Fix \textbf, \textsf, and \textttt LaTeX rendering issues in vignettes (#36).
  • +
+
diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 815250a..9366708 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -8,7 +8,7 @@ articles: introduction: introduction.html SPGLMs: SPGLMs.html technical: technical.html -last_built: 2025-07-03T16:09Z +last_built: 2025-11-17T17:09Z urls: reference: https://usepa.github.io/spmodel/reference article: https://usepa.github.io/spmodel/articles diff --git a/docs/reference/AICc.html b/docs/reference/AICc.html index 0d81337..dddc62a 100644 --- a/docs/reference/AICc.html +++ b/docs/reference/AICc.html @@ -19,7 +19,7 @@ spmodel - 0.11.0 + 0.11.1
diff --git a/docs/reference/AUROC.html b/docs/reference/AUROC.html index 9cc4484..033f0a8 100644 --- a/docs/reference/AUROC.html +++ b/docs/reference/AUROC.html @@ -19,7 +19,7 @@ spmodel - 0.11.0 + 0.11.1
diff --git a/docs/reference/anova.spmodel.html b/docs/reference/anova.spmodel.html index 0987a48..87432d2 100644 --- a/docs/reference/anova.spmodel.html +++ b/docs/reference/anova.spmodel.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/augment.spmodel.html b/docs/reference/augment.spmodel.html index 46f3df5..79801c2 100644 --- a/docs/reference/augment.spmodel.html +++ b/docs/reference/augment.spmodel.html @@ -27,7 +27,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/caribou.html b/docs/reference/caribou.html index 919fe1b..f366bb0 100644 --- a/docs/reference/caribou.html +++ b/docs/reference/caribou.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/coef.spmodel.html b/docs/reference/coef.spmodel.html index 433b9a7..11663d2 100644 --- a/docs/reference/coef.spmodel.html +++ b/docs/reference/coef.spmodel.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/confint.spmodel.html b/docs/reference/confint.spmodel.html index 1df91bf..03fa535 100644 --- a/docs/reference/confint.spmodel.html +++ b/docs/reference/confint.spmodel.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/cooks.distance.spmodel.html b/docs/reference/cooks.distance.spmodel.html index fb41f07..2bc67ab 100644 --- a/docs/reference/cooks.distance.spmodel.html +++ b/docs/reference/cooks.distance.spmodel.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/covmatrix.html b/docs/reference/covmatrix.html index 3af4f8d..f01d3ee 100644 --- a/docs/reference/covmatrix.html +++ b/docs/reference/covmatrix.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/deviance.spmodel.html b/docs/reference/deviance.spmodel.html index d9a9337..0f81db2 100644 --- a/docs/reference/deviance.spmodel.html +++ b/docs/reference/deviance.spmodel.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/dispersion_initial.html b/docs/reference/dispersion_initial.html index d866fee..f8a3ced 100644 --- a/docs/reference/dispersion_initial.html +++ b/docs/reference/dispersion_initial.html @@ -19,7 +19,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/dispersion_params.html b/docs/reference/dispersion_params.html index eedae59..2846b8e 100644 --- a/docs/reference/dispersion_params.html +++ b/docs/reference/dispersion_params.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/esv.html b/docs/reference/esv.html index 0bbbfb5..e4e34e7 100644 --- a/docs/reference/esv.html +++ b/docs/reference/esv.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/fc_borders.html b/docs/reference/fc_borders.html index feddffe..43c5fa1 100644 --- a/docs/reference/fc_borders.html +++ b/docs/reference/fc_borders.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/fitted.spmodel.html b/docs/reference/fitted.spmodel.html index c39bee7..2c90930 100644 --- a/docs/reference/fitted.spmodel.html +++ b/docs/reference/fitted.spmodel.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/formula.spmodel.html b/docs/reference/formula.spmodel.html index 0873ebb..92fcfbc 100644 --- a/docs/reference/formula.spmodel.html +++ b/docs/reference/formula.spmodel.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 @@ -116,7 +116,7 @@

Examples

) formula(spmod) #> z ~ water + tarp -#> <environment: 0x000001775f5ba208> +#> <environment: 0x000002c75df7bab0>
diff --git a/docs/reference/glance.spmodel.html b/docs/reference/glance.spmodel.html index 99a2ecb..c089e68 100644 --- a/docs/reference/glance.spmodel.html +++ b/docs/reference/glance.spmodel.html @@ -21,7 +21,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/glances.html b/docs/reference/glances.html index ee4d80b..df7dde1 100644 --- a/docs/reference/glances.html +++ b/docs/reference/glances.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/hatvalues.spmodel.html b/docs/reference/hatvalues.spmodel.html index 31a4236..43127a7 100644 --- a/docs/reference/hatvalues.spmodel.html +++ b/docs/reference/hatvalues.spmodel.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/index.html b/docs/reference/index.html index b5917af..5671733 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/influence.spmodel.html b/docs/reference/influence.spmodel.html index c8f8238..5cc82d0 100644 --- a/docs/reference/influence.spmodel.html +++ b/docs/reference/influence.spmodel.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/labels.spmodel.html b/docs/reference/labels.spmodel.html index 01d6f37..72a812c 100644 --- a/docs/reference/labels.spmodel.html +++ b/docs/reference/labels.spmodel.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/lake.html b/docs/reference/lake.html index fe32513..ac2752c 100644 --- a/docs/reference/lake.html +++ b/docs/reference/lake.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/lake_preds.html b/docs/reference/lake_preds.html index 593df8e..2565101 100644 --- a/docs/reference/lake_preds.html +++ b/docs/reference/lake_preds.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/logLik.spmodel.html b/docs/reference/logLik.spmodel.html index c496be9..b241775 100644 --- a/docs/reference/logLik.spmodel.html +++ b/docs/reference/logLik.spmodel.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/loocv.html b/docs/reference/loocv.html index 0bc1461..deb68f4 100644 --- a/docs/reference/loocv.html +++ b/docs/reference/loocv.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/model.frame.spmodel.html b/docs/reference/model.frame.spmodel.html index f07ddac..85afcee 100644 --- a/docs/reference/model.frame.spmodel.html +++ b/docs/reference/model.frame.spmodel.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/model.matrix.spmodel.html b/docs/reference/model.matrix.spmodel.html index 20f7fa6..cf82917 100644 --- a/docs/reference/model.matrix.spmodel.html +++ b/docs/reference/model.matrix.spmodel.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/moose.html b/docs/reference/moose.html index ecb063c..d70fc38 100644 --- a/docs/reference/moose.html +++ b/docs/reference/moose.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/moose_preds.html b/docs/reference/moose_preds.html index a584998..510f595 100644 --- a/docs/reference/moose_preds.html +++ b/docs/reference/moose_preds.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/moss.html b/docs/reference/moss.html index e4ebcc0..556bc8a 100644 --- a/docs/reference/moss.html +++ b/docs/reference/moss.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/plot.spmodel.html b/docs/reference/plot.spmodel.html index 9d47105..af1cd27 100644 --- a/docs/reference/plot.spmodel.html +++ b/docs/reference/plot.spmodel.html @@ -20,7 +20,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/predict.spmodel.html b/docs/reference/predict.spmodel.html index 0a0e810..9f4fb5a 100644 --- a/docs/reference/predict.spmodel.html +++ b/docs/reference/predict.spmodel.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/print.spmodel.html b/docs/reference/print.spmodel.html index 27f75cc..477279f 100644 --- a/docs/reference/print.spmodel.html +++ b/docs/reference/print.spmodel.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/pseudoR2.html b/docs/reference/pseudoR2.html index a1802ba..7878ef7 100644 --- a/docs/reference/pseudoR2.html +++ b/docs/reference/pseudoR2.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/randcov_initial.html b/docs/reference/randcov_initial.html index c7f83d3..3e16862 100644 --- a/docs/reference/randcov_initial.html +++ b/docs/reference/randcov_initial.html @@ -19,7 +19,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/randcov_params.html b/docs/reference/randcov_params.html index d574631..a31be6c 100644 --- a/docs/reference/randcov_params.html +++ b/docs/reference/randcov_params.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/reexports.html b/docs/reference/reexports.html index e1675ec..7cd5947 100644 --- a/docs/reference/reexports.html +++ b/docs/reference/reexports.html @@ -24,7 +24,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/residuals.spmodel.html b/docs/reference/residuals.spmodel.html index dbd3b3a..7b2ef26 100644 --- a/docs/reference/residuals.spmodel.html +++ b/docs/reference/residuals.spmodel.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/seal.html b/docs/reference/seal.html index b78083f..6b1bdc3 100644 --- a/docs/reference/seal.html +++ b/docs/reference/seal.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/spautor.html b/docs/reference/spautor.html index 8d3c4ec..e18799a 100644 --- a/docs/reference/spautor.html +++ b/docs/reference/spautor.html @@ -19,7 +19,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/spautorRF.html b/docs/reference/spautorRF.html index 68fd6fb..bc1756e 100644 --- a/docs/reference/spautorRF.html +++ b/docs/reference/spautorRF.html @@ -22,7 +22,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/spcov_initial.html b/docs/reference/spcov_initial.html index 77b91a9..bb2b30e 100644 --- a/docs/reference/spcov_initial.html +++ b/docs/reference/spcov_initial.html @@ -19,7 +19,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/spcov_params.html b/docs/reference/spcov_params.html index 0b5bd43..2861425 100644 --- a/docs/reference/spcov_params.html +++ b/docs/reference/spcov_params.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/spgautor.html b/docs/reference/spgautor.html index 16b9bd2..d2dc8ae 100644 --- a/docs/reference/spgautor.html +++ b/docs/reference/spgautor.html @@ -20,7 +20,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/spglm.html b/docs/reference/spglm.html index a12e4ef..8e1a79c 100644 --- a/docs/reference/spglm.html +++ b/docs/reference/spglm.html @@ -20,7 +20,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/splm.html b/docs/reference/splm.html index fe2195f..1668fe4 100644 --- a/docs/reference/splm.html +++ b/docs/reference/splm.html @@ -20,7 +20,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/splmRF.html b/docs/reference/splmRF.html index a5848be..fcbb029 100644 --- a/docs/reference/splmRF.html +++ b/docs/reference/splmRF.html @@ -21,7 +21,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/spmodel-package.html b/docs/reference/spmodel-package.html index 022721f..271ac97 100644 --- a/docs/reference/spmodel-package.html +++ b/docs/reference/spmodel-package.html @@ -19,7 +19,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/sprbeta.html b/docs/reference/sprbeta.html index b3390d0..264bed6 100644 --- a/docs/reference/sprbeta.html +++ b/docs/reference/sprbeta.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/sprbinom.html b/docs/reference/sprbinom.html index 6dde79d..624a1b8 100644 --- a/docs/reference/sprbinom.html +++ b/docs/reference/sprbinom.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/sprgamma.html b/docs/reference/sprgamma.html index 98c3b6a..6c63bfb 100644 --- a/docs/reference/sprgamma.html +++ b/docs/reference/sprgamma.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/sprinvgauss.html b/docs/reference/sprinvgauss.html index f3aef1d..d0f655e 100644 --- a/docs/reference/sprinvgauss.html +++ b/docs/reference/sprinvgauss.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/sprnbinom.html b/docs/reference/sprnbinom.html index 1b2d3d7..e07cb6d 100644 --- a/docs/reference/sprnbinom.html +++ b/docs/reference/sprnbinom.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/sprnorm.html b/docs/reference/sprnorm.html index 4cbee47..04baf31 100644 --- a/docs/reference/sprnorm.html +++ b/docs/reference/sprnorm.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/sprpois.html b/docs/reference/sprpois.html index 5878556..a3e2ad2 100644 --- a/docs/reference/sprpois.html +++ b/docs/reference/sprpois.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/sulfate.html b/docs/reference/sulfate.html index 8c0852f..d66aec6 100644 --- a/docs/reference/sulfate.html +++ b/docs/reference/sulfate.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/sulfate_preds.html b/docs/reference/sulfate_preds.html index dbe784e..ddd159e 100644 --- a/docs/reference/sulfate_preds.html +++ b/docs/reference/sulfate_preds.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/summary.spmodel.html b/docs/reference/summary.spmodel.html index 20b6e89..386b313 100644 --- a/docs/reference/summary.spmodel.html +++ b/docs/reference/summary.spmodel.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/texas.html b/docs/reference/texas.html index 434fe57..824a776 100644 --- a/docs/reference/texas.html +++ b/docs/reference/texas.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/tidy.spmodel.html b/docs/reference/tidy.spmodel.html index 3d3b21c..ee09ddc 100644 --- a/docs/reference/tidy.spmodel.html +++ b/docs/reference/tidy.spmodel.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/varcomp.html b/docs/reference/varcomp.html index 495a5ed..b534aa6 100644 --- a/docs/reference/varcomp.html +++ b/docs/reference/varcomp.html @@ -18,7 +18,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/docs/reference/vcov.spmodel.html b/docs/reference/vcov.spmodel.html index 3467af5..5c59fa5 100644 --- a/docs/reference/vcov.spmodel.html +++ b/docs/reference/vcov.spmodel.html @@ -17,7 +17,7 @@ spmodel - 0.11.0 + 0.11.1 diff --git a/vignettes/articles/SPGLMs.Rmd b/vignettes/articles/SPGLMs.Rmd index c482c81..66f9bcd 100644 --- a/vignettes/articles/SPGLMs.Rmd +++ b/vignettes/articles/SPGLMs.Rmd @@ -21,7 +21,7 @@ library(spmodel) # Introduction {#sec:introduction} -`spmodel` is an \textbf{\textsf{R}} package used to fit, summarize, and +`spmodel` is an **R** package used to fit, summarize, and predict for a variety of spatial statistical models. The vignette provides an introduction spatial generalized linear models for non-Gaussian response distributions in `spmodel`. Before proceeding, we @@ -212,7 +212,7 @@ least squares). @ver2024marginal provide the methodology's full details. `spmodel` accommodates the binomial, beta, Poisson, negative binomial, gamma, and inverse Gaussian distributions. The binomial and beta -response distributions (specified by \texttt{family}) use the logit +response distributions (specified by `family`) use the logit link, while the Poisson, negative binomial, gamma, and inverse Gaussian distributions use the log link -- see the following table. @@ -231,26 +231,26 @@ spmodel alongside their corresponding link functions and data types. ## Model fitting {#sec:model-fit} Spatial generalized linear models in `spmodel` are fit using -\texttt{spglm()} (for point-referenced data) or \texttt{spgautor()} (for +`spglm()` (for point-referenced data) or `spgautor()` (for areal data). These functions are similar in structure both to one -another and to the \texttt{glm()} function in base **R**. They generally -require the following four arguments: \texttt{formula}, a formula that +another and to the `glm()` function in base **R**. They generally +require the following four arguments: `formula`, a formula that describes the relationship between the response and explanatory -variables; \texttt{family}, the response distribution, which can be -\texttt{binomial}, \texttt{beta}, \texttt{poisson}, \texttt{nbinomial}, -\texttt{Gamma}, or \texttt{inverse.gaussian}; \texttt{data}, a -\texttt{data.frame} or \texttt{sf} object [@pebesma2018sf] whose rows +variables; `family`, the response distribution, which can be +`binomial`, `beta`, `poisson`, `nbinomial`, +`Gamma`, or `inverse.gaussian`; `data`, a +`data.frame` or `sf` object [@pebesma2018sf] whose rows index observations and whose columns contain the response variable, explanatory variables, and spatial information; and -\texttt{spcov\_type}, one of 19 spatial covariance types (e.g., +`spcov_type`, one of 19 spatial covariance types (e.g., spherical spatial covariance, Matérn spatial covariance, simultaneous-autoregressive spatial covariance etc.). The binomial and -beta response distributions (specified by \texttt{family}) use the logit +beta response distributions (specified by `family`) use the logit link, while the Poisson, negative binomial, gamma, and inverse Gaussian distributions use the log link. Other -arguments to \texttt{spglm()} and \texttt{spgautor()} are either +arguments to `spglm()` and `spgautor()` are either required only in specific situations or have default values specified. -All arguments to the \texttt{spglm()} and \texttt{spgautor()} functions +All arguments to the `spglm()` and `spgautor()` functions are summarized in the following table. Models for several hundred observations can take anywhere from a few seconds to a few minutes to fit, depending on the shape of the likelihood surface and how @@ -259,29 +259,29 @@ observations can utilize `spmodel`'s large data set options. | Argument | Purposes | Applies To | |------|------|------| -| $\texttt{formula}$ | Fixed effects formula | Both | -| $\texttt{family}$ | Response distribution | Both | -| $\texttt{data}$ | Data Frame or \texttt{sf} object | Both | -| $\texttt{spcov_type}$ | Spatial covariance type | Both | -| $\texttt{spcov_initial}$ | Initial or known spatial covariance parameters | Both | -| $\texttt{dispersion_initial}$ | Initial or known dispersion parameter | Both | -| $\texttt{estmethod}$ | Estimation method | Both | -| $\texttt{random}$ | Random effects formula | Both | -| $\texttt{randcov_initial}$ | Initial or known random effect variances | Both | -| $\texttt{partition_factor}$ | A partition factor formula | Both | -| $\texttt{...}$ | Additional arguments | Both | -| $\texttt{anisotropy}$ | Whether to model anisotropy | $\texttt{spglm()}$ | -| $\texttt{xcoord}$ | An x-coordinate name | $\texttt{spglm()}$ | -| $\texttt{ycoord}$ | A y-coordinate name | $\texttt{spglm()}$ | -| $\texttt{local}$ | Options for large data sets | $\texttt{spglm()}$ | -| $\texttt{W}$ | A neighborhood weight matrix | $\texttt{spgautor()}$ | -| $\texttt{row_st}$ | Whether to row-standardize $\texttt{W}$ | $\texttt{spgautor()}$ | -| $\texttt{M}$ | A symmetry matrix | $\texttt{spgautor()}$ | -| $\texttt{range_positive}$ | Whether the range parameter is restricted to be positive | -| $\texttt{cutoff}$ | Distance cutoff if using distance-based neighbor definition | - -: Arguments to spglm() and spgautor(), their purpose, and whether the -argument applies to both spglm() and spgautor() or just one of them. +| `formula` | Fixed effects formula | Both | +| `family` | Response distribution | Both | +| `data` | Data Frame or `sf` object | Both | +| `spcov_type` | Spatial covariance type | Both | +| `spcov_initial` | Initial or known spatial covariance parameters | Both | +| `dispersion_initial` | Initial or known dispersion parameter | Both | +| `estmethod` | Estimation method | Both | +| `random` | Random effects formula | Both | +| `randcov_initial` | Initial or known random effect variances | Both | +| `partition_factor` | A partition factor formula | Both | +| `...` | Additional arguments | Both | +| `anisotropy` | Whether to model anisotropy | `spglm()` | +| `xcoord` | An x-coordinate name | `spglm()}` | +| `ycoord` | A y-coordinate name | `spglm()` | +| `local` | Options for large data sets | `spglm()` | +| `W` | A neighborhood weight matrix | `spgautor()` | +| `row_st` | Whether to row-standardize `W` | `spgautor()` | +| `M` | A symmetry matrix | `spgautor()` | +| `range_positive` | Whether the range parameter is restricted to be positive | +| `cutoff` | Distance cutoff if using distance-based neighbor definition | + +: Arguments to `spglm()` and `spgautor()`, their purpose, and whether the +argument applies to both `spglm()` and `spgautor()` or just one of them. ## Model evaluation and diagnostics {#sec:diagnostics} @@ -289,7 +289,7 @@ After fitting a model, it is usually beneficial to evaluate certain aspects of model fit or inspect and visualize model diagnostics like residuals. There are many functions in `spmodel` that are used for these purposes, and their main argument is the fitted model object returned by -\texttt{spglm()} or \texttt{spgautor()}. The names of these functions +`spglm()` or `spgautor()`. The names of these functions are meant to be illustrative, describing the purpose of the function itself. The functions for evaluating model fit (see below) return likelihood-based @@ -299,22 +299,22 @@ validation, and more. | Function | Purpose | |------|------| -| $\texttt{AIC()}$; $\texttt{AICc()}$ | Return AIC and AICc | -| $\texttt{anova()}$ | Perform an analysis of variance | -| $\texttt{AUROC()}$ | Compute the area under the receiver operating characteristic curve | -| $\texttt{BIC()}$ | Return BIC | -| $\texttt{coef()}$; $\texttt{coefficients()}$ | Return parameter estimates | -| $\texttt{confint()}$ | Return confidence intervals | -| $\texttt{covmatrix()}$ | Return the fitted covariance matrix | -| $\texttt{deviance()}$ | Return the deviance | -| $\texttt{glance()}$; $\texttt{glances()}$ | Glance at model fits | -| $\texttt{logLik()}$ | Return the log-likelihood | -| $\texttt{loocv()}$ | Perform leave-one-out cross validation | -| $\texttt{pseudoR2()}$ | Return the pseudo R-squared | -| $\texttt{summary()}$ | Summarize the fitted model | -| $\texttt{tidy()}$ | Tidy the fitted model | -| $\texttt{varcomp()}$ | Compare sources of variability | -| $\texttt{vcov()}$ | Return variance-covariance matrices | +| `AIC()`; `AICc()` | Return AIC and AICc | +| `anova()` | Perform an analysis of variance | +| `AUROC()` | Compute the area under the receiver operating characteristic curve | +| `BIC()` | Return BIC | +| `coef()`; `coefficients()` | Return parameter estimates | +| `confint()` | Return confidence intervals | +| `covmatrix()` | Return the fitted covariance matrix | +| `deviance()` | Return the deviance | +| `glance()`; `glances()` | Glance at model fits | +| `logLik()` | Return the log-likelihood | +| `loocv()` | Perform leave-one-out cross validation | +| `pseudoR2()` | Return the pseudo R-squared | +| `summary()` | Summarize the fitted model | +| `tidy()` | Tidy the fitted model | +| `varcomp()` | Compare sources of variability | +| `vcov()` | Return variance-covariance matrices | : Model evaluation functions available for models fit using spglm() or spgautor() and their purpose. @@ -326,64 +326,64 @@ The functions for inspecting model diagnostics | Function | Purpose | |------|------| -| $\texttt{augment()}$ | Augment model data with diagnostics | -| $\texttt{cooks.distance()}$ | Return Cook's distances | -| $\texttt{fitted()}$; $\texttt{fitted.values()}$ | Return fitted values | -| $\texttt{hatvalues()}$; | Return hat (leverage) values | -| $\texttt{plot()}$ | Plot model diagnostics | -| $\texttt{residuals()}$; $\texttt{resid()}$; $\texttt{rstandard()}$ | Return residuals | +| `augment()` | Augment model data with diagnostics | +| `cooks.distance()` | Return Cook's distances | +| `fitted()`; `fitted.values()` | Return fitted values | +| `hatvalues()`; | Return hat (leverage) values | +| `plot()` | Plot model diagnostics | +| `residuals()`; `resid()`; `rstandard()` | Return residuals | : Mode diagnostic functions available for models fit using spglm() or spgautor() and their purpose. -The functions \texttt{tidy()}, \texttt{glance()}, and -\texttt{augment()}, popularized by the `broom` **R** package -[@robinson2021broom], are particularly useful. The \texttt{tidy()} +The functions `tidy()`, `glance()`, and +`augment()`, popularized by the `broom` **R** package +[@robinson2021broom], are particularly useful. The `tidy()` function tidies parameter estimate output, returning a special -\texttt{data.frame} called a \texttt{tibble} [@muller2021tibble] that is +`data.frame` called a `tibble` [@muller2021tibble] that is much easier to manipulate and work with than the parameter estimate -output printed by \texttt{summary()} to the **R** console. The -\texttt{glance()} function glances at the model fit, returning a -\texttt{tibble} with the sample size, number of estimated parameters, -and several model-fit statistics. \texttt{glances()} is an extension of -\texttt{glance()} that glances at multiple models simultaneously. The -\texttt{augment()} function augments the model fit, returning a -\texttt{tibble} with the data used to fit the model as well as model -diagnostics. The \texttt{augment()} function can also be used to augment +output printed by `summary()` to the **R** console. The +`glance()` function glances at the model fit, returning a +`tibble` with the sample size, number of estimated parameters, +and several model-fit statistics. `glances()` is an extension of +`glance()` that glances at multiple models simultaneously. The +`augment()` function augments the model fit, returning a +`tibble` with the data used to fit the model as well as model +diagnostics. The `augment()` function can also be used to augment prediction data, as we discuss next. ## Prediction {#sec:prediction} Often a priority of a spatial data analysis is using the fitted model to make predictions at unobserved locations and quantify uncertainties in -those predictions. The \texttt{predict()} function in `spmodel` is used +those predictions. The `predict()` function in `spmodel` is used to predict the mean process at unobserved locations. It is similar in -structure to \texttt{predict()} for objects fit using \texttt{glm()} in -base **R** and takes two main arguments: \texttt{object}, the fitted -model object returned by \texttt{spglm()} or \texttt{spgautor()}; and -\texttt{newdata}, a \texttt{data.frame} or \texttt{sf} object whose rows +structure to `predict()` for objects fit using `glm()` in +base **R** and takes two main arguments: `object`, the fitted +model object returned by `spglm()` or `spgautor()`; and +`newdata`, a `data.frame` or `sf` object whose rows index locations requiring prediction and whose columns contain the explanatory variables and spatial information at these locations. Other -arguments to \texttt{predict()} are either required only in specific +arguments to `predict()` are either required only in specific situations or have default values specified. All arguments to the -\texttt{predict()} function are summarized in -the following table. The \texttt{augment()} function can also -be used to augment \texttt{newdata} with predictions, taking the same -arguments as \texttt{predict()}. +`predict()` function are summarized in +the following table. The `augment()` function can also +be used to augment `newdata` with predictions, taking the same +arguments as `predict()`. | Argument | Purpose | |------|------| -| $\texttt{object}$ | Fitted model object | -| $\texttt{newdata}$ | New data frame or \texttt{sf} object | -| $\texttt{type}$ | Whether predictions are on the link or response scale | -| $\texttt{se.fit}$ | Whether standard errors should be returned | -| $\texttt{interval}$ | Interval type (prediction or confidence) | -| $\texttt{level}$ | Prediction or confidence level | -| $\texttt{local}$ | Options for large data sets | -| $\texttt{var_correct}$ | Whether prediction variances should be adjusted | -| $\texttt{...}$ | Additional arguments | - -: Arguments to predict() and their purpose. +| `object` | Fitted model object | +| `newdata` | New data frame or `sf` object | +| `type` | Whether predictions are on the link or response scale | +| `se.fit` | Whether standard errors should be returned | +| `interval` | Interval type (prediction or confidence) | +| `level` | Prediction or confidence level | +| `local` | Options for large data sets | +| `var_correct` | Whether prediction variances should be adjusted | +| `...` | Additional arguments | + +: Arguments to `predict()` and their purpose. ## Simulation {#sec:simulation} @@ -392,20 +392,20 @@ to simulate spatial data from Gaussian, binomial, beta, Poisson, negative binomial, gamma, and inverse Gaussian response distributions. These simulation functions are similar in structure to commonly used base **R** functions for simulating data. They are also similar in name, -simply adding an \texttt{sp} prefix to the conventional name in base -**R**. For example, \texttt{rpois()} is used to simulate Poisson data in -base **R**, while \texttt{sprpois()} is used to simulate spatial Poisson +simply adding an `sp` prefix to the conventional name in base +**R**. For example, `rpois()` is used to simulate Poisson data in +base **R**, while `sprpois()` is used to simulate spatial Poisson data in `spmodel`. These functions are summarized in the following table. | Function | Purpose | |------|------| -| $\texttt{sprnorm()}$ | Simulate spatial Gaussian data | -| $\texttt{sprbinom()}$ | Simulate spatial binomial data | -| $\texttt{sprbeta()}$ | Simulate spatial beta data | -| $\texttt{sprpois()}$ | Simulate spatial Poisson data | -| $\texttt{sprnbinom()}$ | Simulate spatial negative binomial data | -| $\texttt{sprgamma()}$ | Simulate spatial gamma data | -| $\texttt{sprinvgauss()}$ | Simulate spatial inverse Gaussian data | +| `sprnorm()` | Simulate spatial Gaussian data | +| `sprbinom()` | Simulate spatial binomial data | +| `sprbeta()` | Simulate spatial beta data | +| `sprpois()` | Simulate spatial Poisson data | +| `sprnbinom()` | Simulate spatial negative binomial data | +| `sprgamma()` | Simulate spatial gamma data | +| `sprinvgauss()` | Simulate spatial inverse Gaussian data | : Functions to simulate spatial data and their purpose. @@ -413,16 +413,16 @@ data in `spmodel`. These functions are summarized in the following table. In the next two sections we to show how to use `spmodel` to analyze data collected on moose in the Togiak region of Alaska, USA. The -\texttt{moose} data in `spmodel` contain information on moose counts +`moose` data in `spmodel` contain information on moose counts from a survey of sites in the Togiak region. The data are stored as an -`sf` object, a special \texttt{data.frame} built to store spatial data. -\texttt{moose} has several variables: \texttt{strat}; a stratification -variable with two levels (\texttt{L} for low and \texttt{M} for medium) -based on surrounding landscape metrics; \texttt{elev}, the site -elevation; \texttt{presence}, whether or not at least one moose was -observed at the site; \texttt{count}, the number of moose observed at a -the site; and \texttt{geometry}, the spatial coordinates in an Alaska -Albers projection (EPSG: 3338). We load `spmodel` and the \texttt{moose} +`sf` object, a special `data.frame` built to store spatial data. +`moose` has several variables: `strat`; a stratification +variable with two levels (`L` for low and `M` for medium) +based on surrounding landscape metrics; `elev`, the site +elevation; `presence`, whether or not at least one moose was +observed at the site; `count`, the number of moose observed at a +the site; and `geometry`, the spatial coordinates in an Alaska +Albers projection (EPSG: 3338). We load `spmodel` and the `moose` data by running ```{r} @@ -430,8 +430,8 @@ library("spmodel") data("moose") ``` -We are interested in quantifying the effects of \texttt{elev} and -\texttt{strat} on moose \texttt{presence} and begin with some +We are interested in quantifying the effects of `elev` and +`strat` on moose `presence` and begin with some visualizations. First, we visualize the presence for observed sites: ```{r moosepres, out.width="65%", fig.align="center", fig.cap="Moose presence."} @@ -466,9 +466,9 @@ eastern and southwestern parts of the domain. This spatial pattern seems to have a directional orientation, seemingly strongest in the northwest-to-southeast direction. -To quantify the effects of \texttt{elev}, \texttt{strat}, and spatial +To quantify the effects of `elev`, `strat`, and spatial dependence on moose presence, we fit three binomial (i.e., ) logistic -regression models using \texttt{spglm()}: +regression models using `spglm()`: ```{r} # model one @@ -498,9 +498,9 @@ bin_spmod_anis <- spglm( All three models have the same fixed effect structure, using elevation, strata, and their interaction to explain moose presence. The three models vary in their covariance structure. The first model, -\texttt{bin\_mod}, has no spatial covariance ($\sigma^2_{de} = 0$). The -second model, \texttt{bin\_spmod} has a spherical spatial covariance. -The third model, \texttt{bin\_spmod\_anis}, has a spherical spatial +`bin_mod`, has no spatial covariance ($\sigma^2_{de} = 0$). The +second model, `bin_spmod` has a spherical spatial covariance. +The third model, `bin_spmod_anis`, has a spherical spatial covariance that incorporates geometric anisotropy. Geometric anisotropy allows the spatial covariance to vary with direction by evaluating the spatial covariance with $\mathbf{H}^*$ (instead of $\mathbf{H}$), a @@ -512,22 +512,22 @@ three models using AIC by running AIC(bin_mod, bin_spmod, bin_spmod_anis) ``` -The spatial models (\texttt{bin\_spmod}, \texttt{bin\_spmod\_anis}) have -a much lower AIC than the non-spatial model (\texttt{bin\_mod}), which +The spatial models (`bin_spmod`, `bin_spmod_anis`) have +a much lower AIC than the non-spatial model (`bin_mod`), which suggests that the models benefit from incorporating spatial dependence. -\texttt{bin\_spmod\_anis} has a lower AIC than \texttt{bin\_spmod}, +`bin_spmod_anis` has a lower AIC than `bin_spmod`, which suggests that the model benefits from incorporating directionality -in the spatial dependence. Next we inspect \texttt{bin\_spmod\_anis} and +in the spatial dependence. Next we inspect `bin_spmod_anis` and later use it to predict moose presence probability at unobserved sites. -We summarize \texttt{bin\_spmod\_anis} using \texttt{summary()}: +We summarize `bin_spmod_anis` using `summary()`: ```{r} summary(bin_spmod_anis) ``` -The \texttt{summary()} output from an \texttt{spglm()} model is very -similar to the \texttt{summary()} output from a base-**R** -\texttt{glm()} model, returning the original function call, deviance +The `summary()` output from an `spglm()` model is very +similar to the `summary()` output from a base-**R** +`glm()` model, returning the original function call, deviance residuals, a fixed effects coefficients table, a pseudo R-squared (which quantifies the amount of variability explained by the fixed effects), and covariance parameter coefficients. The fixed effects coefficients @@ -535,12 +535,12 @@ table provides some evidence that elevation and strata are associated with with moose presence and that the effect of elevation varies across the two strata (all $p~$values $<$ 0.05). -The area under the receiver receiver operating characteristic (AUROC) curve quantifies the effectiveness of a classifier [@robin2011proc]. It ranges from zero to one, and higher values indicate better model performance. The AUROC of \texttt{bin\_spmod\_anis} is +The area under the receiver receiver operating characteristic (AUROC) curve quantifies the effectiveness of a classifier [@robin2011proc]. It ranges from zero to one, and higher values indicate better model performance. The AUROC of `bin_spmod_anis` is ```{r} AUROC(bin_spmod_anis) ``` -The \texttt{plot()} function +The `plot()` function returns graphics of several model diagnostics. Running ```{r, eval = FALSE} @@ -556,10 +556,10 @@ shows that the spatial dependence is evident and appears strongest in the northwest-to-southeast direction. These findings are supported by the clear spatial patterns in the data. -Recall that the \texttt{tidy()}, \texttt{glance()}, and -\texttt{augment()} functions are particularly useful tools for -manipulating and understanding fitted model objects. The \texttt{tidy()} -function tidies model output, returning a \texttt{tibble} of parameter +Recall that the `tidy()`, `glance()`, and +`augment() functions are particularly useful tools for +manipulating and understanding fitted model objects. The `tidy()` +function tidies model output, returning a `tibble` of parameter estimates (and confidence intervals): ```{r} @@ -567,32 +567,32 @@ tidy(bin_spmod_anis, conf.int = TRUE) ``` By default, the fixed effects estimates are returned, but covariance -parameter estimates are returned via the \texttt{effects} argument: +parameter estimates are returned via the `effects` argument: ```{r} tidy(bin_spmod_anis, effects = "spcov") ``` -The \texttt{is\_known} column indicates whether covariance parameters +The `is_known` column indicates whether covariance parameters were assumed known, which is possible to specify using the -\texttt{spcov\_initial} argument to \texttt{spglm()}. Here, all +`spcov_initial` argument to `spglm()`. Here, all parameters were assumed unknown and then estimated. -The \texttt{glance()} function glances at model fit, returning a -\texttt{tibble} of model fit statistics: +The `glance()` function glances at model fit, returning a +`tibble` of model fit statistics: ```{r} glance(bin_spmod_anis) ``` -\texttt{glances()} can be used to glance at multiple models +`glances()` can be used to glance at multiple models simultaneously and sorts models by ascending AICc: ```{r} glances(bin_mod, bin_spmod, bin_spmod_anis) ``` -The \texttt{augment()} function augments the data with model +The `augment()` function augments the data with model diagnostics: ```{r} @@ -600,17 +600,17 @@ aug_mod <- augment(bin_spmod_anis) aug_mod ``` -where \texttt{.fitted} are fitted values (the estimated -$f^{-1}(\mathbf{w})$, or moose presence probability), \texttt{.resid} -are response residuals, \texttt{.hat} values indicate leverage, -\texttt{.cooksd} values indicate Cook's distance (i.e., influence), and -\texttt{.std.resid} are standardized residuals. +where `.fitted` are fitted values (the estimated +$f^{-1}(\mathbf{w})$, or moose presence probability), `.resid` +are response residuals, `.hat` values indicate leverage, +`.cooksd` values indicate Cook's distance (i.e., influence), and +`.std.resid` are standardized residuals. -The \texttt{moose\_preds} data contains survey sites that were not -sampled. We can use \texttt{bin\_spmod\_anis} to make predictions of the +The `moose_preds` data contains survey sites that were not +sampled. We can use `bin_spmod_anis` to make predictions of the underlying probabilities of moose presence at these sites using -\texttt{predict()} or \texttt{augment()}. \texttt{predict()} and -\texttt{augment()} return the same predictions but \texttt{augment()} +`predict()` or `augment()`. `predict()` and +`augment()` return the same predictions but `augment()` augments the prediction data with the predictions: ```{r} @@ -633,10 +633,10 @@ aug_pred <- augment( aug_pred ``` -Estimated moose presence probability for the \texttt{moose} data -(obtained via \texttt{fitted()}) and predicted moose presence -probability for the \texttt{moose\_preds} data (obtained via -\texttt{predict()} or \texttt{augment()}) are overlain below and share +Estimated moose presence probability for the `moose` data +(obtained via `fitted()`) and predicted moose presence +probability for the `moose_preds` data (obtained via +`predict()` or `augment()`) are overlain below and share similar patterns: ```{r bin, out.width="65%", fig.align="center", fig.cap="Fitted values and predictions for moose presence probability."} @@ -652,7 +652,7 @@ ggplot(aug_combined, aes(color = .fitted, shape = type)) + # An application to count data {#sec:application-count} -The \texttt{moose} data also contain the number of moose observed at +The `moose` data also contain the number of moose observed at each site: ```{r moose, out.width="65%", fig.align="center", fig.cap="Moose counts."} @@ -668,13 +668,13 @@ models, Poisson and negative binomial. The Poisson model assumes the underlying process generating the counts has the same mean and variance while the negative binomial model allows for overdispersion (i.e., the variance is greater than the mean). We are interested in quantifying the -effects of \texttt{elev} and \texttt{strat} on moose `count`, albeit +effects of `elev` and `strat` on moose `count`, albeit using a slightly different approach than we did for moose `presence`. Here, we will model elevation as a fixed effect and allow this effect to change between strata, but we will model strata as a random effect to highlight additional flexibility of the `spmodel` package. We fit relevant Poisson and negative binomial models with a Matérn spatial -covariance using \texttt{spglm()}: +covariance using `spglm()`: ```{r} count_mod_pois <- spglm( @@ -694,11 +694,11 @@ count_mod_nb <- spglm( ) ``` -Random effects are specified in `spmodel` via the \texttt{random} +Random effects are specified in `spmodel` via the `random` argument using similar syntax as the commonly used `lme4` [@bates2015lme4] and `nlme` [@pinheiro2006mixed] **R** packages for -non-spatial mixed models. In `spmodel`, \texttt{~ strat} is short-hand -for \texttt{~ (1 | strat)}. Random effects alter the covariance +non-spatial mixed models. In `spmodel`, `~ strat` is short-hand +for `~ (1 | strat)`. Random effects alter the covariance structure of the model, building additional correlation into the model for sites sharing a level of the random effect (here, sites within the same strata). More formally, when incorporating a random effect, the @@ -711,7 +711,7 @@ $\text{Cov}(\mathbf{v}) = \sigma^2_{v}\mathbf{I}$. Then the covariance matrix, $\boldsymbol{\Sigma}$, becomes $\sigma^2_v \mathbf{Z} \mathbf{Z}^\top + \sigma^2_{de}\mathbf{R} + \sigma^2_{ie}\mathbf{I}$. -Previously we compared models using \texttt{AIC()}, but another way to +Previously we compared models using `AIC()`, but another way to compare models is by leave-one-out cross validation [@hastie2009elements]. In leave-one-out cross validation, each observation is held-out and the model is re-fit and used to predict the @@ -735,7 +735,7 @@ $< 0.1$): tidy(count_mod_nb) ``` -The \texttt{varcomp()} function in `spmodel` apportions model +The `varcomp()` function in `spmodel` apportions model variability into fixed and random components: ```{r} @@ -743,8 +743,8 @@ varcomp(count_mod_nb) ``` Most model variability is explained by the spatially dependent random -error (\texttt{de}) and the random effect for strata -(\texttt{1 | strat}). Running +error (`de`) and the random effect for strata +(`1 | strat`). Running ```{r, eval = FALSE} plot(count_mod_nb, which = c(4, 5)) @@ -758,10 +758,10 @@ plot(count_mod_nb, which = 5) shows observations of high influence or leverage and that the standardized residuals tend to be spread out around zero. -Estimated mean moose counts for the \texttt{moose} data (obtained via -\texttt{fitted()}) and predicted mean moose counts for the -\texttt{moose\_preds} data (obtained via \texttt{predict()} or -\texttt{augment()}) share similar patterns and are overlain by running +Estimated mean moose counts for the `moose` data (obtained via +`fitted()`) and predicted mean moose counts for the +`moose_preds` data (obtained via `predict()` or +`augment()`) share similar patterns and are overlain by running ```{r nb, out.width="65%", fig.align="center", fig.cap="Fitted values and predictions for moose counts."} aug_mod <- augment(count_mod_nb) @@ -780,18 +780,18 @@ ggplot(aug_combined, aes(color = .fitted, shape = type)) + Throughout this vignette, we have shown several features `spmodel` offers, including a novel application of the Laplace approximation, -similarity to base **R**'s \texttt{glm()} function, over a dozen spatial +similarity to base **R**'s `glm()` function, over a dozen spatial covariance functions, a variety of tools available to evaluate models, inspect model diagnostics, and make predictions using ubiquitous base -**R** functions (e.g., \texttt{summary()}, \texttt{plot()}, and -\texttt{predict()}) and more. Spatial generalized linear models for +**R** functions (e.g., `summary()`, `plot()`, and +`predict()`) and more. Spatial generalized linear models for point-referenced data (i.e., generalized geostatistical models) are fit -using the \texttt{spglm()} function. Spatial generalized linear models +using the `spglm()` function. Spatial generalized linear models for areal data (i.e., generalized spatial autoregressive models) are fit -using the \texttt{spgautor()} function. Both functions share common +using the `spgautor()` function. Both functions share common structure and syntax. Spatial data are simulated in `spmodel` by adding -an \texttt{sp} prefix to commonly used base **R** simulation functions -(e.g., \texttt{sprbinom()}). +an `sp` prefix to commonly used base **R** simulation functions +(e.g., `sprbinom()`). We appreciate feedback from users regarding `spmodel`. To learn more about how to provide feedback or contribute to `spmodel`, please visit diff --git a/vignettes/articles/block.Rmd b/vignettes/articles/block.Rmd index 602d3dc..c900bc1 100644 --- a/vignettes/articles/block.Rmd +++ b/vignettes/articles/block.Rmd @@ -25,7 +25,7 @@ set.seed(0) # Introduction {#sec:introduction} -`spmodel` is a \textbf{\textsf{R}} package used to fit, summarize, and +`spmodel` is a **R** package used to fit, summarize, and predict for a variety of spatial statistical models. This vignette explores tools for predicting the average value of a response variable in a particular geographic region, an approach known as Block Prediction (i.e., Block Kriging) [@cressie1993statistics; @ver2008spatial]. Before proceeding, we load `spmodel`, `sf`, and `ggplot2` by running diff --git a/vignettes/articles/emmeans.Rmd b/vignettes/articles/emmeans.Rmd index 3dcb42c..192e5ee 100644 --- a/vignettes/articles/emmeans.Rmd +++ b/vignettes/articles/emmeans.Rmd @@ -22,7 +22,7 @@ library(emmeans) # Introduction {#sec:introduction} -`spmodel` is an \textbf{\textsf{R}} package used to fit, summarize, and +`spmodel` is an **R** package used to fit, summarize, and predict for a variety of spatial statistical models. The vignette provides an estimating marginal means (i.e., least-squares means) of `spmodel` objects using the `emmeans`. **R** package [@lenth2024emmeans]. Before proceeding, we diff --git a/vignettes/articles/guide.Rmd b/vignettes/articles/guide.Rmd index 0a6b42f..4855cd1 100644 --- a/vignettes/articles/guide.Rmd +++ b/vignettes/articles/guide.Rmd @@ -22,7 +22,7 @@ library(spmodel) # Introduction {#sec:introduction} -`spmodel` is an \textbf{\textsf{R}} package used to fit, summarize, and predict for a variety of spatial statistical models. The vignette provides an introduction to both the basic and advanced features of the `spmodel` package coupled with a brief theoretical explanation of the methods. First we give a brief theoretical introduction to spatial linear models. Then we outline the variety of methods used to estimate the parameters of spatial linear models. Then we explain how to obtain predictions at unobserved locations. Then we detail some advanced modeling features, including random effects, partition factors, anisotropy, big data approaches, and spatial generalized linear models. Finally we end with a short discussion. Before proceeding, we load `spmodel` by running +`spmodel` is an **R** package used to fit, summarize, and predict for a variety of spatial statistical models. The vignette provides an introduction to both the basic and advanced features of the `spmodel` package coupled with a brief theoretical explanation of the methods. First we give a brief theoretical introduction to spatial linear models. Then we outline the variety of methods used to estimate the parameters of spatial linear models. Then we explain how to obtain predictions at unobserved locations. Then we detail some advanced modeling features, including random effects, partition factors, anisotropy, big data approaches, and spatial generalized linear models. Finally we end with a short discussion. Before proceeding, we load `spmodel` by running ```{r, eval = FALSE} library(spmodel) ``` @@ -277,7 +277,7 @@ Though we described the model diagnostics in this subsection using $\boldsymbol{ ## The broom functions: `tidy()`, `glance()`, and `augment()` -The `tidy()`, `glance()`, and `augment()` functions from the broom \textbf{\textsf{R}} package [@robinson2021broom] provide convenient output for many of the model fit and diagnostic metrics discussed in the previous two sections. The `tidy()` function returns a tidy tibble of the coefficient table from `summary()`: +The `tidy()`, `glance()`, and `augment()` functions from the broom **R** package [@robinson2021broom] provide convenient output for many of the model fit and diagnostic metrics discussed in the previous two sections. The `tidy()` function returns a tidy tibble of the coefficient table from `summary()`: ```{r} tidy(spmod) ``` @@ -500,7 +500,7 @@ predict(spmods, newdata = sulfate_preds) ## Random Effects -Non-spatial random effects incorporate additional sources of variability into model fitting. They are accommodated in `spmodel` using similar syntax as for random effects in the `nlme` [@pinheiro2006mixed] and `lme4` [@bates2015lme4] \textbf{\textsf{R}} packages. Random effects are specified via a formula passed to the `random` argument. Next we show two examples that incorporate random effects into the spatial linear model using the `moss` data. +Non-spatial random effects incorporate additional sources of variability into model fitting. They are accommodated in `spmodel` using similar syntax as for random effects in the `nlme` [@pinheiro2006mixed] and `lme4` [@bates2015lme4] **R** packages. Random effects are specified via a formula passed to the `random` argument. Next we show two examples that incorporate random effects into the spatial linear model using the `moss` data. The first example explores random intercepts for the `sample` variable. The `sample` variable indexes each unique location, which can have replicate observations due to field duplicates (`field_dup`) and lab replicates (`lab_rep`). There are 365 observations in `moss` at 318 unique locations, which means that 47 observations in `moss` are either field duplicates or lab replicates. It is likely that the repeated observations at a location are correlated with one another. We can incorporate this repeated-observation correlation by creating a random intercept for each level of `sample`. We model the random intercepts for `sample` by running ```{r} @@ -597,7 +597,7 @@ summary(spmod_anis) The `rotate` parameter is between zero and $\pi$ radians and represents the angle of a clockwise rotation of the ellipse such that the major axis of the ellipse is the new x-axis and the minor axis of the ellipse is the new y-axis. The `scale` parameter is between zero and one and represents the ratio of the distance between the origin and the edge of the ellipse along the minor axis to the distance between the origin and the edge of the ellipse along the major axis. Below shows a transformation that turns an anisotropic ellipse into an isotropic one (i.e., a circle). This transformation requires rotating the coordinates clockwise by `rotate` and then scaling them the reciprocal of `scale`. The transformed coordinates are then used instead of the original coordinates to compute distances and spatial covariances. -```{r, anisotropy_fit, echo = FALSE, out.width = "33%", fig.show = "hold", fig.cap = "A visual representation of the anisotropy transformation. In the left figure, the first step is to rotate the anisotropic ellipse clockwise by the \\texttt{rotate} parameter (here \\texttt{rotate} is 0.75$\\pi$ radians or 135 degrees). In the middle figure, the second step is to scale the y axis by the reciprocal of the \\texttt{scale} parameter (here \\texttt{scale} is 0.5). In the right figure, the anisotropic ellipse has been transformed into an isotropic one (i.e., a circle). The transformed coordinates are then used instead of the original coordinates to compute distances and spatial covariances."} +```{r, anisotropy_fit, echo = FALSE, out.width = "33%", fig.show = "hold", fig.cap = "A visual representation of the anisotropy transformation. In the left figure, the first step is to rotate the anisotropic ellipse clockwise by the `rotate` parameter (here `rotate` is 0.75$\\pi$ radians or 135 degrees). In the middle figure, the second step is to scale the y axis by the reciprocal of the `scale` parameter (here `scale` is 0.5). In the right figure, the anisotropic ellipse has been transformed into an isotropic one (i.e., a circle). The transformed coordinates are then used instead of the original coordinates to compute distances and spatial covariances."} spcov_params_val <- coef(spmod_anis, type = "spcov") # FIRST FIGURE theta <- 3 * pi / 4 diff --git a/vignettes/articles/technical.Rmd b/vignettes/articles/technical.Rmd index c36cc91..95c751d 100644 --- a/vignettes/articles/technical.Rmd +++ b/vignettes/articles/technical.Rmd @@ -112,9 +112,9 @@ AIC comparisons between a model fit using restricted maximum likelihood and a mo ## `anova()` {#sec:anova-lm} -Test statistics from \texttt{anova()} are formed using the general linear hypothesis test. Let $\mathbf{L}$ be an $l \times p$ contrast matrix and $l_0$ be an $l \times 1$ vector. The null hypothesis is that $\mathbf{L} \boldsymbol{\hat{\beta}} = l_0$ and the alternative hypothesis is that $\mathbf{L} \boldsymbol{\hat{\beta}} \neq l_0$. Usually, $l_0$ is the zero vector (in `spmodel`, this is assumed). The test statistic is denoted $Chi2$ and is given by \begin{equation*}\label{eq:glht} +Test statistics from `anova()` are formed using the general linear hypothesis test. Let $\mathbf{L}$ be an $l \times p$ contrast matrix and $l_0$ be an $l \times 1$ vector. The null hypothesis is that $\mathbf{L} \boldsymbol{\hat{\beta}} = l_0$ and the alternative hypothesis is that $\mathbf{L} \boldsymbol{\hat{\beta}} \neq l_0$. Usually, $l_0$ is the zero vector (in `spmodel`, this is assumed). The test statistic is denoted $Chi2$ and is given by \begin{equation*}\label{eq:glht} Chi2 = [(\mathbf{L} \boldsymbol{\hat{\beta}} - l_0)^\top(\mathbf{L} (\mathbf{X}^\top \mathbf{\hat{\Sigma}} \mathbf{X})^{-1} \mathbf{L}^\top)^{-1}(\mathbf{L} \boldsymbol{\hat{\beta}} - l_0)] -\end{equation*} By default, $\mathbf{L}$ is chosen such that each variable in the data used to fit the model is tested marginally (i.e., controlling for the other variables) against $l_0 = \mathbf{0}$. If this default is not desired, the \texttt{Terms} and \texttt{L} arguments can be used to pass user-defined $\mathbf{L}$ matrices to \texttt{anova()}. They must be constructed in such a way that $l_0 = \mathbf{0}$. +\end{equation*} By default, $\mathbf{L}$ is chosen such that each variable in the data used to fit the model is tested marginally (i.e., controlling for the other variables) against $l_0 = \mathbf{0}$. If this default is not desired, the `Terms` and `L` arguments can be used to pass user-defined $\mathbf{L}$ matrices to `anova()`. They must be constructed in such a way that $l_0 = \mathbf{0}$. It is notoriously difficult to determine appropriate p-values for linear mixed models based on the general linear hypothesis test. lme4, for example, does not report p-values by default. A few reasons why obtaining p-values is so challenging: @@ -364,7 +364,7 @@ When `interval = "prediction"`, the (100 $\times$ `level`)% prediction interval When `interval = "confidence"`, the average process mean (i.e., not the realized mean) and uncertainties are returned from the underlying model. The (process) mean estimate is $\mathbf{X}_{B} \hat{\boldsymbol{\beta}}$ and a (100 $\times$ `level`)% confidence interval is $\mathbf{X}_{B} \hat{\boldsymbol{\beta}} \pm z^* \sqrt{\mathbf{X}_{B} (\mathbf{X}^\top_o \hat{\boldsymbol{\Sigma}}_o^{-1} \mathbf{X}_o)^{-1} \mathbf{X}_{B}^\top}$. -For Big Data, when `local = TRUE`, the same approach is applied as for point prediction but adjusted slightly to accommodate the averaging necessary for Block Prediction. Thus, when `method = "covariance"` (the default), the `size` observations having the highest average covariance with elements of $\mathbf{y}_o$ are used to find the subsets $\check{\mathbf{X}}_o$, $\check{\boldsymbol{\Sigma}}_o$, and $\check{\mathbf{y}}_o$. When `method = "distance"`, the `size` observations having the smallest average distance from elements of $\mathbf{y}_o$ are used to find the subsets $\check{\mathbf{X}}_o$, $\check{\boldsymbol{\Sigma}}_o$, and $\check{\mathbf{y}}_o$. Recall that these two methods are equivalent for processes without anisotropy, random effects, or partition factors, but can differ otherwise. The default is `size = 1000`, which is much larger than for point prediction. This is because for Block Prediction, the Cholesky decomposition of $\check{\boldsymbol{\Sigma}}_o$ needs to only be computed once (rather than separately for each $\check{\boldsymbol{\Sigma}}_o$ associated with each prediction location, as for point prediction). +For Big Data, when `local = TRUE`, the same approach is applied as for point prediction but adjusted slightly to accommodate the averaging necessary for Block Prediction. Thus, when `method = "covariance"` (the default), the `size` observations of $\mathbf{y}_o$ having the highest average covariance with elements of the fine grid are used to find the subsets $\check{\mathbf{X}}_o$, $\check{\boldsymbol{\Sigma}}_o$, and $\check{\mathbf{y}}_o$. When `method = "distance"`, the `size` observations of of $\mathbf{y}_o$ having the smallest average distance to elements of the fine grid are used to find the subsets $\check{\mathbf{X}}_o$, $\check{\boldsymbol{\Sigma}}_o$, and $\check{\mathbf{y}}_o$. Recall that these two methods are equivalent for processes without anisotropy, random effects, or partition factors, but can differ otherwise. The default is `size = 1000`, which is much larger than for point prediction. This is because for Block Prediction, the Cholesky decomposition of $\check{\boldsymbol{\Sigma}}_o$ needs to only be computed once (rather than separately for each $\check{\boldsymbol{\Sigma}}_o$ associated with each prediction location, as for point prediction). Currently, the fine grid used to obtain Block Predictions is supplied by the user via `newdata`. For an overview of Block Prediction, see @cressie1993statistics. For applications to a finite population (i.e., a region with a finite number of point locations), see @ver2008spatial and @dumelle2022comparison. @@ -453,8 +453,8 @@ where $\sigma^2_{de}$ $(\geq 0)$ is the spatially dependent (correlated) varianc | Spatial covariance type | $\mathbf{R}$ functional form | |---------------------------------|---------------------------------------| -| $\texttt{"car"}$ | $(\mathbf{I} - \phi\mathbf{W})^{-1}\mathbf{M}$ | -| $\texttt{"sar"}$ | $[(\mathbf{I} - \phi\mathbf{W})(\mathbf{I} - \phi\mathbf{W})^\top]^{-1}$ | +| `"car"` | $(\mathbf{I} - \phi\mathbf{W})^{-1}\mathbf{M}$ | +| `"sar"` | $[(\mathbf{I} - \phi\mathbf{W})(\mathbf{I} - \phi\mathbf{W})^\top]^{-1}$ | : The forms of R for each spatial covariance type available in spautor() @@ -472,24 +472,24 @@ For point-referenced data, the spatial covariance is given by \begin{equation*} | Spatial Covariance Type | R Functional Form | |-----------------------------------------|-------------------------------| -| $\texttt{"exponential"}$ | $e^{-\eta}$ | -| $\texttt{"spherical"}$ | $(1 - 1.5\eta + 0.5\eta^3)\mathcal{I}\{h \leq \phi \}$ | -| $\texttt{"gaussian"}$ | $e^{-\eta^2}$ | -| $\texttt{"triangular"}$ | $(1 - \eta)\mathcal{I}\{h \leq \phi \}$ | -| $\texttt{"circular"}$ | $(1 - \frac{2}{\pi}[m\sqrt{1 - m^2} + sin^{-1}\{m\}])\mathcal{I}\{h \leq \phi \}, m = min(\eta, 1)$ | -| $\texttt{"cubic"}$ | $(1 - 7\eta^2 + 8.75\eta^3 - 3.5\eta^5 + 0.75 \eta^7)\mathcal{I}\{h \leq \phi \}$ \\ | -| $\texttt{"pentaspherical"}$ | $(1 - 1.875\eta + 1.250\eta^3 - 0.375\eta^5)\mathcal{I}\{h \leq \phi \}$ \\ | -| $\texttt{"cosine"}$ | $ cos(\eta) $ | -| $\texttt{"wave"}$ | $\frac{sin(\eta)}{\eta}\mathcal{I}\{h > 0 \} + \mathcal{I}\{h = 0 \}$ | -| $\texttt{"jbessel"}$ | $B_j(h\phi), B_j$ is Bessel-J | -| $\texttt{"gravity"}$ | $(1 + \eta^2)^{-1/2}$ | -| $\texttt{"rquad"}$ | $(1 + \eta^2)^{-1}$ | -| $\texttt{"magnetic"}$ | $(1 + \eta^2)^{-3/2}$ | -| $\texttt{"matern"}$ | $\frac{2^{(1 - \xi)}}{\Gamma(\xi)} \alpha^\xi B_k(\alpha, \xi), \alpha = \sqrt{2\xi \eta}, B_k$ is Bessel-K with order $\xi$, $\xi \in [1/5, 5]$ | -| $\texttt{"cauchy"}$ | $(1 + \eta^2)^{-\xi}$, $\xi > 0$ | -| $\texttt{"pexponential"}$ | $exp(-h^\xi / \phi)$, $\xi \in (0, 2]$ | -| $\texttt{"none"}$ | $0$ | -| $\texttt{"ie"}$ | $0$ | +| `"exponential"` | $e^{-\eta}$ | +| `"spherical"` | $(1 - 1.5\eta + 0.5\eta^3)\mathcal{I}\{h \leq \phi \}$ | +| `"gaussian"` | $e^{-\eta^2}$ | +| `"triangular"` | $(1 - \eta)\mathcal{I}\{h \leq \phi \}$ | +| `"circular"` | $(1 - \frac{2}{\pi}[m\sqrt{1 - m^2} + sin^{-1}\{m\}])\mathcal{I}\{h \leq \phi \}, m = min(\eta, 1)$ | +| `"cubic"` | $(1 - 7\eta^2 + 8.75\eta^3 - 3.5\eta^5 + 0.75 \eta^7)\mathcal{I}\{h \leq \phi \}$ \\ | +| `"pentaspherical"` | $(1 - 1.875\eta + 1.250\eta^3 - 0.375\eta^5)\mathcal{I}\{h \leq \phi \}$ \\ | +| `"cosine"` | $ cos(\eta) $ | +| `"wave"` | $\frac{sin(\eta)}{\eta}\mathcal{I}\{h > 0 \} + \mathcal{I}\{h = 0 \}$ | +| `"jbessel"` | $B_j(h\phi), B_j$ is Bessel-J | +| `"gravity"` | $(1 + \eta^2)^{-1/2}$ | +| `"rquad"` | $(1 + \eta^2)^{-1}$ | +| `"magnetic"` | $(1 + \eta^2)^{-3/2}$ | +| `"matern"` | $\frac{2^{(1 - \xi)}}{\Gamma(\xi)} \alpha^\xi B_k(\alpha, \xi), \alpha = \sqrt{2\xi \eta}, B_k$ is Bessel-K with order $\xi$, $\xi \in [1/5, 5]$ | +| `"cauchy"` | $(1 + \eta^2)^{-\xi}$, $\xi > 0$ | +| `"pexponential"` | $exp(-h^\xi / \phi)$, $\xi \in (0, 2]$ | +| `"none"` | $0$ | +| `"ie"` | $0$ | : The forms of R for each spatial covariance type available in splm(). All spatial covariance functions are valid in two dimensions except the triangular and cosine functions, which are only valid in one dimension. An alias for none is ie. @@ -533,16 +533,16 @@ The empirical semivariogram is a moment-based estimate of the semivariogram deno @cressie1985fitting recommends setting $w_i = |N(h)| / \gamma(h)_i^2$, which gives more weight to distance classes with more observations ($|N(h)|$) and shorter distances ($1 / \gamma(h)_i^2$). The default in `spmodel` is to use these $w_i$, known as Cressie weights, though several other options for $w_i$ exist and are available via the `weights` argument. The following table contains all $w_i$ available via the `weights` argument. -| $w_i$ Name | $w_i$ Form | $\texttt{weight =}$ | +| $w_i$ Name | $w_i$ Form | `weight =` | |--------------------------|-----------------------|-----------------------| -| Cressie | $|N(h)| / \gamma(h)_i^2$ | $\texttt{"cressie"}$ | -| Cressie (Denominator) Root | $|N(h)| / \gamma(h)_i$ | $\texttt{"cressie-dr"}$ | -| Cressie No Pairs | $1 / \gamma(h)_i^2$ | $\texttt{"cressie-nopairs"}$ | -| Cressie (Denominator) Root No Pairs | $1 / \gamma(h)_i$ | $\texttt{"cressie-dr-nopairs"}$ | -| Pairs | $|N(h)|$ | $\texttt{pairs"}$ | -| Pairs Inverse Distance | $|N(h)| / h^2$ | $\texttt{"pairs-invd"}$ | -| Pairs Inverse (Root) Distance | $|N(h)| / h$ | $\texttt{"pairs-invrd"}$ | -| Ordinary Least Squares | 1 | $\texttt{"ols"}$ | +| Cressie | $|N(h)| / \gamma(h)_i^2$ | `"cressie"` | +| Cressie (Denominator) Root | $|N(h)| / \gamma(h)_i$ | `"cressie-dr"` | +| Cressie No Pairs | $1 / \gamma(h)_i^2$ | `"cressie-nopairs"` | +| Cressie (Denominator) Root No Pairs | $1 / \gamma(h)_i$ | `"cressie-dr-nopairs"` | +| Pairs | $|N(h)|$ | `"pairs"` | +| Pairs Inverse Distance | $|N(h)| / h^2$ | `"pairs-invd"` | +| Pairs Inverse (Root) Distance | $|N(h)| / h$ | `"pairs-invrd"` | +| Ordinary Least Squares | 1 | `"ols"` | : Table of values for the weights argument in splm() when estmethod = "sv-wls". diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index eb79b7c..4bac858 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -33,7 +33,7 @@ library(spmodel) # Introduction -The `spmodel` package is used to fit and summarize spatial models and make predictions at unobserved locations (Kriging). This vignette provides an overview of basic features in `spmodel`. We load `spmodel` by running +The `spmodel` **R** package is used to fit and summarize spatial models and make predictions at unobserved locations (Kriging). This vignette provides an overview of basic features in `spmodel`. We load `spmodel` by running ```{r, eval = FALSE} library(spmodel) ```