sbm {sbd}R Documentation

Fit a size biased model

Description

Fits a parametric or non-parametric size biased distribution model to a positive response variable.

Usage

sbm(
  formula,
  data,
  pdf = c("none", "lnorm", "gamma", "weibull"),
  var.range = c(-4, 4),
  trace = FALSE,
  ...
)

Arguments

formula

A two-sided formula of the form response ~ covariate + ...

data

A dataframe containing the fields named in formula.

pdf

A text value naming the probability density function to use.

var.range

The range of log variance within which to search when fitting parametric distributions.

trace

Logical defining whether to show diagnostic information when fitting parametric distributions (passed to mle2).

...

Arguments passed to predict.sbm (options: newdata, reps).

Details

Response values must be strictly positive. To fit a distribution without covariates use 1 on the right hand side of the formula. When pdf = "none", the harmonic mean and it's standard error are calculated, and no covariates can be used.

The contents of the the estimate component of the result depends on the type of model. When no covariates are used, it contains a single overall average estimate. When covariates are used and newdata = NULL, it contains one estimate per unique combination of factor covariate levels, with any quantitative covariates held at their mean values. When covariates are used and a dataframe with valid covariate fields is supplied to newdata, it replicates newdata appending averages estimated at the covariate values supplied.

Value

A list of class sbm with methods summary.sbm, predict.sbm, hist.sbm, and AIC.sbm. The list has elements:

"estimate"

A dataframe of estimated averages, their standard errors and 95% confidence limits.

"data"

A dataframe containing the data used to fit the model.

"model"

A model object of class mle2.

"formula"

The formula supplied to the function call.

"pdf"

Character string recording the probability density function used to fit the model.

Examples

  data(BCI_speed_data)
  agoutiData <- subset(BCI_speed_data, species=="agouti")

  # harmonic mean estimate for agouti
  hmod <- sbm(speed~1, agoutiData)

  # lognormal estimate with or without a covariates
  lmod <- sbm(speed~1, agoutiData, pdf="lnorm")
  lmod_mass <- sbm(speed~mass, BCI_speed_data, pdf="lnorm")
  lmod_spp <- sbm(speed~species, BCI_speed_data, pdf="lnorm")

  # inspect estimates
  hmod$estimate
  lmod$estimate
  lmod_mass$estimate
  lmod_spp$estimate

[Package sbd version 0.1.0 Index]