files2coda             package:bayesSurv             R Documentation

_R_e_a_d _t_h_e _s_a_m_p_l_e_d _v_a_l_u_e_s _f_r_o_m _t_h_e _B_a_y_e_s_i_a_n _s_u_r_v_i_v_a_l _r_e_g_r_e_s_s_i_o_n _m_o_d_e_l
_t_o _a _c_o_d_a _m_c_m_c _o_b_j_e_c_t.

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

     This function creates a 'coda' 'mcmc' object from values found in
     files where sampled values from 'bayessurvreg1' function are
     stored or from data.frames.

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

     files2coda(files, data.frames, variant = 1, dir = getwd(),
        start = 1, end, thin = 1, header = TRUE, chain)

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

   files: a vector of strings giving the names of files that are to be
          converted to 'coda' objects. If missing and 'data.frames' is
          also missing, all appropriate files found in a directory
          'dir' are converted to coda objects. File "iteration.sim" is
          always used (if found) to index the sampled values. If this
          file is not found the sampled values are indexed from 1 to
          the sample size. If "mixture.sim" appeares here, only the
          column with number of mixture components is converted to the
          coda object.

data.frames: a vector of strings giving the names of data.frames that
          are to be converted to 'coda' objects. 

 variant: a variant of 'bayessurvreg' function used to generate sampled
          values. This argument is only used to identify appropriate
          files when 'files' argument is missing.

          Currently only 1 is supported to cooperate with
          'bayessurvreg1'. 

     dir: string giving the directory where it will be searched for the
          files with  sampled values.

   start: the first row (possible header does not count) from the files
          with the sampled values that will be converted to coda
          objects.

     end: the last row from the files with the sampled values that will
          be converted to coda objects. If missing, it is the last row
          in files.

    thin: additional thinning of sampled values (i.e. only every 'thin'
          value from 'files' and 'data.frames' is considered).

  header: TRUE or FALSE indicating whether the files with the sampled
          values contain also the header on the first line or not.

   chain: parameter giving the number of the chain if parallel chains
          were created and sampled values stored in data.frames further
          stored in lists(). If 'missing', data.frames are not assumed
          to be stored in lists.

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

     A list with 'mcmc' objects. One object per file or data.frame.

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

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

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

     ## *** illustration of usage of parameters 'data.frames' and 'chain' ***
     ## *********************************************************************
     ## Two parallel chains with four variables, stored in data.frames
     ## data.frames are further stored in lists
     library(coda)

     group1 <- list();  group2 <- list();  group3 <- list()
         ## first chain of first two variables:
       group1[[1]] <- data.frame(var1 = rnorm(100, 0, 1), var2 = rnorm(100, 5, 4))
         ## second chain of first two variables:   
       group1[[2]] <- data.frame(var1 = rnorm(100, 0, 1), var2 = rnorm(100, 5, 4))
         ## first chain of the third variable:
       group2[[1]] <- data.frame(var3 = rgamma(100, 1, 1))
         ## second chain of the third variable:
       group2[[2]] <- data.frame(var3 = rgamma(100, 1, 1))
         ## first chain of the fourth variable:
       group3[[1]] <- data.frame(var4 = rbinom(100, 1, 0.4))
         ## second chain of the fourth variable:
       group3[[2]] <- data.frame(var4 = rbinom(100, 1, 0.4))  

       ## Create mcmc objects for each chain separately
     mc.chain1 <- files2coda(data.frames = c("group1", "group2", "group3"), chain = 1)
     mc.chain2 <- files2coda(data.frames = c("group1", "group2", "group3"), chain = 2)

       ## Create mcmc.list to represent two parallel chains
     mc <- mcmc.list(mc.chain1, mc.chain2)
     rm(mc.chain1, mc.chain2)

     ## *** illustration of usage of parameter 'data.frames' without 'chain' ***
     ## ************************************************************************
     ## Only one chain for four variables was sampled and stored in three data.frames
         ## chain of first two variables:
       group1 <- data.frame(var1 = rnorm(100, 0, 1), var2 = rnorm(100, 5, 4))
         ## chain of the third variable:  
       group2 <- data.frame(var3 = rgamma(100, 1, 1))
         ## chain of the fourth variable:
       group3 <- data.frame(var4 = rbinom(100, 1, 0.4))                        

       ## Create an mcmc object
     mc <- files2coda(data.frames = c("group1", "group2", "group3"))

