JAGSrun               package:bayesmix               R Documentation

_M_C_M_C _s_a_m_p_l_i_n_g _o_f _B_a_y_e_s_i_a_n _m_o_d_e_l_s

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

     Calls jags for MCMC sampling.

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

     JAGSrun(y, prefix = yname, model = BMMmodel(k = 2),
             control = JAGScontrol(variables = c("mu", "tau", "eta")), tmp = TRUE,
             cleanup = TRUE, jags = getOption("jags.exe"), ...)

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

       y: a numeric vector.

  prefix: character prefix of files.

   model: object of class 'JAGSmodel' or output from 'BMMmodel'.

 control: specification of control by a 'JAGScontrol' object.

     tmp: logical: shall the files be written in a temporary directory.

 cleanup: logical: shall the created files be removed.

    jags: string indicating location of jags executable.

   yname: a character string with the actual 'y' argument name.

     ...: further parameters handed over to 'BMMmodel' where it is used
          for the function specifiying the initial values, e.g.,
          'initsFS'.

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

     If an error occurs when runing jags, the created files are not
     removed. This function is a wrapper calling 'JAGSsetup',
     'JAGScall' and 'JAGSread'.

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

     Returns a 'jags' object with components 

    call: the matched call.

 results: results read in from ``jags.out'' if run was successful or
          from ``jags.dump'' if an error occurred.

   model: a 'JAGSmodel' object.

variables: vector containing the names of the monitored variables.

    data: a numeric vector.

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

     Bettina Gruen

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

     'JAGSsetup', 'JAGScall', 'JAGSread', 'BMMmodel', 'initsFS'

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

     data(fish)
     prefix <- "fish"
     variables <- c("mu","tau","eta")
     k <- 3
     modelFish <- BMMmodel(k = k, priors = list(kind = "independence",
                           parameter = "priorsFish", hierarchical = "tau"))
     controlFish <- JAGScontrol(variables = c(variables, "S"), draw = 100, seed = 1)
     ## Installation of JAGS necessary for applying these functions
     if (haveJAGS()) {
     z1 <- JAGSrun(fish, prefix, model = modelFish, initialValues = list(S0 = 2),
                   control = controlFish, cleanup = TRUE, tmp = FALSE)
     zSort <- Sort(z1, "mu")
     BMMposteriori(zSort)
     }
     data(darwin)
     prefix <- "darwin"
     k <- 2
     modelDarwin <- BMMmodel(k = k, priors = list(kind = "independence",
                             parameter = "priorsUncertain"), aprioriWeights = c(1, 15),
                             no.empty.classes = TRUE, restrict = "tau")
     ## Installation of JAGS necessary for applying these functions
     if (haveJAGS()) {
     z2 <- JAGSrun(darwin, prefix, model = modelDarwin, control =
                   JAGScontrol(variables = variables, draw = 3000, burnIn = 1000,
                   seed = 1), cleanup = TRUE, tmp = FALSE)
     plot(z2, variables = "mu")
     }

