View source: R/metastan_data.R
metastan_data | R Documentation |
metastan_data
creates datasets suitable for meta_stan function
metastan_data( id, treatment, x, type = c("normal", "binomial", "poisson"), y, se, v, count, total, exposure, labels, data, sort = TRUE, checkForConflicts = TRUE )
id |
a vector of study IDs (labels) |
treatment |
(optional) vector indicating treatment groups |
x |
(optional) covariable/regressor vector or matrix |
type |
type of outcome |
y |
estimates (for normal outcomes) |
se |
associated standard errors (normal outcomes) |
v |
variances / squared standard errors (normal outcomes) |
count |
event count (for binomial or Poisson outcomes) |
total |
sample size (for binomial outcomes) |
exposure |
exposure (for Poisson outcomes) |
labels |
(optional) vector of row labels |
data |
a data frame from which (some of) above variables may be taken |
sort |
if TRUE (the default), output rows will be sorted (keeping entries corresponding to the same study ("id") next to each other, and sorting by "treatment" and "x") |
The resulting data.frame can be used as data argument in meta_stan
.
NB: arguments "id", "treatment", "x", "y", "se", "v", "count", "total", "exposure", "labels" may be taken from local environment OR from "data" (data frame) argument.
The returned object is a "list" of class "metastan_data" containing the following elements: * "id" : study identifier (a vector of type factor) * "treatment" : (optional) a treatment identifier (a vector of type factor, or NULL) * "x" : (optional) covariable(s), (a numeric matrix, or NULL) * "type" : a flag identifying the outcome type ("normal", "binomial", or "poisson") * "outcome" : the actual outcome data (a two-column numeric matrix) * "call" : the original function call
# 3 studies, binomial endpoint, one covariable (named "dose"): msd <- metastan_data(id=c("Smith","Smith", "Taylor","Taylor", "Jones", "Jones","Taylor"), treatment=c("placebo","verum","placebo","verum", "verum","placebo","verum"), type="binomial", count=c(3, 2, 7, 5, 4, 5, 6), total=c(10, 10, 25, 27, 15, 16, 23), x=cbind("dose"=c(0, 50, 0, 50, 30, 0, 20))) msd print(msd, n=7) # (show all 7 lines of data) print.default(msd) # default view of returned object
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.