Add covariate to model object
addCovariate.Rd
Add a continuous, categorical, or occasion covariate to model object and set covariate effect on structural parameters.
Usage
addCovariate(
.Object,
covariate,
effect = NULL,
type = c("Continuous", "Categorical", "Occasion"),
direction = c("Forward", "Interpolate", "Backward"),
option = c("Yes", "PlusOne", "No"),
center = NULL,
centerValue = NULL,
levels = NULL,
labels = NULL,
isDiagonal = TRUE,
values = NULL,
isPositive = TRUE
)
Arguments
- .Object
Model object
- covariate
Name of covariate. If the involved model has columns mapped (i.e. model with
columnMap = TRUE
) use named character if the name of the covariate is different from the corresponding column in the input dataset, for example,covariate = c(BW = "BodyWeight")
, whereBW
denotes the name of the covariate, and"BodyWeight"
is the name of the corresponding column in the input dataset.- effect
Name of structural parameter(s) on which the covariate has an effect. Specify
effect
as character or character vector if the covariate has an effect on multiple structural parameters.- type
Type of covariate. Options are
"Continuous"
,"Categorical"
,"Occasion"
.- direction
Direction of missing values propagation (if no covariate value is given). Options are
"Forward"
,"Interpolate"
,"Backward"
, where"Interpolate"
is only applicable totype = "Continuous"
.- option
Options are
"Yes"
,"PlusOne"
, or"No"
, whereoption = "No"
will remove the covariate effect from the specified structural parameter(s), but retain the covariate in the model. Note:option = "PlusOne"
is only applicable to continuous and categorical covariates in the case where structural parameters havestyle = "LogNormal"
. Multiple options are not supported (i.e. all covariate effects in the call are supposed to have the sameoption
. If differentoption
s are required for different covariate effects, sequential calls of current method could be done.- center
Centering method. Options are
"Mean"
,"Median"
,"Value"
or"None"
. Only applicable to covariatetype = "Continuous"
. Must include argumentcenterValue
ifcenter = "Value"
.- centerValue
Value used to center covariate. Only applicable if argument
center = "Value"
andtype = "Continuous"
.- levels
Unique values of categorical or occasion covariate. Only applicable to covariate
type = "Categorical"
ortype = "Occasion"
.- labels
Label names (in the same order as levels) for unique levels of categorical or occasion covariate in data. Only applicable to covariate
type = "Categorical"
ortype = "Occasion"
where its corresponding column in the input dataset has character type.- isDiagonal
Set to
FALSE
if inter-occasion covariance matrix is not diagonal matrix. Only applicable to covariatetype = "Occasion"
.- values
Initial values for the diagonal elements of the inter-occasion covariance matrix (if
isDiagonal = TRUE
) or initial values for the lower triangular elements (including diagonal elements) of inter-occasion covariance matrix (ifisDiagonal = FALSE
) in a row-wise order. Only applicable for covariatetype = "Occasion"
.- isPositive
Set to
FALSE
if covariate contains negative values. Only applicable to covariatetype = "Continuous"
.
Details
The following relationships are applicable for covariates:
direction = "Forward"
is equivalent to PML code 'fcovariate(CovName)';direction = "Backward"
is equivalent to PML code 'covariate(CovName)';direction = "Interpolate"
is equivalent to PML code 'interpolate(CovName)'.If the structural parameter has
style = "LogNormal"
, the options are reflected in PML code as follows:option = "Yes"
is equivalent tostparm(V = tvV * wt^dVdwt * exp(dVdsex1*(sex==1)) * exp(nV))
;option = "PlusOne
is equivalent tostparm(V = tvV * (1+wt*dVdwt) * (1+dVdsex1*(sex==1)) * exp(nV))
.
Examples
model <- pkmodel(
numCompartments = 2,
data = pkData,
ID = "Subject",
Time = "Act_Time",
A1 = "Amount",
CObs = "Conc"
)
# Add Gender covariate of type categorical
model <- addCovariate(model,
covariate = "Gender",
type = "Categorical",
effect = c("V2", "Cl2"),
levels = c(0, 1),
labels = c("Female", "Male")
)
# Add BodyWeight covariate of type continuous
model <- addCovariate(model,
covariate = "BodyWeight",
type = "Continuous",
direction = "Backward",
center = "Mean",
effect = c("V", "Cl")
)