| hsaDist | R Documentation |
The set of functions similar to dhpa-like
functions. The difference is that instead of a polynomial these functions
utilize a spline.
dhsa(x, m, knots, mean = 0, sd = 1, log = FALSE)
ehsa(m, knots, mean = 0, sd = 1, power = 1)
x |
numeric vector of values for which the function should be estimated. |
m |
numeric matrix whose rows correspond to the spline intervals while columns represent the variables powers. Therefore the element in i-th row and j-th column represents the coefficient associated with the variable that 1) belongs to the i-th interval i.e. between the i-th and (i + 1)-th knots 2) raised to the power of (j - 1). |
knots |
a numeric vector sorted in ascending order representing the knots of the spline. |
mean |
expected value of a normal distribution. |
sd |
standard deviation of a normal distribution. |
log |
logical; if |
power |
non-negative integer representing the moment order, i.e., E(X ^ power) will be estimated. |
In contrast to dhpa-like functions these
functions may deal with univariate distributions only. In future this
functions will be generalized to work with multivariate distributions.
The main idea of these functions is to use squared spline instead of squared
polynomial in order to provide greater numeric stability and approximation
accuracy. To provide spline parameters please use m and knots
arguments (i.e. instead of pol_degrees and pol_coefficients
arguments that were used to specify the polynomial
for dhpa-like functions).
Function dhsa returns vector of probability
densities of the same length as x. Function ehsa
returns moment value.
dhpa, bsplineGenerate
## Examples demonstrating dhsa and ehsa functions' application.
# Generate b-splines
b <- bsplineGenerate(knots = c(-2.1, 1.5, 1.5, 2.2, 3.7, 4.2, 5),
degree = 3)
# Combine b-splines into a spline
spline <- bsplineComb(splines = b, weights = c(1.6, -1.2, 3.2))
# Assign parameters using the spline created above
knots <- spline$knots
m <- spline$m
mean <- 1
sd <- 2
# Estimate the density at particular points
x <- c(2, 3.7, 8)
dhsa(x,
m = m, knots = knots,
mean = mean, sd = sd)
# Calculate expected value
ehsa(m = m, knots = knots,
mean = mean, sd = sd,
power = 1)
# Evaluate the third moment
ehsa(m = m, knots = knots,
mean = mean, sd = sd,
power = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.