genInitsFile              package:rbugs              R Documentation

_G_e_n_e_r_a_t_i_n_g _I_n_i_t_i_a_l _V_a_l_u_e _F_i_l_e_s _f_o_r _B_U_G_S

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

     Generating the files of initial values for MCMC which can be used
     in the script for running BUGS in batch-mode.

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

     genInitsFile(n.chains, inits, initsFileStem)

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

n.chains: The number of chains to run.

   inits: A list of list of initial values or a function which returns
          a list of initial values. See details.

initsFileStem: A character string naming the files to print to. See
          details.

_D_e_t_a_i_l_s:

     if 'inits' is a list, it should have length 'n.chains', and each
     element of the list should be a list which contains one set of
     initial values. If 'inits' is a function, it will be run
     'n.chains' times to generate a list of list of initial values.

     The 'initsFileStem' is the stem of the file names. The resulted
     file names end with .txt. For example, if 'n.chains' is 3 and
     'initsFileStem' is "init", then the file names will be init1.txt,
     init2.txt, and init3.txt.

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

     None.

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

     Jun Yan jyan@stat.uiowa.edu

_S_e_e _A_l_s_o:

     'genDataFile', 'genBugsScript'

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

     ## when inits is a list:
     inits <- list(list(alpha=1, beta=2), list(alpha=4, beta=4))
     genInitsFile(2, inits, "foo.init")
     file.show("foo.init1.txt")
     file.show("foo.init2.txt")
     ## when inits is a function:
     inits <- function() list(alpha=rnorm(2, sd=100),
                              beta=rgamma(1, 0.1, 0.001))
     genInitsFile(2, inits, "foo.init")
     file.show("foo.init1.txt")
     file.show("foo.init2.txt")
     unlink("foo.init1.txt")
     unlink("foo.init2.txt")

