Learn R Programming

RSiena (version 1.1-212)

bayes: A function for fitting Bayesian models

Description

A function to fit a Bayesian model to Siena Data objects. Uses the function maxlikec for the MCMC part, the Bayesian part is performed in R.

Usage

bayes(data, effects, model, nwarm=100, nmain=100, nrunMHBatches=20,
      plotit=FALSE, nbrNodes=1, dfra=NULL, n=10,
      priorSigma=NULL, prevAns=NULL, clusterType=c("PSOCK", "FORK"),
      getDocumentation=FALSE)

Arguments

Value

Returns a list containing, among other things:posteriorTot?posteriorMII?candidatesarray of parametersacceptancesmatrix of booleans: whether the corresponding change to the parameters was accepted. By group.MHacceptancesarray of acceptances of the MH steps, by step type and group but summed over dependent variables.MHrejectionsarray of rejections of the ML stepsMHproportionsarray of proportions of the MH steps accepted

Details

This function wraps Bayesian sampling of parameters around calls to maxlikec. Unless a Hessian is supplied, one will be estimated from n batches of MH steps using the initial parameters. It is then transformed so the basic rate parameters are on a log scale. And inverted. It then attempts to scale the sampling covariance matrix to achieve about 40 out of 100 acceptances of Bayes proposals after single MH steps. Then a warming phase is done of nwarm Bayesian proposals each with 4 MH steps. Finally nmain repeats of (nrunMHBatches of nrunMH steps plus 1 Bayesian propsal) are performed. If plotit is TRUE, plots are produced at intervals during the run showing progress. They can be memory hogs, but the code may be useful for use on the returned values.

References

See http://www.stats.ox.ac.uk/~snijders/siena/

See Also

siena07

Examples

Run this code
mynet1 <- sienaNet(array(c(tmp3, tmp4), dim=c(32, 32, 2)))
mydata <- sienaDataCreate(mynet1)
myeff <- getEffects(mydata)
myeff <- includeEffects(myeff, transTrip)
mymodel <- sienaModelCreate(maxlike=TRUE)
ans <- bayes(mydata, myeff, mymodel)

Run the code above in your browser using DataLab