mlwin2bugs: This function captures output files from MLwiN for estimation...

View source: R/mlwin2bugs.R

mlwin2bugsR Documentation

This function captures output files from MLwiN for estimation in WinBUGS/OpenBUGS.

Description

This function allows R to call WinBUGS using the output files from MLwiN. This function uses functionalities in the R2WinBUGS-package package.

Usage

mlwin2bugs(
  D,
  levID,
  datafile,
  initfiles,
  modelfile,
  bugEst,
  fact,
  addmore,
  n.chains,
  n.iter,
  n.burnin,
  n.thin,
  debug = FALSE,
  bugs.directory = bugs.directory,
  bugsWorkingDir = tempdir(),
  OpenBugs = FALSE,
  cleanBugsWorkingDir = FALSE,
  seed = NULL
)

Arguments

D

A vector specifying the type of distribution used in the model.

levID

A character (vector) specifying the level ID(s).

datafile

A file name where the BUGS data file will be saved in .txt format.

initfiles

A list of file names where the BUGS initial values will be saved in .txt format.

modelfile

A file name where the BUGS model will be saved in .txt format.

bugEst

A file name where the estimates from BUGS will be stored in .txt format.

fact

A list of objects used to specify factor analysis. See ‘Details’ below.

addmore

A vector of strings specifying additional coefficients to be monitored.

n.chains

The number of chains to be monitored.

n.iter

The number of iterations for each chain

n.burnin

The length of burn-in for each chain

n.thin

Thinning rate

debug

A logical value indicating whether (TRUE) or not (FALSE; the default) to close the BUGS window after completion of the model run

bugs.directory

The full path of location where WinBUGS is installed (ignored if OpenBugs is TRUE).

bugsWorkingDir

A directory where all the intermediate files are to be stored; defaults to tempdir().

OpenBugs

If TRUE, OpenBUGS is used, if FALSE (the default) WinBUGS is used.

cleanBugsWorkingDir

If TRUE, the generated files will be removed from the bugsWorkingDir; defaults to FALSE.

seed

An integer specifying the random seed.

Details

A list of objects to specify factor analysis, as used in the argument fact:

  • nfact: specifies the number of factors;

  • lev.fact: Specifies the level/classification for the random part of the factor for each factor;

  • nfactcor: specifies the number of correlated factors;

  • factcor: a vector specifying the correlated factors: the first element corresponds to the first factor number, the second to the second factor number, the third element corresponds to the starting value for the covariance and the fourth element to whether this covariance is constrained (1) or not (0). If more than one pair of factors is correlated, then repeat this sequence for each pair.

  • loading: a matrix specifying the starting values for the factor loadings and the starting value of the factor variance. Each row corresponds to a factor.

  • constr: a matrix specifying indicators of whether the factor loadings and the factor variance are constrained (1) or not (0).

Value

Returns an mcmc object.

Author(s)

Zhang, Z., Charlton, C.M.J., Parker, R.M.A., Leckie, G., and Browne, W.J. (2016) Centre for Multilevel Modelling, University of Bristol.

See Also

runMLwiN,bugs


R2MLwiN documentation built on May 29, 2024, 2:10 a.m.