Learn R Programming

fBasics (version 221.10065)

SmoothedSplineDistribution: Smoothed Spline Distribution

Description

A collection and description of functions to compute density, distribution function, quantile function and to generate random variates for empirical distributions. Estimates are done using smoothing spline ANOVA models with cubic spline, linear spline, or thin-plate spline marginals for numerical variables. The functions are: ll{ dssd Spline smoothed density, pssd spline smoothed probability function, qssd spline smoothed quantiles, rssd random deviates drawn from a ssd.}

Usage

dssd(x, param)
pssd(q, param)
qssd(p, param)
rssd(n, param)

Arguments

n
number of observations.
p
a numeric vector of probabilities.
x, q
a numeric vector of quantiles.
param
a S3 object specifying the parameters as returned by the function ssdFit.

Value

  • All values are numeric vectors: d* returns the density, p* returns the distribution function, q* returns the quantile function, and r* generates random deviates.

Details

This is an easy to use version for the functions implemented in Chong Gu's contributed R package "gss" which is downloadable from the CRAN server. If you require more functionality, e.g. to tailor the parameter estimate we recommend to install Gu's package. The installation does not interfere with the functions implemented in Rmetrics. Note, before you can use the functions you have to estimate the parameters param using the function ssdFit.

References

Gu C., Wang, J. (2003); emph{Penalized likelihood density estimation: Direct cross-validation and scalable approximation}, Statistica Sinica, 13, 811--826. Gu C. (2002); Smoothing Spline ANOVA Models, New York, Springer-Verlag.

Examples

Run this code
## SOURCE("fBasics.13C-SmoothedSplineDistribution")

## ssd -
xmpBasics("\nStart: Spline Smoothed Distribution > ")
   par(mfcol = c(2, 1), cex = 0.5)
   set.seed(1953)
   x = rnorm(1000)
   param = ssdFit(x)
   # Plot empirical density and compare with fitted density:
   hist(x, n = 25, probability = TRUE, border = "white", col = "steelblue4") 
   s = seq(min(x), max(x), 0.1)
   lines(s, dssd(s, param), lwd = 2)
   # Plot df and compare with true df:
   plot(sort(x), (1:1000/1000), main = "Probability", col = "steelblue4")
   lines(s, pssd(s, param), lwd = 2)
   # Compute quantiles:
   qssd(pssd(seq(-3, 3, 1), param), param)

Run the code above in your browser using DataLab