sf_distrib: Test Overdispersion and Zero Inflation in Size and Fecundity...

View source: R/popchar.R

sf_distribR Documentation

Test Overdispersion and Zero Inflation in Size and Fecundity Distributions

Description

Function sf_distrib takes a historically formatted vertical data as input and tests whether size and fecundity data are dispersed according to a Poisson distribution (where mean = variance), and whether the number of 0s exceeds expectations. This function is now deprecated in favor of function hfv_qc().

Usage

sf_distrib(
  data,
  sizea = NA,
  sizeb = NA,
  sizec = NA,
  obs3 = NA,
  fec = NA,
  repst = NA,
  zisizea = TRUE,
  zisizeb = TRUE,
  zisizec = TRUE,
  zifec = TRUE,
  fectime = 2,
  show.size = TRUE,
  show.fec = TRUE
)

Arguments

data

A historical vertical data file, which is a data frame of class hfvdata.

sizea

A vector holding the name or column number of the variables corresponding to primary size in occasions t+1 and t. Input only if sizea is to be tested.

sizeb

A vector holding the name or column number of the variables corresponding to secondary size in occasions t+1 and t. Input only if sizeb is to be tested.

sizec

A vector holding the name or column number of the variables corresponding to tertiary size in occasions t+1 and t. Input only if sizec is to be tested.

obs3

The name or column number of the variable corresponding to observation status in occasion t+1. This should be used if observation status will be used as a vital rate to absorb states of size = 0.

fec

A vector holding the names or column numbers of the variables corresponding to in occasions t+1 and t. Input only if fec is to be tested.

repst

A vector holding the names or column numbers of the variables corresponding to reproductive status in occasions t+1 and t. If not provided, then fecundity will be tested without subsetting to only reproductive individuals.

zisizea

A logical value indicating whether to conduct a test of zero inflation in primary size. Defaults to TRUE.

zisizeb

A logical value indicating whether to conduct a test of zero inflation in secondary size. Defaults to TRUE.

zisizec

A logical value indicating whether to conduct a test of zero inflation in tertiary size. Defaults to TRUE.

zifec

A logical value indicating whether to conduct a test of zero inflation in fecundity. Defaults to TRUE.

fectime

An integer indicating whether to treat fecundity as occurring in time t (2) or time t+1 (3). Defaults to 2.

show.size

A logical value indicating whether to show the output for tests of size. Defaults to TRUE.

show.fec

A logical value indicating whether to show the output for tests of fecundity. Defaults to TRUE.

Value

Produces text describing the degree and significance of difference from expected dispersion, and the degree and significance of zero inflation. The tests are chi-squared score tests based on the expectations of mean = variance, and 0s as abundant as predicted by the value of lambda estimated from the dataset. See van der Broek (1995) for more details.

Notes

This function subsets the data in the same way as modelsearch() before testing underlying distributions, making the output much more appropriate than a simple analysis of size and fecundity variables in data.

The specific test used for overdispersion is a chi-squared test of the dispersion parameter estimated using a generalized linear model predicting the response given size in occasion t, under a quasi-Poisson distribution.

The specific test used for zero-inflation is the chi-squared test presented in van der Broek (1995).

Examples

data(lathyrus)

sizevector <- c(0, 4.6, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8,
  9)
stagevector <- c("Sd", "Sdl", "Dorm", "Sz1nr", "Sz2nr", "Sz3nr", "Sz4nr",
  "Sz5nr", "Sz6nr", "Sz7nr", "Sz8nr", "Sz9nr", "Sz1r", "Sz2r", "Sz3r",
  "Sz4r", "Sz5r", "Sz6r", "Sz7r", "Sz8r", "Sz9r")
repvector <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1)
obsvector <- c(0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
matvector <- c(0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
immvector <- c(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
propvector <- c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  0)
indataset <- c(0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
binvec <- c(0, 4.6, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5,
  0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5)

lathframeln <- sf_create(sizes = sizevector, stagenames = stagevector,
  repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
  immstatus = immvector, indataset = indataset, binhalfwidth = binvec,
  propstatus = propvector)

lathvertln <- verticalize3(lathyrus, noyears = 4, firstyear = 1988,
  patchidcol = "SUBPLOT", individcol = "GENET", blocksize = 9,
  juvcol = "Seedling1988", sizeacol = "lnVol88", repstracol = "Intactseed88",
  fecacol = "Intactseed88", deadacol = "Dead1988",
  nonobsacol = "Dormant1988", stageassign = lathframeln, stagesize = "sizea",
  censorcol = "Missing1988", censorkeep = NA, NAas0 = TRUE, censor = TRUE)

lathvertln$feca2 <- round(lathvertln$feca2)
lathvertln$feca1 <- round(lathvertln$feca1)
lathvertln$feca3 <- round(lathvertln$feca3)

sf_distrib(lathvertln, sizea = c("sizea3", "sizea2"), fec = c("feca3", "feca2"),
  repst = c("repstatus3", "repstatus2"), zifec = FALSE)


lefko3 documentation built on Oct. 14, 2023, 1:07 a.m.