bootstrap_gof: Get reference distribution for goodness of fit statistics for...

Description Usage Arguments

View source: R/bootstrap_gof.R

Description

Get reference distribution for goodness of fit statistics for the spatial residuals of a MRF model.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
bootstrap_gof(
  data,
  conclique_cover,
  neighbors,
  inits,
  conditional_sampler,
  conditional_cdf,
  fit_model,
  params0,
  B = 1000,
  statistic = c("ks", "cvm"),
  aggregate = c("mean", "max"),
  quantiles = NULL,
  plot.include = FALSE
)

Arguments

data

A vector containing data values for each location in the lattice.

conclique_cover

A list of class "conclique_cover" encoding the locations in each conclique for the conclique cover

neighbors

A matrix N*N by (max # neighbors) + 1, where the first column is the location id of each location in the lattice. This could be the result from get_neighbors().

inits

Initial values for the lattice, formatted as a grid.

conditional_sampler

The string name of a function that has two inputs:

  • data, and

  • params.

There are three built in samplers:

  • "gaussian_single_param" - a Gaussian sampler with a single dependence parameter,

  • "binary_single_param" - a binary sampler with a single dependence parameter, and

  • "binary_two_param" - a binary sampler with two dependence parameters.

If the user chooses to write their own sampler in R, they must pass the name of the sampler that is available in the gloabl environment as this parameter. The input "data" is a list containing two elements, sums and nums which contain the sum of the data in each neighborhood as well as the number of locations in the neighborhood for each point in the conclique. The input "params" is a list of parameter values. This function returns a value sampled from the specified conditional distribution given the data and parameters passed.

conditional_cdf

A function that has two inputs:

  • data, and

  • params.

There are three built in cdfs:

  • "gaussian_single_param" - a Gaussian cdf with a single dependence parameter,

  • "binary_single_param" - a binary cdf with a single dependence parameter, and

  • "binary_two_param" - a binary cdf with two dependence parameters.

If the user chooses to write their own cdf in R, they must pass the name of the cdf function that is available in the global environment as this parameter. The input "data" is a list containing at least two elements, sums and nums which contain the sum of the data in each neighborhood as well as the number of locations in the neighborhood for each point in the conclique. In addition, the data can contain two additional elements, u and v, which are vectors that contain the horizontal and vertical location of each point in space. The input "params" is a list of parameter values. This function returns the inverse cdf at a value between 0 and 1 from the conditional distribution

fit_model

A function that has three inputs:

  • data

  • neighbors, and

  • params0.

The input "data" is a vector containing data values for each location in the lattice. The input "neighbors" is a matrix N*N by (max # neighbors) + 1, where the first column is the location id of each location in the lattice. The input "params0" is a list of parameter values. This function should return a list of fitted parameter values with the same name is params0.

params0

A named list of parameter initialization points.

B

The number of bootstrap samples to take, defaults to 1000

statistic

Which goodness of fit statistic to use, Kolmogorov-Smirnov ("ks") or Cramer von Mises ("cvm"). Kolmogorov-Smirnov is the default choice.

aggregate

How to aggregate GOF statistics across concliques, mean ("mean") or max ("max"). Mean is the default. Can also be a name of a user defined aggregation function

quantiles

(Optional) A vector of quantiles to return from the reference distribution. If NULL (default), no quantiles are returned

plot.include

TRUE/FALSE parameterizing if a plot of the distribution is returned.


andeek/conclique documentation built on Dec. 26, 2021, 3:12 a.m.