View source: R/createCovariates.R
createCovariates | R Documentation |
Function to create covariates. Discrete, continuous and/or from an external
file. This function acts as a wrapper for the functions :
createContinuousCovariates
,
createDiscreteCovariates
,
createDiscreteCovariates
and
createTimeVaryingCovariates
createCovariates(
subjects,
conNames = NULL,
conMean,
conCov,
conRange = NULL,
conDigits,
conMaxDraws = 100,
disNames = NULL,
disValues,
disProbs,
disProbArray,
extNames = NULL,
extFile,
extSubset,
extRefCol,
extSameRow = TRUE,
extDataId = idCol,
workingPath = getwd(),
timeNames = NULL,
timeMean,
timeCov,
timeRange = NULL,
timeCol = getEctdColName("Time"),
timePeriod,
idCol = getEctdColName("Subject"),
seed = .deriveFromMasterSeed()
)
subjects |
(Required) Subjects for which to create covariates |
conNames, conMean, conCov, conRange, conDigits, conMaxDraws |
(Optional)
Arguments for the |
disNames, disValues, disProbs, disProbArray |
(Optional) Arguments for the
|
extNames, extFile, extSubset, extRefCol, extSameRow, extDataId |
(Optional)
Arguments for the |
workingPath |
(Optional) Working directory from which to import covariate data. By default, the current working directory is used |
timeNames, timeMean, timeCov, timeRange, timeCol, timePeriod |
(Optional)
Arguments for the |
idCol |
(Optional) Name of the subject column. Must be a valid R name
(See |
seed |
(Optional) Random seed to use by all the lower-level functions. By default, this is derived from the current random seed |
According to the presence of each "names" argument, the function calls
lower-level functions to generate covariates. For example, if
conNames
is given, the function will attempt to generate covariates
from a continuous distribution using the
createContinuousCovariates
function.
If no names is given, a data frame containing only the subject column will be created.
If createTimeVaryingCovariates
is invoked, the additional TIME
column will be included in the output data.
Arguments are systematically passed to lower-level function according to a
name convention. For example, the conRange
argument is passed to
createContinuousCovariates
as the range
argument, the
extFile
is passed to the createExternalCovariates
as
the file
argument, ...
Data frame merging the results from the lower-level functions :
createContinuousCovariates
,
createDiscreteCovariates
,
createExternalCovariates
and
createTimeVaryingCovariates
The function will generate an error if there is any
duplicated names between conNames
, extNames
, disNames
,
timeNames
and idCol
.
Mike K Smith mstoolkit@googlemail.com
createContinuousCovariates
,
createDiscreteCovariates
,
createTimeVaryingCovariates
and
createExternalCovariates
for details about each source of
covariate and examples.
## unit tests for the covariates component of the MSToolkit package
## Not run:
file.show( system.file( "Runit", "runit.data.covariates.R", package = "MSToolkit") )
wPath <- system.file( "Runit", "data", "createCovariates", package = "MSToolkit")
dAll <- createCovariates( 30,
conNames = "X,Y", conMean = "0,0" , conCov = "1,0,1", conRange = "-1<X<1", # continuous
disNames = "P1,P2", disValues = "1,2#3,5,6" , disProbs = ".5,.5#.3,.3,.4", # discrete
extNames = "X1", extFile = "testCovariates.csv", workingPath = wPath ) # external
dAllwithtime <- createCovariates( 30,
conNames = "X,Y", conMean = "0,0" , conCov = "1,0,1", conRange = "-1<X<1", # continuous
disNames = "P1,P2", disValues = "1,2#3,5,6" , disProbs = ".5,.5#.3,.3,.4", # discrete
timeNames = "T1,T2", timeMean = list(1:3, 1:3), timeCov = list(1, 1:3), # time-varying
timePeriod = 1:3, extNames = "X1", extFile = "testCovariates.csv", # external
workingPath = wPath )
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.