This vignette shows how one can correct for the bias in the trial’s effect estimate using the R package mecor. We make use of external validation data. Suppose an endpoint in a trial is measured with error, i.e., the substitute endpoint \(Y^*\) instead of the reference endpoint \(Y\) is observed.
First, we simulate some example data for a trial composed out of two groups. For example, a placebo group (\(X = 0\)) and an active comparator (\(X = 1\)). The number of individuals included in the trial is set to 1000, 500 individuals in each group. Suppose the substitute endpoint \(Y^*\) is observed instead of \(Y\). Further, suppose that an external validation set of sample size 500 is available in which both \(Y^*\) and \(Y\) are measured.
# simulate the trial's data X <- rep(c(0,1), 500) Y <- 2 * X + rnorm(1000, 0, 1) # estimand: 2 # introduce measurement error Y_star <- 1.1 * Y + rnorm(1000, 0, 1) trial <- cbind.data.frame(X = X, Y_star = Y_star) # simulate an external validation data set Y <- rnorm(100, 2, 1) Y_star <- 1.1 * Y + rnorm(500, 0, 1) trial_ext <- cbind.data.frame(Y = Y, Y_star = Y_star)
When the error is ignored, one would estimate the trial’s effect by regressing \(X\) on \(Y^*\).
As you might expect, the trial’s effect estimate does not equal 2, to which value the estimand was set when generating the data. To obtain an unbiased trial effect, measurement error correction is needed. First, we estimate the parameters of the measurement error model using our external validation data:
Then, mecor can be used to correct for the measurement error in the trial’s effect estimate as follows:
Confidence intervals for the corrected estimate can be obtained by using the summary object:
summary(cor_fit, fieller = TRUE, zerovar = TRUE) #> #> Call: #> mecor(formula = MeasErrorExt(substitute = Y_star, model = memod_fit) ~ #> X, data = trial, method = "standard", B = 0) #> #> Coefficients Corrected Model: #> Estimate SE SE (zerovar) #> (Intercept) 0.193191 0.100126 0.054796 #> X 1.827552 0.105154 0.077493 #> #> 95% Confidence Intervals: #> Estimate LCI UCI LCI (zerovar) UCI (zerovar) #> (Intercept) 0.193191 -0.003053 0.389435 0.085793 0.300589 #> X 1.827552 1.621454 2.033649 1.675667 1.979436 #> LCI (fieller) UCI (fieller) #> (Intercept) NA NA #> X 1.631252 2.045218 #> #> The measurement error is corrected for by application of method of moments #> #> Coefficients Uncorrected Model: #> Estimate Std. Error t value Pr(>|t|) #> (Intercept) 0.0041228 0.0643255 0.0641 0.9489 #> X 2.1453759 0.0909700 23.5833 <2e-16 #> #> 95% Confidence Intervals: #> Estimate LCI UCI #> (Intercept) 0.004123 -0.122106 0.130352 #> X 2.145376 1.966861 2.323890 #> #> Residual standard error: 1.438363 on 998 degrees of freedom
When there is no external validation data available. One could conduct a sensitivity analysis by making informed guesses about the parameters values of the measurement error model. Suppose e.g. we guess the following measurement error model: \(Y^* = 1.1 Y\). The following code can be used to quantify the impact of the measurement error would be on the trial’s effect estimate:
sens_fit <- mecor(MeasErrorExt(substitute = Y_star, model = list(coef = c(0, 1.1))) ~ X, data = trial, method = "standard" ) sens_fit #> #> Call: #> mecor(formula = MeasErrorExt(substitute = Y_star, model = list(coef = c(0, #> 1.1))) ~ X, data = trial, method = "standard") #> #> Coefficients Corrected Model: #> (Intercept) X #> 0.003747996 1.950341740 #> #> Coefficients Uncorrected Model: #> (Intercept) X #> 0.004122795 2.145375914