betta_random {breakaway}R Documentation

modelling total diversity with random effects

Description

This function extends betta() to permit random effects modelling.

Usage

betta_random(
  chats = NULL,
  ses,
  X = NULL,
  groups = NULL,
  formula = NULL,
  data = NULL,
  p.digits = 3
)

Arguments

chats

A vector of estimates of total diversity at different sampling locations. Required with the groups argument, and optionally with the X argument.

ses

The standard errors in chats, the diversity estimates. This can either be a vector of standard errors (with the arguments chats and X), or the name of the variable in the dataframe data that contains the standard errors (with the arguments formula and data).

X

A numeric matrix of covariates corresponding to fixed effects. If not supplied, an intercept-only model will be fit. Optional with the chats and groups arguments.

groups

A categorical variable representing the random-effects groups that each of the estimates belong to. Required with the chats argument and optionally with the X argument.

formula

A formula object of the form y ~ x | group. Required with the data argument.

data

A dataframe containing the response, response standard errors, covariates, and grouping variable. Required with the formula argument.

p.digits

(Optional) A number that specifies the number of digits to which p-values will be rounded. The default value is 3 digits.

Value

table

A coefficient table for the model parameters. The columns give the parameter estimates, standard errors, and p-values, respectively. This model is only as effective as your diversity estimation procedure; for this reason please confirm that your estimates are appropriate and that your model is not misspecified. betta_pic may be useful for this purpose.

cov

Estimated covariance matrix of the parameter estimates.

ssq_u

The estimate of the heterogeneity variance.

ssq_g

Estimates of within-group variance. The estimate will be zero for groups with only one observation.

homogeneity

The test statistic and p-value for the test of homogeneity.

global

The test statistic and p-value for the test of model explanatory power.

blups

The conditional expected values of the diversity estimates (conditional on the random effects). Estimates of variability for the random effects case are unavailable at this time; please contact the maintainer if needed.

function.args

A list containing values initially passed to betta_random.

Author(s)

Amy Willis

References

Willis, A., Bunge, J., and Whitman, T. (2015). Inference for changes in biodiversity. arXiv preprint.

See Also

betta;

Examples


df <- data.frame(chats = c(2000, 3000, 4000, 3000),
ses = c(100, 200, 150, 180),
Cont_var = c(100, 150, 100, 50),
groups = c("a", "a", "a", "b"))

# formula notation
betta_random(formula = chats ~ Cont_var| groups,
ses = ses,
 data = df)

# direct input
betta_random(c(2000, 3000, 4000, 3000), c(100, 200, 150, 180),
X = cbind(Int = 1, Cont_var = c(100, 150, 100, 50)),
groups = c("a", "a", "a", "b"))

## handles missing data
betta_random(c(2000, 3000, 4000, 3000), c(100, 200, 150, NA),
groups = c("a", NA,
    "b", "b"))


[Package breakaway version 4.8.4 Index]