Learn R Programming

logspline (version 2.1.22)

oldlogspline: Logspline Density Estimation - 1992 version

Description

Fits a logspline density using splines to approximate the log-density using the 1992 knot deletion algorithm (oldlogspline). The 1997 algorithm using knot deletion and addition is available using the logspline function.

Usage

oldlogspline(uncensored, right, left, interval, lbound,
ubound, nknots, knots, penalty, delete = TRUE)

Value

Object of the class oldlogspline, that is intended as input for plot.oldlogspline, summary.oldlogspline, doldlogspline (densities), poldlogspline (probabilities),

qoldlogspline (quantiles), roldlogspline (random numbers from the fitted distribution). The function oldlogspline.to.logspline can translate an object of the class oldlogspline to an object of the class logspline.

The object has the following members:

call

the command that was executed.

knots

vector of the locations of the knots in the oldlogspline model. old

coef

coefficients of the spline. The first coefficient is the constant term, the second is the linear term and the k-th \((k>2)\) is the coefficient of \((x-t(k-2))^3_+\) (where \(x^3_+\) means the positive part of the third power of \(x\), and \(t(k-2)\) means knot \(k-2\)). If a coefficient is zero the corresponding knot was deleted from the model.

bound

first element: 0 - lbound was \(-\inf\) 1 it was something else; second element: lbound, if specified; third element: 0 - ubound was \(\inf\), 1 it was something else; fourth element: ubound, if specified.

logl

the k-th element is the log-likelihood of the fit with k+2 knots.

penalty

the penalty that was used.

sample

the sample size that was used.

delete

was stepwise knot deletion employed?

Arguments

uncensored

vector of uncensored observations from the distribution whose density is to be estimated. If there are no uncensored observations, this argument can be omitted. However, either uncensored or interval must be specified.

right

vector of right censored observations from the distribution whose density is to be estimated. If there are no right censored observations, this argument can be omitted.

left

vector of left censored observations from the distribution whose density is to be estimated. If there are no left censored observations, this argument can be omitted.

interval

two column matrix of lower and upper bounds of observations that are interval censored from the distribution whose density is to be estimated. If there are no interval censored observations, this argument can be omitted.

lbound,ubound

lower/upper bound for the support of the density. For example, if there is a priori knowledge that the density equals zero to the left of 0, and has a discontinuity at 0, the user could specify lbound = 0. However, if the density is essentially zero near 0, one does not need to specify lbound. The default for lbound is -inf and the default for ubound is inf.

nknots

forces the method to start with nknots knots (delete = TRUE) or to fit a density with nknots knots (delete = FALSE). The method has an automatic rule for selecting nknots if this parameter is not specified.

knots

ordered vector of values (that should cover the complete range of the observations), which forces the method to start with these knots (delete = TRUE) or to fit a density with these knots delete = FALSE). Overrules nknots. If knots is not specified, a default knot-placement rule is employed.

penalty

the parameter to be used in the AIC criterion. The method chooses the number of knots that minimizes -2 * loglikelihood + penalty * (number of knots - 1). The default is to use a penalty parameter of penalty = log(samplesize) as in BIC. The effect of this parameter is summarized in summary.oldlogspline.

delete

should stepwise knot deletion be employed?

Author

Charles Kooperberg clk@fredhutch.org.

References

Charles Kooperberg and Charles J. Stone. Logspline density estimation for censored data (1992). Journal of Computational and Graphical Statistics, 1, 301--328.

Charles J. Stone, Mark Hansen, Charles Kooperberg, and Young K. Truong. The use of polynomial splines and their tensor products in extended linear modeling (with discussion) (1997). Annals of Statistics, 25, 1371--1470.

See Also

logspline, oldlogspline, plot.oldlogspline, summary.oldlogspline,
doldlogspline, poldlogspline, qoldlogspline, roldlogspline, oldlogspline.to.logspline.

Examples

Run this code
# A simple example
y <- rnorm(100)
fit <- oldlogspline(y)       
plot(fit)
# An example involving censoring and a lower bound
y <- rlnorm(1000)
censoring <- rexp(1000) * 4
delta <- 1 * (y <= censoring)
y[delta == 0] <- censoring[delta == 0]
fit <- oldlogspline(y[delta == 1], y[delta == 0], lbound = 0)

Run the code above in your browser using DataLab