Learn R Programming

MethComp (version 1.22.2)

Meth: Create a Meth object representing a method comparison study

Description

Creates a dataframe with columns meth, item, (repl) and y.

Usage

Meth( data=NULL, meth="meth", item="item", repl=NULL, y="y", print=!is.null(data), keep.vars=!is.null(data) ) "summary"( object, ... ) "plot"(x, which = NULL, col.LoA = "blue", col.pt = "black", cex.name = 2, var.range, diff.range, var.names = FALSE, pch = 16, cex = 0.7, Transform, ... ) "mean"(x, na.rm=TRUE, simplify=TRUE, ... ) "sort"(x, ... ) "subset"(x, ... ) "sample"( x, how = "random", N = if( how=="items" ) nlevels( x$item ) else nrow(x), ... ) "transform"(`_data`, ... )

Arguments

data
A dataframe.
meth
Vector of methods, numeric, character or factor. Can also be a number or character referring to a column in data.
item
Vector of items, numeric, character or factor. Can also be a number or character referring to a column in data.
repl
Vector of replicate numbers, numeric, character or factor. Can also be a number or character referring to a column in data.
y
Vector of measurements. Can also be a character or numerical vector pointing to columns in data which contains the measurements by different methods or a dataframe with columns representing measurements by different methods. In this case the argument meth is ignored, and the names of the columns are taken as method names.
print
Logical: Should a summary result be printed?
keep.vars
Logical. Should the remaining variables from the dataframe data be transferred to the Meth object.
object
A Meth object.
x
A Meth object.
which
A vector of indices or names of methods to plot. If NULL all methods in the object are plotted.
col.LoA
What color should be used for the limits of agreement.
col.pt
What color should be used for the points.
cex.name
Character expansion factor for plotting method names
var.range
The range of both axes in the scatter plot and the x-axis in the Bland-Altman plot be?
diff.range
The range of yaxis in the Bland-Altman plot. Defaults to a range as the x-axis, but centered around 0.
var.names
If logical: should the individual panels be labelled with the variable names?. If character, then the values of the character will be used to label the methods.
pch
Plot character for points.
cex
Plot charcter expansion for points.
Transform
Transformation used to the measurements prior to plotting. Function or character, see choose.trans for possible values.
na.rm
Logical. Should NAs be removed before calculations?
simplify
Should a Meth object with one row per (meth,item) be returned?
how
Character. What sampling strategy should be used, one of "random", "linked" or "item". Only the first letter is significant. See details for explanation.
N
How many observations should be sampled?
_data
A Meth object.
...
Ignored by the Meth and the summary and sample functions. In the plot function, parameters passed on to both the panel function plotting methods against each other, as well as to those plotting differences against means.

Value

Meth function returns a Meth object which is a dataframe with columns meth, item, (repl) and y. summary.Meth returns a table classified by method and no. of replicate measurements, extended with columns of the total number of items, total number of observations and the range of the measurements.The mean.Meth returns a Meth object where means have been computed over replicates, and put in a variable mean.y. If simplify=TRUE, a smaller Meth object will be returned with only one row per (meth,item), and the means in the variable y. This is useful if the definition of a particular measurement method is the mean of a specified number of replicate measuements. The functions mean.Meth, median.Meth, max.Meth, and min.Meth behaves similarly, whereas sort.Meth just sorts the replicates within each (meth,item), and puts the results in a variable sort.y added Meth object.The subset.Meth returns a subset of the Meth rows. If a subset of the methods is selected, the new meth variable will have levels equal to the actually present levels of meth in the new Meth object. This is not the case if subsetting is done using "[".

Details

In order to perform analyses of method comparisons it is convenient to have a dataframe with classifying factors, meth, item, and possibly repl and the response variable y. This function creates such a dataframe, and gives it a class, Meth, for which there is a number of methods: summary - tabulation, plot - plotting and a couple of analysis methods.

If there are replicates in the values of item it is assumed that those observations represent replicate measurements and different replicate numbers are given to those.

sample.Meth samples a Meth object with replacement. If how=="random", a random sample of the rows are sampled, the existing values of meth, item and y are kept but new replicate numbers are generated. If how=="linked", a random sample of the linked observations (i.e. observations with identical item and repl values) are sampled with replacement and replicate numbers are kept. If how=="item", items are sampled with replacement, and their observations are included the sampled numner of times.

Examples

Run this code
data(fat)
# Different ways of selecting columns and generating replicate numbers
Sub1 <- Meth(fat,meth=2,item=1,repl=3,y=4,print=TRUE)
Sub2 <- Meth(fat,2,1,3,4,print=TRUE)
Sub3 <- Meth(fat,meth="Obs",item="Id",repl="Rep",y="Sub",print=TRUE)
summary( Sub3 )
plot( Sub3 )

# Use observation in different columns as methods
data( CardOutput )
head( CardOutput )
sv <- Meth( CardOutput, y=c("Svo2","Scvo2") )
# Note that replicates are generated if a non-unique item-id is used
sv <- Meth( CardOutput, y=c("Svo2","Scvo2"), item="Age" )
str( sv )
# A summary is not created if the the first argument (data=) is not used:
sv <- Meth( y=CardOutput[,c("Svo2","Scvo2")], item=CardOutput$VO2 )
summary(sv)

# Sample items
ssv <- sample.Meth( sv, how="item", N=8 )

# More than two methods
data( sbp )
plot( Meth( sbp ) )
# Creating non-unique replicate numbers per (meth,item) creates a warning:
data( hba1c )
hb1  <- with( hba1c,
              Meth( meth=dev, item=item, repl=d.ana-d.samp, y=y, print=TRUE ) )
hb2  <- with( subset(hba1c,type=="Cap"),
              Meth( meth=dev, item=item, repl=d.ana-d.samp, y=y, print=TRUE ) )
  

Run the code above in your browser using DataLab