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

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

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

# S3 method for tbl_dbi
convertToCyclopsData(
  outcomes,
  covariates,
  modelType = "lr",
  addIntercept = TRUE,
  checkSorting = NULL,
  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

(DEPRECATED) 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 suppressed.

floatingPoint

Specified floating-point representation size (32 or 64)

Value

An object of type cyclopsData

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)
weights(real)(optional) Non-negative weights to apply to outcome
censorWeights(real)(optional) Non-negative censoring weights for competing risk model; will be computed if not provided.

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

Methods (by class)

  • convertToCyclopsData(data.frame): Convert data from two data.frame

  • convertToCyclopsData(tbl_dbi): Convert data from two Andromeda tables

Examples

#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)
#> Sorting outcomes by stratumId and rowId
#> Sorting covariates by covariateId, stratumId, and rowId

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