BRugsFit                package:BRugs                R Documentation

_B_R_u_g_s' _m_e_t_a _f_u_n_c_t_i_o_n

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

     This function takes model, data and starting values as input and
     automatically runs a simulation in BRugs.

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

     BRugsFit(modelFile, data, inits, numChains = 3, parametersToSave,
         nBurnin = 1000, nIter = 1000, nThin = 1,
         DIC = TRUE, working.directory = NULL, digits = 5, 
         BRugsVerbose = getOption("BRugsVerbose"))

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

modelFile: File containing the model written in OpenBUGS code.

    data: Either a named list (names corresponding to variable names in
          the 'modelFile')  of the data for the OpenBUGS model, _or_ a
          vector or list of the names of the data objects used by the
          model. In these cases data are written into a file 'data.txt'
          into the working directory.

          If a filename of an existing file is given, data are read
          from that file.

   inits: A list with 'numChains' elements; each element of the list is
          itself a list of starting values for the OpenBUGS model, _or_
          a function creating (possibly random) initial values. In
          these cases inits are written into files 'inits1.txt', ...,
          'initsN.txt' into the working directory.

          If a vector of filenames of existing files is given, inits
          are read from those files. Alternatively, if 'inits' is not
          specified, initial values are generated by OpenBUGS.

numChains: Number of Markov chains (default: 3).

parametersToSave: Character vector of the names of the parameters to
          save which should be monitored.

 nBurnin: Length of burn in (before 'nIter' iterations start).

   nIter: Number of iterations (without burn in).

   nThin: Every 'nThin'-th iteration of each chain is stored.

     DIC: Logical, whether to calculate and return the DIC.

working.directory: Sets working directory during execution of this
          function; 'data', 'inits' and other files are written to /
          read from this directory if no other directory  is explicitly
          given in those arguments. If 'NULL', the current working
          directory is chosen.

  digits: Number of significant digits used for OpenBUGS input, see
          'formatC'.

BRugsVerbose: Logical, whether BRugs is supposed to be verbose.  This
          can be controlled for the whole BRugs package by by the
          option 'BRugsVerbose' (see 'options') which is set to 'TRUE'
          by default.

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

     A list containg components 

   Stats: A data frame containing sample statistics. See
          'samplesStats'.

     DIC: The DIC statistics, if 'DIC=TRUE', else 'NULL'. See
          'dicStats'.

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

     'BRugs', 'help.WinBUGS'.  Andrew Gelman proposes some 'print' and
     'plot' methods that can be accessed by the  'openbugs' (and
     'bugs') and 'as.bugs.array' functions in the CRAN package
     'R2WinBUGS'.

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

     BRugsFit(data = "ratsdata.txt", inits = "ratsinits.txt", 
         para = c("alpha", "beta"), modelFile = "ratsmodel.txt", 
         numChains = 1, 
         working.directory = system.file("OpenBUGS", "Examples", 
                                         package = "BRugs"))

