vecr2matr {bayesSurv}R Documentation

Transform single component indeces to double component indeces

Description

Components of a bivariate G-spline can be indexed in several ways. Suppose that the knots in the first dimension are \mu_{1,-K_1},\dots,\mu_{1,K_1} and the knots in the second dimension \mu_{2,-K_2},\dots,\mu_{2,K_2}. I.e. we have 2K_1+1 knots in the first dimension and 2K_2+1 knots in the second dimension. Each G-spline component can have a double index (k_1,k_2) assigned which means that it corresponds to the knot (\mu_{1,k_1},\mu_{2,k_2}) or alternatively the same G-spline component can have a~single index

r=(k_2 + K_2)\times(2K_1+1) + k_1 + K_1 + 1

assigned where r takes values from 1,\dots,K_1\times K_2. Single indexing is used for example by files r.sim and r_2.sim generated by functions bayesHistogram, bayesBisurvreg, bayessurvreg2 to save some space.

This function serves to translate single indeces to double indeces using the relationship

k_1 = (r - 1) \mbox{ mod } (2K_1+1) - K_1

k_2 = (r - 1) \mbox{ div } (2K_1+1) - K_2

The function can be used also in one dimensional case when a~simple relationship holds

r = k + K + 1

k = r - 1 - K

Usage

vecr2matr(vec.r, KK)

Arguments

vec.r

a~vector of single indeces

KK

a~vector with numbers of knots on each side of the central knot for each dimension of the G-spline. The length of KK determines dimension of the G-spline

Value

In bivariate case: a~matrix with two columns and as many rows as the length of vec.r.

In univariate case: a~vector with as ,amy components as the length of vec.r.

Author(s)

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

Examples

### Bivariate G-spline
### with 31 knots in each dimension
KK <- c(15, 15)

### First observation in component (-15, -15),
### second observation in component (15, 15),
### third observation in component (0, 0)
vec.r <- c(1, 961, 481)
vecr2matr(vec.r, KK)

[Package bayesSurv version 3.7 Index]