Learn R Programming

episplineDensity (version 0.0-1)

expepi: Fit density estimate by exponential epi-splines.

Description

This code produces one-dimensional density estimates satisfying "soft" conditions like unimodality. A number of possible soft conditions are permitted. This version calls the nloptr suite of optimizers. Convergence is not particularly fast.

Usage

expepi(data, lower = NULL, upper = NULL, N = 10, M = 5, order = 2, softinfo, opt.args, opt.local.args, postproc.controls)

Arguments

data
Numeric vector of data for density estimate.
lower
Lower bound for density support. If missing, use default as set in preprocess.data
upper
Upper bound for density support. If missing, use default as set in preprocess.data
N
Integer: number of segments. Default 10.
M
Integer: number of points within each segment to consider. Default 5.
order
Integer: order of polynomials used in spline fits. Currently this must be 2.
softinfo
List of "soft" conditions to be imposed on the density estimate. See setup.softinfo for possibilities.
opt.args
List of arguments to be passed to global optimizer. See setup.optargs for defaults and more information. Set print_level = 1 to show each iteration in the global optimizer, which might help convince you that something is happening.
opt.local.args
List of arguments to be passed to local optimizer. See setup.optargs for defaults and more information.
postproc.controls
List of arguments for post-processing. See postproc.control for defaults and more information.

Value

A list of class c("episplineDensity", "nloptr") with the output from nloptr, plus additional items:
softinfo
The softinfo as passed to the optimizer, consisting of what was passed into this function plus some defaults
epiparameters
Epiparameters, as generated by preprocess.data
caseinfo
A list with the sample size, as sampleisze, and notion else.
x
Copy of the data
c.out
Coefficients associated with this set of data.
opts
Copy of opts. See setup.optargs.
orig.integral
If the postprocessing option normalize.to.1 is supplied, this item is present and gives the value of the integral of the density before normalization. It should be near 1.
integral
If the postprocessing option normalize.to.1 is supplied, this item is present and gives the value of the integral of the density after normalization. It should exactly 1.

Details

This function produces a density estimator for data data, imposing constraints in softinfo. The density is in the form of an exponential epi-spline. An epi-spline is like a spline estimator in that in consists of polynomials between knots. However, the polynomials are not automatically constrained to meet at knots. The density estimate is an exponential epi-spline, which is exp(- s) where s is the epi-spline value.

References

Royset and Wets, Nonparametric Density Estimation with Soft Information Using Exponential Epi-Splines, in press.

See Also

nloptr

Examples

Run this code
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

n10 <- c(-0.795173769, -0.268865287, -0.032803042, -0.361751212, 
0.699170399, -0.909275685, 0.452956532, 1.501356616, 1.669061521, 
-0.524919503)
#
# Generate a unimodal estimate. Plot automatically.
#
## Not run: soft <- setup.softinfo (10, unimodal = TRUE)

## Not run: expepi (n10, softinfo = soft)
#
# Generate a unimodal estimate, but constrain the second non-central
# moment to be <= 0.4. Plot automatically. This command will require
# a couple of minutes to run.
#
## Not run: soft$upperbound2moment <- 0.4
## Not run: expepi (n10, softinfo = soft)
#
# Generate a nondecreasing estimate without plotting.
#
## Not run: soft <- setup.softinfo (10, monotone="nondecreasing")
## Not run: n10.out <- expepi (n10, softinfo = soft, postproc.controls = 
#  postproc.control (pic.types = NULL))## End(Not run)
#
# Now plot.
#
## Not run: plot (n10.out)

Run the code above in your browser using DataLab