phfit.density {mapfit} | R Documentation |
PH fitting with density function
Description
Estimates PH parameters from density function.
Usage
phfit.density(
ph,
f,
deformula = deformula.zeroinf,
weight.zero = 1e-12,
weight.reltol = 1e-08,
start.divisions = 8,
max.iter = 12,
...
)
Arguments
ph |
An object of R6 class. The estimation algorithm is selected depending on this class. |
f |
A function object for a density function. |
deformula |
An object for formulas of numerical integration. It is not necessary to change it when the density function is defined on the positive domain [0,infinity). |
weight.zero |
A absolute value which is regarded as zero in numerical integration. |
weight.reltol |
A value for precision of numerical integration. |
start.divisions |
A value for starting value of divisions in deformula. |
max.iter |
A value for the maximum number of iterations to increase divisions in deformula. |
... |
Options for EM steps, which is also used to send the arguments to density function. |
Value
Returns a list with components, which is an object of S3 class phfit.result
;
model |
an object for estimated PH class. |
llf |
a value of the maximum log-likelihood (a negative value of the cross entropy). |
df |
a value of degrees of freedom of the model. |
KL |
a value of Kullback-Leibler divergence. |
iter |
the number of iterations. |
convergence |
a logical value for the convergence of estimation algorithm. |
ctime |
computation time (user time). |
data |
an object for data class |
aerror |
a value of absolute error for llf at the last step of algorithm. |
rerror |
a value of relative error for llf at the last step of algorithm. |
options |
a list of options. |
call |
the matched call. |
Note
Any of density function can be applied to the argument f
, where
f
should be defined f <- function(x, ...)
.
The first argument of f
should be an integral parameter.
The other parameters are set in the argument ...
of phfit.density
.
The truncated density function can also be used directly.
Examples
####################
##### truncated density
####################
## PH fitting for general PH
(result1 <- phfit.density(ph=ph(2), f=dnorm, mean=3, sd=1))
## PH fitting for CF1
(result2 <- phfit.density(ph=cf1(2), f=dnorm, mean=3, sd=1))
## PH fitting for hyper Erlang
(result3 <- phfit.density(ph=herlang(3), f=dnorm, mean=3, sd=1))
## mean
ph.mean(result1$model)
ph.mean(result2$model)
ph.mean(result3$model)
## variance
ph.var(result1$model)
ph.var(result2$model)
ph.var(result3$model)
## up to 5 moments
ph.moment(5, result1$model)
ph.moment(5, result2$model)
ph.moment(5, result3$model)