MCmcmc {MethComp}R Documentation

Fit a model for method comparison studies using WinBUGS

Description

A model linking each of a number of methods of measurement linearly to the "true" value is set up in BUGS and run via the function bugs from the R2WinBUGS package.

Usage

MCmcmc( data,
        linked = FALSE,
           IxR = linked,
           MxI = TRUE,
        varMxI = TRUE,
     intercept = TRUE,
         slope = intercept,
      n.chains = 4,
        n.iter = 2000,
      n.burnin = n.iter/2,
        n.thin = ceiling((n.iter - n.burnin)/1000),
bugs.directory = getOption("bugs.directory"),
         debug = FALSE,
bugs.code.file = "model.txt",
       clearWD = TRUE,
        bugsWD = "bugsWD",
     code.only = FALSE,
      ini.mult = 2,
           org = FALSE,
       program = "BRugs",
           ...)
## S3 method for class 'MCmcmc':
summary( object, alpha=0.05, ...)
## S3 method for class 'MCmcmc':
print( x, across, digits=3, alpha=0.05, ... )
## S3 method for class 'MCmcmc':
subset( x, subset=NULL, allow.repl=FALSE, chains=NULL, ... )
## S3 method for class 'MCmcmc':
mcmc( x, ... )
  

Arguments

data Data frame with variables meth, item, repl and y. y represents a measurement on an item (typically patient or sample) by method meth, in replicate repl.
linked Logical. Are the replicates linked across methods. If true, a random item by repl is included in the model.
IxR Logical, alias for linked.
MxI Logical, should the method by item effect be in the model?
varMxI Logical, should the method by item effect have method-specific variances. Ignored if only two methods are compared.
intercept Logical. If FALSE the bias between methods will be assumed to be 0. If slope is TRUE when intercept is FALSE, the resulting model assumes proportional bias, which is a very strong assumption.
slope Logical. Should a slope other than 1 be allowed? If FALSE the bias between methods will be assumed constant.
n.chains How many chains should be run by WinBUGS — passed on to bugs.
n.iter How many total iterations — passed on to bugs.
n.burnin How many of these should be burn-in — passed on to bugs.
n.thin How many should be sampled — passed on to bugs.
bugs.directory Where is WinBUGS (>=1.4) installed — passed on to bugs. The default is to use a parameter from options(). If you use this routinely, this is most conveniently set in your .Rprofile file.
debug Should WinBUGS remain open after running — passed on to bugs.
clearWD Should the working directory be cleared for junk files after the running of WinBUGS — passed on to bugs.
bugsWD Name of the folder where the bugs files are put. The code file is also put in this folder.
bugs.code.file Where should the bugs code go?
code.only Should MCmcmc just create a bugs code file and a set of inits?
ini.mult Numeric. What factor should be used to randomly perturb the initial values for the variance componets, see below in details.
org Logical. Should the posterior of the original model parameters be returned too? If TRUE, the MCmcmc object will have an attribute, original, with the posterior of the parameters in the model actually simulated.
program Which program should be used for the MCMC simulation. Possible values are "brugs","openbugs","ob" (openBUGS), "winbugs","wb" (WinBUGS).
... Additional arguments passed on to bugs.
object A MCmcmc object
alpha 1 minus the the confidence level
x A MCmcmc object
across Should the summary of conversion formulae be printed with $α$, $β$ and prediction sd. across or down?
digits Number of digits after the decimal point when printing.
subset Numerical, character or list giving the variables to keep. If numerical, the variables in the MCmcmc object with these numbers are selected. If character, each element of the character vector is "grep"ed against the variable names, and the matches are selected to the subset. If a list each element is used in turn, numerical and character elements can be mixed.
allow.repl Should duplicate columns be allowed in the result?
chains Numerical vector giving the number of the chains to keep.

Details

The model set up for an observation y_mir is:

y_mir = alpha_m + beta_m*(mu_i+b_ir+c_mi) + e_mir

where $b_{ir}$ is a random item by repl interaction (included if "ir" %in% random) and $c_{mi}$ is a random meth by item interaction (included if "mi" %in% random). The mu_i's are parameters in the model but are not monitored — only the alphas, betas and the variances of b_{ir}, c_{mi} and e_{mir} are monitored and returned. The estimated parameters are only determined up to a linear transformation of the mus, but the linear functions linking methods are invariant. The identifiable conversion parameters are:

alpha_m|k=alpha_m-alpha_k beta_m/beta_k, beta_m|k=beta_m/beta_k

The posteriors of these are derived and included in the posterior, which also will contain the posterior of the variance components (the sd's, that is). Furthermore, the posterior of the point where the conversion lines intersects the identity as well as the prediction sd's between any pairs of methods are included.

The function summary.MCmcmc method gives estimates of the conversion parameters that are consistent. Clearly,

median(beta.1.2)=1/median(beta.2.1)

because the inverse is a monotone transformation, but there is no guarantee that

median(alpha.1.2)=median(-alpha.2.1/beta.2.1)

and hence no guarantee that the parameters derived as posterior medians produce conversion lines that are the same in both directions. Therefore, summary.MCmcmc computes the estimate for α_{2cdot 1} {alpha.2.1} as

(median(alpha.1.2)-median(alpha.2.1)/ median(beta.2.1))/2

and the estimate of alpha.1.2 correspondingly. The resulting parameter estimates defines the same lines.

Value

If code.only==FALSE, an object of class MCmcmc which is a mcmc.list object of the relevant parametes, i.e. the posteriors of the conversion parameters and the variance components transformed to the scales of each of the methods.
Furthermore, the object have the following attibutes:

random Character vector indicatinf which random effects ("ir","mi") were included in the model.
methods Character vector with the method names.
data The dataframe used in the analysis. This is used in plot.MCmcmc when plotting points.
mcmc.par A list giving the number of chains etc. used to generate the object.
original If org=TRUE, an mcmc.list object with the posterior of the original model parameters, i.e. the variance components and the unidentifiable mean parameters.


If code.only==TRUE, a list containing the initial values is generated.

Author(s)

Bendix Carstensen, Steno Diabetes Center, http://www.biostat.ku.dk/~bxc, Lyle Gurrin, University of Melbourne, http://www.epi.unimelb.edu.au/about/staff/gurrin-lyle.

References

B Carstensen: Comparing and predicting between several methods of measurement, Biostatistics, 5, pp 399-413, 2004

See Also

BA.plot, plot.MCmcmc, print.MCmcmc, check.MCmcmc

Examples

data( ox )
str( ox )
MCmcmc( ox, MI=TRUE, IR=TRUE, code.only=TRUE, bugs.code.file="" )

### What is written here is not necessarily correct on your machine.
# ox.MC <- MCmcmc( ox, MI=TRUE, IR=TRUE, n.iter=100, program="winbugs" )
# ox.MC <- MCmcmc( ox, MI=TRUE, IR=TRUE, n.iter=100 )
# data( ox.MC )
#  str( ox.MC )
#print( ox.MC )

[Package MethComp version 0.5.0 Index]