smoothSplinesVal: Estimate density from histogram - for different 'alpha'

View source: R/splineDensity.smoothingSplinesValidation.R

smoothSplinesValR Documentation

Estimate density from histogram - for different alpha

Description

As smoothSplines, smoothSplinesVal computes the density function that 'best' fits discretized distributional data, using B-spline basis functions, for different alpha.
Comparing and choosing an appropriate alpha is the ultimate goal.

Usage

smoothSplinesVal(
  k,
  l,
  alpha,
  data,
  xcp,
  knots,
  weights = matrix(1, dim(data)[1], dim(data)[2]),
  prior = "default",
  cores = 1
)

Arguments

k

smoothing splines degree

l

order of derivative in the penalization term

alpha

vector of weights for penalization

data

an object of class "matrix" containing data to be smoothed, row by row

xcp

vector of control points

knots

either vector of knots for the splines or a integer for the number of equispaced knots

weights

matrix of weights. If not gives, all data points will be weighted the same.

prior

prior used for zero-replacements. This must be one of "perks", "jeffreys", "bayes_laplace", "sq" or "default"

cores

number of cores for parallel execution

Details

See smoothSplines for the description of the algorithm.

Value

A list of three objects:

alpha

the values of alpha

J

the values of the functional evaluated in the minimizing

CV-error

the values of the leave-one-out CV-error

Author(s)

Alessia Di Blasi, Federico Pavone, Gianluca Zeni, Matthias Templ

References

J. Machalova, K. Hron & G.S. Monti (2016): Preprocessing of centred logratio transformed density functions using smoothing splines. Journal of Applied Statistics, 43:8, 1419-1435.

Examples

SepalLengthCm <- iris$Sepal.Length
Species <- iris$Species

iris1 <- SepalLengthCm[iris$Species==levels(iris$Species)[1]]
h1 <- hist(iris1, nclass = 12, plot = FALSE)

## Not run: 
midx1 <- h1$mids
midy1 <- matrix(h1$density, nrow=1, ncol = length(h1$density), byrow=TRUE)
knots <- 7
sol1 <- smoothSplinesVal(k=3,l=2,alpha=10^seq(-4,4,by=1),midy1,midx1,knots,cores=1)

## End(Not run)

robCompositions documentation built on Aug. 25, 2023, 5:13 p.m.