Description Details Fields Methods Examples
Optimize parameters and approximate probability density functions of random variables.
Use objects of this class to optimize a p.d.f. and approximate it using products of independent, transformed parameters. You need to initialize an object of this class, call the constructor with a function and initial guesstimates for the unknown parameters, and finally call the set.z method. For convenience, you can do this in one step, when you initialize the object. Then, use the pdf method to obtain fast evaluations of the approximate p.d.f.
logpdfLog-pdf to be optimized
nparNumber of unknown parameters
argsOther arguments required by log-pdf
iterationNumber of p.d.f. evaluations conducted
lowerLower bounds for unknown parameters
upperUpper bounds for unknown parameters
modeMode of pdf (par. value that maximizes pdf)
fmodeMaximum value of the log-pdf (value at mode)
lev0Evaluation of the log-p.d.f. when pars = 0
covFCovariance factor at the mode
precRPrecision factor at the mode
logdetPRLog determinant of par. cov. at the mode
optim.resOutput from the optimization method
ZList of transformed model parameters
cdf(x = NULL, ...)Provides either cumulative density function or its evaluation given x
construct(fn, initial, is.logf = FALSE, lower = -Inf, upper = Inf,
max.it = 300, args = NULL, zspecs = NULL, skip.z = FALSE,
verbose = FALSE, method = "Nelder-Mead", optim.tol = 1e-04)Optimization method that lets you find the mode of a p.d.f.
@param fn function p.d.f. (needn't integrate to 1) to be optimized
@param is.logf logical Is fn already log-transformed?
@param initial numerical Initial values for the p.d.f. parameters
@param lower numerical Lower bounds for the parameters
@param upper numerical Upper bounds for the parameters
@param args list Additional input arguments for the function
@param zspecs list Specifications used to transform the parameters
@param skip.z logical Should parameter transformation be skipped? @param method character Optimization algorithm @param optim.tol numerical Optimization relative tolerance
get.extremes(id)Provides the bounds of the region where a given input parameter has non-zero density
get.x2z(x)Provides transformed parameters based on original input parameters.
@param x numeric, matrix, Matrix X-coordinates to be transformed
@result z numeric, matrix, Matrix Transformed z-coordinates
get.z2x(z)Provides parameters with their original units based on transformed parameters.
@param z numeric, matrix, Matrix Z-coordinates to be transformed
@result x numeric, matrix, Matrix Transformed x-coordinates
get.zaxis(id = 1)Coordinates of transformed parameters, at all evaluation points.
@param id numeric Identification number of Z-axis
@result axis matrix X-coordinates of required Z-axis
iget.reshape(f, x = NULL)Internal function that reshapes the input provided to pdf, cdf and invcdf
initialize(fn = NULL, initial = NULL, is.logf = FALSE, lower = -Inf,
upper = Inf, max.it = 300, args = NULL, zspecs = NULL,
skip.c = FALSE, skip.z = FALSE, verbose = FALSE, method = "GenSA",
optim.tol = 1e-04)Lets you run optimization and pdf exploration in one go
@param fn function p.d.f. (needn't integrate to 1) to be optimized
@param initial numerical Initial values for the p.d.f. parameters
@param is.logf logical Is fn already log-transformed?
@param lower numerical Lower bounds for the parameters
@param upper numerical Upper bounds for the parameters
@param args list Additional input arguments for the function
@param zspecs list Specifications used to transform the parameters
@param skip.z logical Should parameter transformation be skipped?
@param method character Optimization algorithm
@param optim.tol numerical Optimization relative tolerance.
invcdf(p = NULL, ...)Provides either inverse of the cumulative density function or its evaluation, for a given p.
pdf(x = NULL, do.log = FALSE)Approximate p.d.f. evaluation.
@param x numeric,matrix,NULL X-coords of points where pdf is evaluated
@param do.log logical Provide log-transformed p.d.f. instead?
@result myf numeric,matrix,function Either evaluations or R function
set.z(zspecs = NULL)Provides transformed input parameters based on the optimization of the input function.
@param zspecs list list of specifications, e.g.
zspecs <- list(nside = 10, logtol = -5, eps = 1e-4,
useFortran = TRUE, useQuadratic = TRUE, useEigen = TRUE)
1 2 3 4 5 6 7 8 9 10 11 12 13 | myfun <- function(x) dgamma(x, shape = 1.3, scale = 1) *
dnorm(x, mean = 2, sd = 1)
myfun.integ <- integrate(
f = myfun, lower = 0, upper = 10)$value
fn <- function(x) myfun(x) / myfun.integ
s <- opt(fn = fn, initial = 1, lower = 0)
x <- seq(0, 10, 0.1)
plot(x, fn(x), ty = "l", col = "grey", lwd = 4,
xlab = "x", ylab = "pdf")
lines(x, s$pdf(x))
legend(0.6 * max(x), max(fn(x)),
c("true pdf", "rcoptim pdf"),
col = c("grey", "black"), lty = 1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.