Learn R Programming

smoothSurv (version 0.4)

minPenalty: Minimize the penalty term under the two (mean and variance) constraints

Description

This function minimizes $$\frac{1}{2}\sum_{j=m+1}^g \Bigl(\Delta^m a_j\Bigr)^2$$ with respect to $a_1,\dots, a_g$ under the constraints $$\sum_{j=1}^g c_j \mu_j = 0$$ and $$\sum_{j=1}^g c_j (\mu_j^2 + \sigma_0^2) = 1,$$ where $$c_j = \frac{\exp(a_j)}{\sum_{l=1}^g}\exp(a_l)$$ with one of $a$'s fixed to zero.

Note that the minimum is always zero. We are thus mainly interested in the point where the minimum is reached.

Usage

minPenalty(knots = NULL, dist.range = c(-6, 6), by.knots = 0.3, sdspline = NULL,
    difforder = 3, init.c,
    maxiter = 200, rel.tolerance = 1e-10, toler.chol = 1e-15, toler.eigen = 1e-3,
    maxhalf = 10, debug = 0, info = TRUE)

Arguments

knots
A vector of knots $\mu_1,\dots,\mu_g$.
dist.range
Approximate minimal and maximal knot. If not given by knots the knots are determined as c(seq(0, dist.range[2], by = by.knots), seq(0, dist.range[1], by = -by.knots)). The sequence of knots is sorted and multiple en
by.knots
The distance between the two knots used when building a vector of knots if these are not given by knots.
sdspline
Standard deviation $\sigma_0^2$ of the basis G-spline (here it appeares only in the variance constraint). If not given it is determined as 2/3 times the maximal distance between the two knots. If sdspline >= 1 it is chan
difforder
The order of the finite difference used in the penalty term.
init.c
Optional vector of the initial values for the G-spline coefficients c, all values must lie between 0 and 1 and must sum up to 1.
maxiter
Maximum number of Newton-Raphson iterations.
rel.tolerance
(Relative) tolerance to declare the convergence. For this function, the convergence is declared if absolute value of the penalty is lower than rel.tolerance and if both constraints are satisfied up to rel.tolerance<
toler.chol
Tolerance to declare Cholesky decomposition singular.
toler.eigen
Tolerance to declare an eigen value of a matrix to be zero.
maxhalf
Maximum number of step-halving steps if updated estimate leads to a decrease of the objective function.
debug
If non-zero print debugging information.
info
If TRUE information concerning the iteration process is printed during the computation to the standard output.

Value

  • A list with the components ``spline'', ``penalty'', ``warning'', ``fail''.
  • splineA data frame with columns named ``Knot'', ``SD basis'', ``c coef.'' and ``a coef.'' which gives the optimal values of $c_1,\dots, c_g$ and $a_1,\dots, a_g$ in the latter two columns. This data.frame can be further worked out using the function eval.Gspline.
  • penaltyThe value of the penalty term when declaring convergence.
  • warningPossible warnings concerning the convergence.
  • failFailure indicator. It is zero if everything went OK.

Examples

Run this code
optimum <- minPenalty(knots=seq(-4.2, 4.2, by = 0.3), sdspline=0.2, difforder=3)
where <- optimum$spline
print(where)
show <- eval.Gspline(where, seq(-4.2, 4.2, by=0.05))
plot(show, type="l", bty="n", lwd=2)

Run the code above in your browser using DataLab