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

View source: R/convertCDA.R

derivative.expADR Documentation

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)

Arguments

knots

A vector of G-spline knots mu.

sdspline

Standard deviation sigma0 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.

Details

To satisfy the three constraints

c[1] + ... c[g] = 1,

c[1]mu[1] + ... c[g]mu[g] = 0,

c[1]mu[1]^2 + ... c[g]mu[g]^2 = 1 - sigma0^2

imposed on the G-spline we use the following parametrization:

c[j] = exp(a[j])/[exp(a[1]) + ... + exp(a[g])], j = 1, ..., 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[omega[0,k] + sum[j != last.three]omega[j,k]exp(a[j])], 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) = t(Omega_[1,]) + t(Omega[-1,])exp(d)

and if all == FALSE

exp(a[last.three[2:3]]) = t(Omega_[1,]) + t(Omega[-1,])exp(d).

Value

A matrix with omega coefficients.

Note

WARNING: This function is primarily used inside smoothSurvReg. Consequently, it has very few error checks on its input arguments.

Author(s)

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


smoothSurv documentation built on Oct. 11, 2022, 1:05 a.m.