Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: smoother
See also: plogspline qlogspline dlogspline rlogspline logsplinesummary plotlogspline

Quantlet: logsplinefit
Description: estimates density function using splines

Reference(s):

Usage: {coef,knots,bound,logl,penalty,sample,del}=logsplinefit(uncensored,right,left,interval,lbound,ubound,indel,nknots,inputknots,inpenalty)
Input:
uncensored vector of uncensored observations from the distribution whose density is to be estimated. If there are no uncensored observations, plug in any non-numeric type to omit this parameter. However, either uncensored observations or the 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, plug in any non-numeric type.
left vector of left censored observations from the distribution whose density is to be estimated. If there are no left censored observations, plug in any non-numeric type.
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, plug in any non-numeric type.
lbound, ubound lower and upper bounds 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. To omit these parameters plug in any non-numeric type.
indel optional scalar, should stepwise knot deletion be employed (non-zero value) or not (zero, default)?
nknots optional vector, forces the method to start with nknots knots (indel=1) or to fit a density with nknots knots (indel=0). The method has an automatic rule for selecting nknots if this parameter is not specified.
inputknots optional ordered vector of values (that should cover the complete range of the observations), which forces the method to start with these knots (indel=1) or to fit a density with these knots (indel=0). Overrules nknots. If inputknots is not specified, a default knot-placement rule is employed.
inpenalty optional scalar, the parameter to be used in the AIC criterion. The method chooses the number of knots that minimizes -2*loglikelihood+inpenalty*(number of inputknots-1). The default is to use inpenalty=log(samplesize) as in BIC. The effect of this parameter is summarized in logsplinesummary().
Output:
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 ^3+ means the positive part of the third power, and t[k-2] means knot k-2). If a coefficient is zero, the corresponding knot was deleted from the model.
knots vector of the locations of the knots in the logspline model
bound first element: 0 - lbound was -infinity, 1 it was something else; second element: lbound, if specified; third element: 0 - ubound was infinity, 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.
del was stepwise knot deletion employed?

Example:
library("smoother")
data = read("geyser")
fit  = logsplinefit(data[,1], "no","no","no","no","no",1,6,"no",7)
fit
plotlogspline(fit)
setgopt(plotdisplay,1,1,"title", "Density Function of Geyser Data")

Result:
A graph of estimated density and the following text output of the fit:

Contents of fit.coef

[1,]  -79.319
[2,]   46.126
[3,]  -489.86
[4,]   1063.8
[5,]  -574.69
[6,]  -35.986
[7,]   117.49
[8,]  -80.729

Contents of fit.knots

[1,]      1.6
[2,]   1.7381
[3,]   1.8584
[4,]   4.6957
[5,]   4.9667
[6,]      5.1

Contents of fit.bound

[1,]        0
[2,]        0
[3,]        0
[4,]        0

Contents of fit.logl

[1,]        0
[2,]  -423.04
[3,]  -274.87
[4,]  -267.34

Contents of fit.penalty

[1,]        7

Contents of fit.sample

[1,]      272

Contents of fit.del

[1,]        1



Author: K. Komorad, W. Haerdle, 20010625 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006