distfit {disttree} | R Documentation |
The function distfit
carries out maximum-likelihood
estimation of parameters for distributions from the GAMLSS
family (for generalized additive models for location, scale,
and shape). The parameters can be transformed through
link functions but do not depend on further covariates
(i.e., are constant across observations).
distfit(y, family, weights = NULL, start = NULL, start.eta = NULL, vcov = TRUE, type.hessian = c("checklist", "analytic", "numeric"), estfun = TRUE, bd = NULL, fixed = NULL, fixed.values = NULL, censtype = "none", censpoint = NULL, ocontrol = list(), ...)
y |
numeric vector of the response |
family |
specification of the response distribution.
Either a |
weights |
optional numeric vector of case weights. |
start |
starting values for the distribution parameters handed over to |
start.eta |
starting values for the distribution parameters on the link scale handed over to |
vcov |
logical. Specifies whether or not a variance-covariance matrix should be calculated and returned. |
type.hessian |
Can either be 'checklist', 'analytic' or 'numeric' to decide how the hessian matrix should be calculated in the fitting process in |
estfun |
logical. Should the matrix of observation-wise score contributions (or empirical estimating functions) be returned? |
bd |
binomial denominator: additional parameter needed for binomial gamlss.families |
fixed |
FIXME |
fixed.values |
FIXME |
censtype |
Can either be 'none', 'left' or 'right' to set the type of censoring for censored response. |
censpoint |
numeric value. Censoring point can be set for censored response. |
ocontrol |
List with control parameters passed to
|
... |
further arguments passed to |
The function distfit
fits distributions,
similar to fitdistr
from MASS (Venables and Ripley 2002)
but based on GAMLSS families (Stasinopoulos and Rigby 2007).
Provides analytical gradients and hessian, can be plugged into
mob
.
The resulting object of class distfit
comes with a set of
standard methods to generic functions including coef
, estfun
, vcov
, predict
and logLik
.
distfit
returns an object of class distfit
which is a list with
the following components:
npar |
number of parameter |
y |
numeric vector of the response |
ny |
number of observations |
weights |
numeric vector of case weights handed over as input argument |
family |
name of the distribution family |
familylist |
if the input argument 'family' was already a list, this list is returned. Otherwise the generated family list is returned. |
start |
used starting values in |
starteta |
starting value on the link scale used in |
opt |
list returned by |
converged |
logical. TRUE if |
par |
fitted distribution parameters (on parameter scale) |
eta |
fitted distribution parameters (on link scale) |
hess |
hessian matrix |
vcov |
variance-covariance matrix |
loglik |
value of the maximized log-likelihood function |
call |
function call |
estfun |
matrix with the scores for the estimated parameters. Each line represents an observation and each column a parameter. |
ddist |
density function with the estimated distribution parameters already plugged in |
pdist |
probability function with the estimated distribution parameters already plugged in |
qdist |
quantile function with the estimated distribution parameters already plugged in |
rdist |
random number generating function with the estimated distribution parameters already plugged in |
method |
optimization method applied in |
Stasinopoulos DM, Rigby RA (2007). Generalized Additive Models for Location Scale and Shape (GAMLSS) in R, Journal of Statistical Software, 23(7), 1-46. doi: 10.18637/jss.v023.i07
Venables WN, Ripley BD (2002). Modern Applied Statistics with S. 4th Edition. Springer-Verlag, New York.
## simulate artifical negative binomial data set.seed(0) y <- rnbinom(1000, size = 1, mu = 2) ## simple distfit df <- distfit(y, family = NBI) coef(df) confint(df) logLik(df) ## using tabulated data ytab <- table(y) df2 <- distfit(as.numeric(names(ytab)), family = NBI, weights = ytab) coef(df2) confint(df2) logLik(df2) ## coefficients tests if(require("lmtest")) { coeftest(df) coeftest(df2) } ## censored logistic example if(require("crch") & require("gamlss.cens")) { library("crch") data("RainIbk", package = "crch") m1 <- crch(rain ~ 1, data = RainIbk, left = 0, dist = "logistic") library("gamlss.cens") gen.cens(LO, type = "left") m2 <- distfit(RainIbk$rain, family = LOlc, cens = "left", censpoint = 0) dist_list_cens_log <- disttree::dist_crch(dist = "logistic", type = "left", censpoint = 0) m3 <- distfit(RainIbk$rain, family = dist_list_cens_log) coef(m1) coef(m2, type = "link") coef(m3, type = "link") logLik(m1) logLik(m2) logLik(m3) }