Learn R Programming

spiders (version 1.2)

predPref: parameter estimation

Description

Estimates parameters of predator preferences model and calculates LRT. Eaten and caught dataframes are indexed with rows across time points and columns of prey species.

Usage

predPref(eaten, caught, hypotheses = c("c", "Ct"), alpha = 0.05, em_maxiter = 1000)

Arguments

eaten
a dataframes of eatings preferences; TxS
caught
a dataframes of caught prey species; TxS
hypotheses
a 2-tuple specifying the null and alternative hypotheses, respectively
alpha
LRT level of significance
em_maxiter
maximum number of iterations allowed for EM algorithm

Value

A list of class 'predPref' with the following elements:null: parameters as estimated under the specified null hypothesis.alt: parameters as estimated under the specified alternative hypothesis.loglikH0: the null hypothesis log-likelihood, with constants not accounted for.loglikH1: the alternative hypothesis log-likelihood, with constants not accounted for.J: a column vector of dimension T containing the number of predators in each time period.I: a column vector of dimension T containing the number of traps in each time period.LRT: the likelihood ratio test statistics.hypotheses: a 2-tuple of the user specified hypotheses.data.name: a character string giving the names of the data.

See Also

simPref summary.predPref

Examples

Run this code
# set parameters
Predators <- Traps <- 100
PreySpecies <- 2
Times <- 5
g <- matrix(sqrt(2), nrow=Times, ncol=PreySpecies)     # gamma
l <- matrix(seq(0.4,1.8,length.out=5)*sqrt(2), nrow=Times, ncol=PreySpecies) # ct

# fit model
## Not run: 
# fdata <- simPref(PreySpecies, Times, Predators, Traps, l, g, EM=FALSE)
# predPref(fdata$eaten, fdata$caught, hypotheses=c('ct', 'cst'))
# ## End(Not run)

Run the code above in your browser using DataLab