Simulate dose response data and apply 4- or 3- parameter Emax MLE estimation. For binary data, the model is fit on the logit scale and then back-transformed. When MLE estimation fails, models with fewer parameters (including models linear in their parameters) are substituted. Summaries of estimation performance are returned for further analyses. An MCP-MOD test is also performed for each simulated data set.
emaxsim(
nsim,
genObj,
modType=3,
binary=FALSE,
seed=12357,
nproc = parallel::detectCores(),
negEmax=FALSE,
ed50contr=NULL,
lambdacontr=NULL,
testMods=NULL,
idmax=length(doselev),
iparm=NA,
ed50cutoff=2.5*max(doselev),
ed50lowcutoff=doselev[2]/1000,
switchMod= TRUE,
truncLambda=6,
description="")
A list is returned with class(emaxsim) containing:
User description of simulation
Binary response data.
User supplied starting Emax model
List object with data and function used to generate study data
Matrix with rows containing population parameters for each simulation. Type of parameter depends on constructor function generating study data.
Vector containing the population SD used to generate
continuous data. NULL
for binary data.
Matrix with rows containing the starting Emax parameters for each simulation
Matrix with 4 parmameter Emax fit. NA if failed to converge or modType=3
Matrix with 3 parmameter Emax fit. NA if failed to converge or 4-parameter estimation was successful.
Matrix with alternative parameter estimates. NA if Emax model fit successfully
Variance-covariance matrix for the estimated parameters stored as a vector for each simulation. The vc vector stored has 16,9, or 4 elements depending on fitType (with NA values on the end if elements are unused).
The residual SD based on the selected model.
Character vector with "4", "3", "L", "LL", or "E" for 4-Emax, 3-Emax, linear, log-linear, or exponential when an alternative model is selected.
The nsim
p-values from the global null test. The p-values are
1-sided computed using MCP-Mod.
The index of the test contrast producing the smallest p-value.
Object of class Mods from R package DoseFinding
that defines
the contrasts used in MCP-MOD testing. The functions can be plotted with
DoseFinding
loaded.
User input stored for subsequent reference.
Upper allowed limit for ED50 estimates
Lower allowed limit for the ED50 estimates.
If switchMod is TRUE, the algorithm substitutes a simpler model if (1) convergence is not achieved, (2) the information matrix is not positive definite at the converged values, (3) the ED50 estimates are outside the cutoff bounds. If switchMod is F, only conditions (1) or (2) cause a simpler model to be used.
negC=TRUE if the primary fit (from modType) yielded a ED50 estimate < ED50 lower limit.
bigC=TRUE if the primary fit (from modType) yielded an ED50> ED50 upper limit.
Matrix with population means for each dose group
Matrix with rows containing dose group sample means
Matrix with rows containing dose group sample SD
Matrix with rows containing dose groups means estimated from the model
Matrix with rows containing SE for fitpredv
Matrix with rows containing SE for model-based differences with placebo
Starting random
number seed for each simulated data set set that can be assigned to .Random.seed
.
To reproduce the data, the random number generator must also be changed to
RNGkind("L'Ecuyer-CMRG")
.
Index of default dose group for comparison to placebo (e.g., for plotting Z-statistics).
Number of simulation replications
Object containing inputs and function to create simulated
data sets. These objects are created by special constructor
functions; the current choices are FixedMean
and RandEmax
.
When modType=4, the fitting begins with the 4 parameter model. If estimation fails or modType=3, the 3-parameter estimation is applied. If it fails, a best-fitting model linear in its parameters is selected.
When specified, the Emax model is fit on the logit scale, and then the results are back-transformed to proportions.
Seed for random number generator used to create data.
The number of processors to use in parallel computation of the
simulations, which are divided into equal-sized computational blocks. When nproc=1
a single local processor.
When TRUE
, the intended effect is assumed to be negative.
A vector of ED50 values for creating a global null test using the MCP-MOD package DoseFinding based on Emax model-based contrasts. The default is 3 contrasts: the mid-point between pbo and the lowest dose, the mid-point between the 2 highest doses, and the median of the dose levels. When there are <=4 doses including pbo, the median-based contrast is excluded.
Hill parameters matched to the ed50contr. The default value is 1 for each contrast model.
The model object for a MCP-MOD test
created by Mods
from package DoseFinding
. If
specified, the other contrast inputs are ignored. The Mods
call should
use the unique sorted dose levels. The direction of the trend should be specificed in the call to Mods
. The negEmax
is stored for use by support functions, but it does not determine the direction of the effect when testMods
is specified. The validity of
testMods
is not checked.
Index of the default dose group for comparison to placebo. Most analysis functions allow other dose groups to be specified. The default is the index of the highest dose.
Starting values for the Emax fit. If unspecified, starting values are computed. The order of the variables is (log(ED50),Emax,E0) or (log(ED50),lambda,Emax,E0). Note the transformation of ED50.
The upper limit for the ED50 parameter estimates.The default is large enough to ensure a near linear fit to the data from an Emax model.
Lower allowed limit for the ED50 estimates.
If switchMod is TRUE, the algorithm substitutes a simpler model if (1) convergence is not achieved, (2) the information matrix is not positive definite at the converged values, (3) the ED50 estimates are outside the cutoff bounds. If switchMod is F, only conditions (1) or (2) cause a simpler model to be used.
When modType=4
and the converged estimate of
the Hill parameter lambda exceeds truncLambda
, the model fit
is judged unstable and discarded. Set truncLambda=Inf
for
no truncation. Four parameter model fits are also discarded
when lambda is less than 0.1.
Optional text describing the simulation setting that is stored with the simulation output.
Neal Thomas
Continuous data can be simulated from any dose response curve with homogeneous normally distributed residuals. The estimation procedure starts with ML estimation of a 4- or 3- parameter Emax model depending on modType. If modType=3 or 4-parameter estimation fails, a 3 parameter Emax model is fit by maximum likelihood non-linear least squares. If 1) nls fails to converge for a 3 parameter Emax model, 2) the ED50 estimate is <=0, or 3) the ED50 estimate exceeds ed50cutoff, a linear, log-linear (offset of 1.0), or scaled exponental (exp(dose/max(dose))), is fit using simple linear least squares estimation. The model selected has the smallest residual SS.
Binary data are handled similarly using maximum likelihood implemented with the nlm function. The models are fit on the logit scale and then back-transformed for estimation of dose response. Reduced linear models are selected based on the corresponding likelihood deviance.
MCP-MOD tests are created from contrasts based on the Emax function using
the DoseFinding
package. Different
ED50 and lambda (Hill) parameters can be specified to form the contrasts. A contrast
matrix output from the DoseFinding package can be specified instead, allowing for
other contrast choices.
print.emaxsim
,
summary.emaxsim
, plot.emaxsim
,
coef.emaxsim
, sigma.emaxsim
,
vcov.emaxsim
, predict.emaxsim
,
emaxfun
if (FALSE) {
## emaxsim changes the random number seed
nsim<-50
idmax<-5
doselev<-c(0,5,25,50,100)
n<-c(78,81,81,81,77)
Ndose<-length(doselev)
### population parameters for simulation
e0<-2.465375
ed50<-67.481113
dtarget<-100
diftarget<-2.464592
emax<-solveEmax(diftarget,dtarget,log(ed50),1,e0)
sdy<-7.967897
pop<-c(log(ed50),emax,e0)
meanlev<-emaxfun(doselev,pop)
###FixedMean is specialized constructor function for emaxsim
gen<-FixedMean(n,doselev,meanlev,sdy)
D1 <- emaxsim(nsim,gen,modType=3)
summary(D1,testalph=0.05)
D4 <- emaxsim(nsim,gen,modType=4)
summary(D4,testalph=0.05)
}
# \dontshow{
## emaxsim changes the random number seed
nsim<-2
doselev<-c(0,5,25,50,100)
n<-c(78,81,81,81,77)
Ndose<-length(doselev)
### population parameters for simulation
e0<-2.465375
ed50<-67.481113
dtarget<-100
diftarget<-2.464592
emax<-solveEmax(diftarget,dtarget,log(ed50),1,e0)
sdy<-7.967897
pop<-c(log(ed50),emax,e0)
meanlev<-emaxfun(doselev,pop)
###FixedMean is specialized constructor function for emaxsim
gen<-FixedMean(n,doselev,meanlev,sdy)
D1 <- emaxsim(nsim,gen,modType=3,nproc=1)
# }
Run the code above in your browser using DataLab