R/NewDataConversion.R
convertToCyclopsData.Rd
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
)
A data frame or ffdf object containing the outcomes with predefined columns (see below).
A data frame or ffdf object containing the covariates with predefined columns (see below).
Cyclops model type. Current supported types are "pr", "cpr", lr", "clr", or "cox"
Add an intercept to the model?
(DEPRECATED) Check if the data are sorted appropriately, and if not, sort.
Check if all rowIds in the covariates appear in the outcomes.
String: Name of normalization for all non-indicator covariates (possible values: stdev, max, median)
If true, (warning) messages are suppressed.
Specified floating-point representation size (32 or 64)
An object of type cyclopsData
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 |
convertToCyclopsData(data.frame)
: Convert data from two data.frame
convertToCyclopsData(tbl_dbi)
: Convert data from two Andromeda
tables
#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"))