vecr2matr | R Documentation |
Components of a bivariate G-spline can be indexed in several ways. Suppose that the knots in the first dimension are mu[1,-K1],...,mu[1,K1] and the knots in the second dimension mu[2,-K2],...,mu[2,K2]. I.e. we have 2*K[1]+1 knots in the first dimension and 2*K[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,k1], mu[2,k2]) or alternatively the same G-spline component can have a~single index
r=(k[2]+K[2])*(2*K[1]+1) + k[1] + K[1] + 1
assigned where r takes values from
1,...,K[1]*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) %% (2*K[1]+1) - K[1]
k[2] = (r-1) %\ % (2*K[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
vecr2matr(vec.r, KK)
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 |
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
.
Arnošt Komárek arnost.komarek@mff.cuni.cz
### 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.