Skip to content
Prev 326072 / 398503 Next

"actuar" package query.

On Jun 27, 2013, at 4:14 AM, Charles Thuo wrote:

            
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")
Nothing to do with 'actuar' per se. The same error would ahveoccured with any R function that expects a function as its first argument.