Learn R Programming

smoothSurv (version 0.7)

give.c: Work Function for 'smoothSurvReg'

Description

Give a vector of all 'c' G-spline coefficients satisfying the three constrains (see below) if only (g-3) c's are given.

Usage

give.c(knots, sdspline, last.three, c.rest)

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 'c' G-spline coefficients which are not included in c.rest. This must be a vector of length 3 with three different numbers from 1:length(knots).
c.rest
A vector of length(knots) - 3 'c' spline coefficients corresponding to knots knots[-last.three]. They must all lie between zero and one and their sum must be lower or equal to one.

Value

  • A vector of all length(knots) 'c' G-spline coefficients.

Details

The functions computes remaining three 'c' G-spline coefficients (if it is possible) such that the resulting G-spline satisfies the following: $$\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.$$

Examples

Run this code
knots <- seq(-4, 4, 0.5)
sd0 <- 0.3
ccoef <- find.c(knots, sd0, dist = "dstlogis")

last.three <- c(3, 7, 10)
c.rest <- ccoef[-last.three]
ccoef2 <- give.c(knots, sd0, last.three, c.rest)

print(ccoef)
print(ccoef2)    ## Almost no change

Run the code above in your browser using DataLab