Learn R Programming

R2MLwiN (version 0.1-7)

MacroScript1: Writes MLwiN macros to fit models using the iterative generalized least squares (IGLS) algorithm

Description

MacroScript1 is an internal function which creates an MLwiN macro file to fit a multilevel model using IGLS.

Usage

MacroScript1(indata, dtafile, resp,
levID, expl, rp, D = "Normal",
nonlinear = c(0, 1), categ = NULL,
notation = NULL, nonfp = NA,
clre, smat, Meth = 1,
BUGO = NULL, mem.init = "default",
weighting = NULL,
modelfile = modelfile,
initfile = initfile, datafile = datafile,
macrofile = macrofile, IGLSfile = IGLSfile,
resifile = resifile, resi.store = resi.store,
resioptions = resioptions, debugmode = debugmode)

Arguments

indata
A data.frame object containing the data to be modelled.
dtafile
The file name of the dataset to be imported into MLwiN, which is in Stata format (i.e. with extension .dta).
resp
A character string (vector) of response variable(s).
levID
A character string (vector) of the specified level ID(s). The ID(s) should be sorted in the descending order of levels (e.g. levID=c('level2','level1') where 'level2' is the higher level).
expl
A character string (vector) of explanatory (predictor) variable(s).
rp
A character string (vector) of random part of random variable(s).
D
A vector specifying the type of distribution to be modelled, which can include "Normal", "Binomial" "Poisson", "Unordered Multinomial", "Ordered Multinomial", "Multivariate Normal"
nonlinear
LINEarise mode N order M. N=0 specifies marginal quasi-likelihood linearization (MQL), whilst N=1 specifies penalised quasi-likelihood linearization (PQL); M=1 specifies first order approximation, whilst M=2
categ
Specifies categorical variable(s) as a matrix. Each column corresponds to a categorical variable; the first row specifies the name(s) of variable(s); the second row specifies the name(s) of reference group(s), NA(s) if no reference group; th
notation
Specifies the model subscript notation to be used in the MLwiN equations window. "class" means no multiple subscripts, whereas "level" has multiple subscripts.
nonfp
Removes the fixed part of random variable(s). NA if no variable to be removed.
clre
A matrix used to estimate some, but not all, of the variances and covariances for a set of coefficients at a particular level. Removes from the random part at level the covariance matrix element(s) defined by the pair(s) of rows <
smat
An integer vector of length 2 specifying whether the covariance matrix at a particular level is diagonal. The first digit is the level indicator, whilst the second digit is a binary indicator where 1 indicates a diagonal covariance matrix and
Meth
Specifies which maximum likelihood estimation method to be used. If Meth=0 estimation method is set to RIGLS. If Meth=1 estimation method is set to IGLS (the default setting). If Meth is absent, alternate between IGL
BUGO
If the first entry of the vector is TRUE, the current model is outputted in BUGS code. version=4 specifies WinBUGS 1.4 format, whilst version=3 corresponds to WinBUGS 1.3 format. n.chains specifies the n
mem.init
A vector which sets and displays worksheet capacities for the current MLwiN session according to the value(s) specified. By default, the number of levels is nlev+1; worksheet size in thousands of cells is 6000; the number of columns is 2500;
weighting
A list of objects specified for using weights in an analysis, including levels, weights, mode, FSDE and RSDE. By default, weighting is NULL, i.e., equal weights for
modelfile
A file name where the WinBUGS model will be saved in .txt format.
initfile
A file name where the WinBUGS initial values will be saved in .txt format.
datafile
A file name where the WinBUGS data will be saved in .txt format.
macrofile
A file name where the MLwiN macro file will be saved. The default location is in the temporary folder.
IGLSfile
A file name where the parameter estimates will be saved. The default location is in the temporary folder.
resifile
A file name where the residuals will be saved. The default location is in the temporary folder.
resi.store
A logical value to indicate if the residuals are to be stored (TRUE) or not (FALSE).
resioptions
A string vector to specify the various residual options. The "variances" option calculates the posterior variances instead of the posterior standard errors; the "standardised", "leverage", "influence" an
debugmode
A logical value determining whether MLwiN is run in the background or not. The default value is FALSE: i.e. MLwiN is run in the background. If TRUE MLwiN remains open after the model has run, allowing the user to interact with ML

Value

  • The MLwiN macro file is created in the temporary directory (tempdir()) and will be displayed on screen if show.file=TRUE..

See Also

MacroScript2,tempdir