convertToCyclopsData: Convert data from two data frames or ffdf objects into a...

View source: R/NewDataConversion.R

convertToCyclopsDataR Documentation

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",
  timeEffectMap = NULL,
  addIntercept = TRUE,
  checkSorting = NULL,
  checkRowIds = TRUE,
  normalize = NULL,
  quiet = FALSE,
  floatingPoint = 64
)

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

## S3 method for class 'tbl_dbi'
convertToCyclopsData(
  outcomes,
  covariates,
  modelType = "lr",
  timeEffectMap = NULL,
  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"

timeEffectMap

A data frame or ffdf object containing the convariates that have time-varying effects on the outcome

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)

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

These columns are expected in the timeEffectMap object:

⁠covariateId⁠ (integer) A numeric identifier of the covariates that have time-varying effects on the outcome

Value

An object of type cyclopsData

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)

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


Cyclops documentation built on June 22, 2024, 10:24 a.m.