Convert data from two data frames or ffdf objects into a CyclopsData object

Description

convertToCyclopsData loads data from two data frames or ffdf objects, and inserts it into a Cyclops data object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
convertToCyclopsData(outcomes, covariates, modelType = "lr",
  addIntercept = TRUE, checkSorting = TRUE, checkRowIds = TRUE,
  normalize = NULL, quiet = FALSE)

## S3 method for class 'ffdf'
convertToCyclopsData(outcomes, covariates, modelType = "lr",
  addIntercept = TRUE, checkSorting = TRUE, checkRowIds = TRUE,
  normalize = NULL, quiet = FALSE)

## S3 method for class 'data.frame'
convertToCyclopsData(outcomes, covariates,
  modelType = "lr", addIntercept = TRUE, checkSorting = TRUE,
  checkRowIds = TRUE, normalize = NULL, quiet = FALSE)

Arguments

outcomes

A data frame or ffdf object containing the outcomes with predefined columns (see below).

covariates

A data frame or ffdf object containing the covariates with predefined columns (see below).

modelType

Cyclops model type. Current supported types are "pr", "cpr", lr", "clr", or "cox"

addIntercept

Add an intercept to the model?

checkSorting

Check if the data are sorted appropriately, and if not, sort.

checkRowIds

Check if all rowIds in the covariates appear in the outcomes.

normalize

String: Name of normalization for all non-indicator covariates (possible values: stdev, max, median)

quiet

If true, (warning) messages are surpressed.

Details

These columns are expected in the outcome object:

stratumId (integer) (optional) Stratum ID for conditional regression models
rowId (integer) Row ID is used to link multiple covariates (x) to a single outcome (y)
y (real) The outcome variable
time (real) For models that use time (e.g. Poisson or Cox regression) this contains time
(e.g. number of days)

These columns are expected in the covariates object:

stratumId (integer) (optional) Stratum ID for conditional regression models
rowId (integer) Row ID is used to link multiple covariates (x) to a single outcome (y)
covariateId (integer) A numeric identifier of a covariate
covariateValue (real) The value of the specified covariate

Note: If checkSorting is turned off, the outcome table should be sorted by stratumId (if present) and then rowId except for Cox regression when the table should be sorted by stratumId (if present), -time, y, and rowId. The covariate table should be sorted by covariateId, stratumId (if present), rowId except for Cox regression when the table should be sorted by covariateId, stratumId (if present), -time, y, and rowId.

Value

An object of type cyclopsData

Methods (by class)

  • ffdf: Convert data from two ffdf

  • data.frame: Convert data from two data.frame

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#Convert infert dataset to Cyclops format:
covariates <- data.frame(stratumId = rep(infert$stratum, 2),
                         rowId = rep(1:nrow(infert), 2),
                         covariateId = rep(1:2, each = nrow(infert)),
                         covariateValue = c(infert$spontaneous, infert$induced))
outcomes <- data.frame(stratumId = infert$stratum,
                       rowId = 1:nrow(infert),
                       y = infert$case)
#Make sparse:
covariates <- covariates[covariates$covariateValue != 0, ]

#Create Cyclops data object:
cyclopsData <- convertToCyclopsData(outcomes, covariates, modelType = "clr",
                                    addIntercept = FALSE)

#Fit model:
fit <- fitCyclopsModel(cyclopsData, prior = createPrior("none"))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.