vecr2matr             package:bayesSurv             R Documentation

_T_r_a_n_s_f_o_r_m _s_i_n_g_l_e _c_o_m_p_o_n_e_n_t _i_n_d_e_c_e_s _t_o _d_o_u_b_l_e _c_o_m_p_o_n_e_n_t _i_n_d_e_c_e_s

_D_e_s_c_r_i_p_t_i_o_n:

     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

_U_s_a_g_e:

     vecr2matr(vec.r, KK)

_A_r_g_u_m_e_n_t_s:

   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

_V_a_l_u_e:

     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'.

_A_u_t_h_o_r(_s):

     Arno&#353t Kom&#225rek komarek@karlin.mff.cuni.cz

_E_x_a_m_p_l_e_s:

     ### 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)

