maximise.likelihood {bayescount} | R Documentation |
Calculate the Maximum Likelihood Parameters of a Continuous or Count Distribution
Description
Crude function to maximise the likelihood of one of the following distributions: Poisson (P), gamma (G), lognormal (L), Weibull (W), gamma Poisson (GP), lognormal Poisson (LP), Weibull Poisson (WP), all with or without zero-inflation (ZI). Uses the likelihood() function to calculate the likelihood at each iteration. For mixture models, the likelihood is calculated for the data by integrating over each possible value of lambda for each data point, which may take some time for large datasets. Starting values for each parameter are optional, but may improve the speed and reliability of the function if appropriate values are provided. If missing, starting values will be calculated from the data.
Usage
maximise.likelihood(data=stop("Data must be specified"),
model=stop("Please specify a distribution"), mean=NA,
variance=NA, zi=NA, shape=NA, scale=NA, silent=FALSE)
Arguments
data |
a vector of data to fit the distribution to. Count data for the count models, continuous data for the continuous distributions. |
model |
the distribution to fit to the data. Choices are: "P", "ZIP", "G", "ZIG", "L", "ZIL", "W", "ZIW", "GP", "ZIGP", "LP", "ZILP", "WP", "ZIWP" (case insensitive). No default. |
mean |
the starting value for mean. Optional. |
variance |
the starting value for variance. Optional. |
zi |
the starting value for zero-inflation. Optional. |
shape |
the starting value for the shape parameter. Optional. |
scale |
the starting value for the scale parameter. Optional. |
silent |
should warning messages and progress indicators be supressed? Default FALSE. |
Value
The values for each parameter at the maximum likelihood are output)
See Also
Examples
# obtain values for mean and zero-inflation of a zero-inflated
# gamma Poisson model:
data <- rpois(100, rgamma(100, shape=1, scale=8))
data[1:15] <- 0
maximise.likelihood(data, "ZIGP")