Learn R Programming

fitdistrplus (version 0.1-1)

fitdistcens: Fitting of univariate distributions to censored data

Description

Fits a univariate distribution to censored data by maximum likelihood.

Usage

fitdistcens(censdata, distr, start)
## S3 method for class 'fitdistcens':
print(x,...)
## S3 method for class 'fitdistcens':
plot(x,...)
## S3 method for class 'fitdistcens':
summary(object,...)

Arguments

censdata
A dataframe of two columns respectively named left and right, describing each observed value as an interval. The left column contains either NA for left censored observations, the left b
distr
A character string "name" naming a distribution, for which the corresponding density function dname and the corresponding distribution function pname must be defined, or directly the density function.
start
A named list giving the initial values of parameters of the named distribution. This argument may be omitted for some distributions for which reasonable starting values are computed (see details).
x
an object of class 'fitdistcens'.
object
an object of class 'fitdistcens'.
...
further arguments passed to or from other methods

Value

  • fitdistcens returns an object of class 'fitdistcens', a list with 5 components,
  • estimatethe parameter estimates
  • sdthe estimated standard errors
  • corthe estimated correlation matrix
  • loglikthe log-likelihood
  • censdatathe censored dataset
  • distnamethe name of the distribution

Details

Maximum likelihood estimations of the distribution parameters are computed using the function mledistcens. Maximum likelihood estimations of the distribution parameters are computed. Direct optimization of the log-likelihood is performed using optim, with its default method "Nelder-Mead" for distributions characterized by more than one parameter and the method "BFGS" for distributions characterized by only one parameter. For the following named distributions, reasonable starting values will be computed if start is omitted : "norm", "lnorm", "exp" and "pois", "cauchy", "gamma", "logis", "nbinom" (parametrized by mu and size), "geom", "beta" and "weibull". Note that these starting values may not be good enough if the fit is poor. The function is not able to fit a uniform distribution. With the parameter estimates, the function returns the log-likelihood and the standard errors of the estimates calculated from the Hessian at the solution found by optim. The plot of an object of class "fitdistcens" returned by fitdistcens uses the function plotdistcens.

References

Venables WN and Ripley BD (2002) Modern applied statistics with S. Springer, New York, pp. 435-446.

See Also

plotdistcens, optim, mledistcens and fitdist.

Examples

Run this code
d1<-data.frame(
left=c(1.73,1.51,0.77,1.96,1.96,-1.4,-1.4,NA,-0.11,0.55,0.41,
    2.56,NA,-0.53,0.63,-1.4,-1.4,-1.4,NA,0.13),
right=c(1.73,1.51,0.77,1.96,1.96,0,-0.7,-1.4,-0.11,0.55,0.41,
    2.56,-1.4,-0.53,0.63,0,-0.7,NA,-1.4,0.13))
f1n<-fitdistcens(d1, "norm")
f1n
summary(f1n)
plot(f1n,rightNA=3)

dgumbel<-function(x,a,b) 1/b*exp((a-x)/b)*exp(-exp((a-x)/b))
pgumbel<-function(q,a,b) exp(-exp((a-q)/b))
f1g<-fitdistcens(d1,"gumbel",start=list(a=0,b=2))
summary(f1g)
plot(f1g,rightNA=3)

d3<-data.frame(left=10^(d1$left),right=10^(d1$right))
f3w<-fitdistcens(d3,"weibull")
summary(f3w)
plot(f3w,leftNA=0)
f3l<-fitdistcens(d3,"lnorm")
summary(f3l)
plot(f3l,leftNA=0)
f3e<-fitdistcens(d3,"exp")
summary(f3e)
plot(f3e,leftNA=0)

Run the code above in your browser using DataLab