"actuar" package query.
On Jun 27, 2013, at 4:14 AM, Charles Thuo wrote:
I run the following in the "actuar" package while trying to discretize the lognormal distribution which i had fitted using the "fitdistrplus" package. fx <- discretize(plnorm(11.69,2.1),from = 0, to = 22, step = 0.5, method = "upper") Error in discretize(plnorm(11.69, 2.1), from = 0, to = 22, step = 0.5, : 'cdf' must be a function or an expression containing 'x' Because of this error am unable to fit a compound distribution between the negative binomial and lognormal. Is there another way besides using "actuar".
The error is being thrown because you are not calling discretize with a function as its first argument. You are giving it a single value. Try: fx <- discretize( plnorm( x , 2.1), from = 0, to = 22, step = 0.5, method ="upper") You could also continue to emulate the first example on help(discretize) library(actuar) x <- seq(0, 22, 0.5) fu <- discretize(plnorm(x, 2.1), from = 0, to = 22, step = 0.5, method ="upper") fl <- discretize(plnorm(x, 2.1), from = 0, to = 22, step = 0.5, method ="lower") curve(plnorm(x, 2.1), xlim = c(0, 22)) par(col = "blue") plot(stepfun(head(x, -1), diffinv(fu)), pch = 19, add = TRUE) par(col = "green") plot(stepfun(x, diffinv(fl)), pch = 19, add = TRUE) par(col = "black")
I have just started using actuar. Kindly assist.
Nothing to do with 'actuar' per se. The same error would ahveoccured with any R function that expects a function as its first argument.
David Winsemius Alameda, CA, USA