Cyclops (version 2.0.2)

convertToCyclopsData: 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

convertToCyclopsData(outcomes, covariates, modelType = "lr",
  addIntercept = TRUE, checkSorting = TRUE, checkRowIds = TRUE,
  normalize = NULL, quiet = FALSE, floatingPoint = 64)

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

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

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.

floatingPoint

Specified floating-point representation size (32 or 64)

Value

An object of type cyclopsData

Methods (by class)

  • ffdf: Convert data from two ffdf

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

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.

Examples

Run this code
# NOT RUN {
#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"))

# }

Run the code above in your browser using DataLab