Learn R Programming

smoothSurv (version 2.6)

derivative.expAD: Work Function for 'smoothSurvReg', currently nowhere used

Description

Function to compute derivatives of exp(a) w.r.t. exp(d) where d stands for a shorter vector of 'a' G-spline coefficients.

Usage

derivative.expAD(knots, sdspline, last.three, all = TRUE)

Value

A matrix with \(\omega\) coefficients.

Arguments

knots

A vector of G-spline knots \(\mu\).

sdspline

Standard deviation \(\sigma_0\) of the basis G-spline.

last.three

Indeces of the three 'a' G-spline coefficients which are expressed as a function of the remaining (g-3) 'a' G-spline coefficients such that the three constraints are satisfied. This must be a vector of length 3 with three different numbers from 1:length(mu). Consequently, a[last.three[1]] <- 0.

all

If TRUE, matrix (g - 2) x g (there is one zero column) is returned. If FALSE, matrix (g - 2) x 2 is returned. The first row is always an intercept. See details.

Author

Arnošt Komárek arnost.komarek@mff.cuni.cz

Details

To satisfy the three constraints $$\sum_{j=1}^g c_j = 1,$$ $$\sum_{j=1}^g c_j \mu_j = 0,$$ $$\sum_{j=1}^g c_j \mu_j^2 = 1 - \sigma_0^2$$ imposed on the G-spline we use the following parametrization: $$c_j = \frac{\exp(a_j)}{\sum_{l=1}^{g}\exp(a_l)}, j = 1,\dots, g.$$ The constraints can be solved such that a[last.three[1]] = 0 and a[last.three[2:3]] are expressed as a function of a[-last.three] in the following way: $$a_{k} = \log\Bigl\{\omega_{0,k} + \sum_{j\neq last.three}\omega_{j,k}\exp(a_j)\Bigr\},% \qquad k = last.three[2], last.three[3],$$ where \(\omega\) coefficients are a function of knots and G-spline standard deviation. If we denote \(d\) the vector a[-last.three] this function computes derivatives of \(\exp(a)\) w.r.t. \(\exp(d)\) together with the intercept term used to compute \(\exp(a)\) from \(\exp(d)\). This is actually a matrix of \(\omega\) coefficients. If we denote it as \(\Omega\) then if all == TRUE $$\exp(a) = \Omega_{1,\cdot}^T + \Omega_{-1,\cdot}^T\exp(d)$$ and if all == FALSE $$\exp(a[last.three[2:3]]) = \Omega_{1,\cdot}^T + \Omega_{-1,\cdot}^T\exp(d).$$