Learn R Programming

R2MLwiN (version 0.8-1)

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

Description

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

Usage

write.IGLS(indata, dtafile, oldsyntax = FALSE, resp, levID, expl, rp,
  D = "Normal", nonlinear = c(0, 1), categ = NULL, notation = NULL,
  nonfp = NA, clre = NULL, Meth = 1, extra = FALSE, reset,
  rcon = NULL, fcon = NULL, maxiter = 20, convtol = 2,
  mem.init = "default", optimat = FALSE, weighting = NULL,
  fpsandwich = FALSE, rpsandwich = FALSE, macrofile, IGLSfile, resifile,
  resi.store = FALSE, resioptions, debugmode = FALSE, startval = NULL,
  namemap = sapply(colnames(indata), as.character))

Arguments

indata
A data.frame object containing the data to be modelled.
dtafile
The name of the temporary file used to send the data to MLwiN, which is in Stata format (i.e. with extension .dta).
oldsyntax
Specified as FALSE if new syntax has been used in Formula object, else specified as TRUE (to enable back-compatibility).
resp
A character string (vector) of the response variable name(s).
levID
A character string (vector) of the specified level ID name(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 name(s).
rp
A character string (vector) of random part of random variable name(s).
D
A character string/vector specifying the type of distribution to be modelled, which can include 'Normal' (the default), 'Binomial', 'Poisson', 'Negbinom', 'Unordered Multinomial', 'O
nonlinear
A character vector specifying linearisation method for discrete response models (see Chapter 9 of Rasbash et al 2012, and Goldstein 2011). N = 0 specifies marginal quasi-likelihood linearization (MQL), whilst N = 1 specifies p
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;
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 define which elements of the random effects matrix to remove (i.e. hold constant at zero). Removes from the random part at level the covariance matrix element(s) defined by the pair(s) of rows . Each
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).
extra
If TRUE, extra binomial, extra negative binomial, extra Poisson or extra multinomial distributions assumed, else FALSE.
reset
A vector of length(levID) specifying the action to be taken, at each level, if a variance parameter is estimated at a particular iteration to be negative during estimation. Values specified in ascending order of level hierarchy: if 0
rcon
Matrix specifying constraints on the random parameters as specified in random.ui and random.ci in the constraints option within estoptions (see runMLwiN
fcon
Matrix specifying constraints on the fixed coefficients as specified in fixed.ui and fixed.ci in the constraints option within estoptions (see runMLwiN
maxiter
Numeric value specifying the maximum number of iterations, from the start, before estimation halts.
convtol
Numeric value specifying the convergence criterion, as specified in the tol option within estoptions (see runMLwiN). If value of convtol is m, estimation will be d
mem.init
If calling write.IGLS directly, if wish to use defaults, value needs to be specified as 'default', else specify a vector of length 5 corresponding to the following order: number of levels; worksheet size in thousands of cells; the number o
optimat
This option instructs MLwiN to limit the maximum matrix size that can be allocated by the (R)IGLS algorithm. Specify optimat = TRUE if MLwiN gives the following error message 'Overflow allocating smatrix'. This error message arises if one
weighting
A list of two items, one of which is a list called weightvar the length of which corresponds to the number of levels in the model, in descending order from highest level first. The other is an option standardised which is
fpsandwich
Specifies standard error type for fixed parameters. If fpsandwich = TRUE, robust or `sandwich' standard errors based on raw residuals are used, if fpsandwich = FALSE (default) then standard, uncorrected, IGLS or RIGLS computat
rpsandwich
Specifies standard error type for random parameters. If rpsandwich = TRUE, robust or `sandwich' standard errors based on raw residuals are used, if rpsandwich = FALSE (default) then standard, uncorrected, IGLS or RIGLS `plug i
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'
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 the MLwiN GUI is opened, and then pauses after the model has been set-up, allo
startval
A list of numeric vectors specifying the starting values. FP.b corresponds to the estimates for the fixed part; FP.v specifies the variance/covariance estimates for the fixed part; RP.b specifies the variance esti
namemap
A mapping of column names to DTA friendly shorter names

Value

  • Outputs a modified version of namemap containing newly generated short names.

References

Goldstein, H. (2011) Multilevel Statistical Models. 4th Edition. London: John Wiley and Sons. Rasbash, J., Steele, F., Browne, W.J. and Goldstein, H. (2012) A User's Guide to MLwiN Version 2.26. Centre for Multilevel Modelling, University of Bristol.

See Also

write.MCMC