Title: | Statistical Methods for Designing and Analyzing a Calibration Study |
---|---|
Description: | Provides statistical methods for the design and analysis of a calibration study, which aims for calibrating measurements using two different methods. The package includes sample size calculation, sample selection, regression analysis with error-in measurements and change-point regression. The method is described in Tian, Durazo-Arvizu, Myers, et al. (2014) <DOI:10.1002/sim.6235>. |
Authors: | Ramon Durazo-Arvizu, Chris Sempos, and Lu Tian |
Maintainer: | Lu Tian <[email protected]> |
License: | GPL |
Version: | 1.0 |
Built: | 2024-11-16 06:39:37 UTC |
Source: | CRAN |
Implements statistical methods for designing and analyzing a calibration study
Implements statistical methods for design and analysis of a calibration study. The important functions are "samplesize": for sample size estimation; "sampletot": for sample selection, "calfun": for estimating calibrating equation and "chngpt": for estimating the piece-wise linear equation.
Ramon Durazo-Arvizu, Chris Sempos, and Lu Tian
Tian L., Durazo-Arvizu R. A., Myers G., Brooks S., Sarafin K., and Sempos C. T. (2014), The estimation of calibration equations for variables with heteroscedastic measurement errors, Statist. Med., 33, pages 4420-4436
Estimates the calibration equation based on CV information
calfun(x, y, CVx, CVy = CVx, lambda0 = 1)
calfun(x, y, CVx, CVy = CVx, lambda0 = 1)
x |
old VD measurements |
y |
reference (new) VD measurements |
CVx |
CV% of the old VD measurements |
CVy |
CV% of the new VD measurements |
lambda0 |
the CV ratio of the new vs old measurements |
Estimation of the calibration equation. It covers 4 scenarios: Only CVx is known; only CVy is known; both CVx and CVy are known; and Only the ratio of CVy to CVx is known.
coef |
estimated coefficients of the linear function |
se |
standard errors of the estimated coefficients |
lower CI |
the lower end of the 95% CI of the regression coefficients |
upper CI |
the upper end of the 95% CI of the regression coefficients |
Durazo-Arvizu, Ramon; Sempos, Chris; Tian, Lu
Tian L., Durazo-Arvizu R. A., Myers G., Brooks S., Sarafin K., and Sempos C. T. (2014), The estimation of calibration equations for variables with heteroscedastic measurement errors, Statist. Med., 33, pages 4420-4436
n=100 sigma0=10 beta0=5 beta1=1.2 CVx=0.15 CVy=0.07 lambda0=CVy^2/CVx^2 x0=runif(n, 20, 200) y0=beta0+beta1*x0+rnorm(n)*sigma0 x=x0+x0*CVx*rnorm(n) y=y0+y0*CVy*rnorm(n) fit=calfun(x, y, CVx, CVy, lambda0) fit
n=100 sigma0=10 beta0=5 beta1=1.2 CVx=0.15 CVy=0.07 lambda0=CVy^2/CVx^2 x0=runif(n, 20, 200) y0=beta0+beta1*x0+rnorm(n)*sigma0 x=x0+x0*CVx*rnorm(n) y=y0+y0*CVy*rnorm(n) fit=calfun(x, y, CVx, CVy, lambda0) fit
Estimate a piecewise linear regression equation
chngpt(x, y, start = quantile(x, probs = 0.1, na.rm = "TRUE"),finish = quantile(x, probs = 0.9, na.rm = "TRUE"), NbrSteps = 500)
chngpt(x, y, start = quantile(x, probs = 0.1, na.rm = "TRUE"),finish = quantile(x, probs = 0.9, na.rm = "TRUE"), NbrSteps = 500)
x |
old VD measurements |
y |
reference (new) VD measurements |
start |
lower bound of the changing point |
finish |
upper bound of the changing point |
NbrSteps |
number of points used in grid search |
This function uses grid search method to fit a piecewise linear regression model with one changing point
x |
old VD levels |
y |
new VD levels |
yfitted |
calibrated VD levels based on the fitted piecewise linear regression |
chngpt |
the estimated chang point |
coefficients |
the estimated regression coefficients for the piecewise linear regression |
Durazo-Arvizu, Ramon and Sempos, Chris
Tian L., Durazo-Arvizu R. A., Myers G., Brooks S., Sarafin K., and Sempos C. T. (2014), The estimation of calibration equations for variables with heteroscedastic measurement errors, Statist. Med., 33, pages 4420-4436
### Generate equally spaced TEST VALUES in the interval [20,200] set.seed(123456789) x= 20 + 180*1:100/100 x2= (x - 95)*(x>=95) # Generate REFERENCE VALUES y = -8 + 1.5*x - 0.85*x2 + 15*rnorm(100) #Plot test values versus reference values along with fitted piecewise model plot(x,y) fit.chngpt = chngpt(x,y) plot(fit.chngpt$x[order(fit.chngpt$yfitted)], fit.chngpt$y[order(fit.chngpt$yfitted)], xlim=c(0,200), ylim=c(0,200), xlab="25-Hydroxyvitamin D (nmol/mL), IDS", ylab="25-Hydroxyvitamin D (nmol/mL), LC/MS", bty="n", las=1) lines(fit.chngpt$x[order(fit.chngpt$yfitted)], fit.chngpt$yfitted[order(fit.chngpt$yfitted)], lty=2,col=2, lwd=2) abline(v=fit.chngpt$chngpt, lty=2,col=3, lwd=2) arrows(fit.chngpt$chngpt+20 ,15, fit.chngpt$chngpt,-8, length=0.1, lwd=2, col=4) legend(fit.chngpt$chngpt + 5,30, legend=round(fit.chngpt$chngpt, digits=1), bty="n", col=4)
### Generate equally spaced TEST VALUES in the interval [20,200] set.seed(123456789) x= 20 + 180*1:100/100 x2= (x - 95)*(x>=95) # Generate REFERENCE VALUES y = -8 + 1.5*x - 0.85*x2 + 15*rnorm(100) #Plot test values versus reference values along with fitted piecewise model plot(x,y) fit.chngpt = chngpt(x,y) plot(fit.chngpt$x[order(fit.chngpt$yfitted)], fit.chngpt$y[order(fit.chngpt$yfitted)], xlim=c(0,200), ylim=c(0,200), xlab="25-Hydroxyvitamin D (nmol/mL), IDS", ylab="25-Hydroxyvitamin D (nmol/mL), LC/MS", bty="n", las=1) lines(fit.chngpt$x[order(fit.chngpt$yfitted)], fit.chngpt$yfitted[order(fit.chngpt$yfitted)], lty=2,col=2, lwd=2) abline(v=fit.chngpt$chngpt, lty=2,col=3, lwd=2) arrows(fit.chngpt$chngpt+20 ,15, fit.chngpt$chngpt,-8, length=0.1, lwd=2, col=4) legend(fit.chngpt$chngpt + 5,30, legend=round(fit.chngpt$chngpt, digits=1), bty="n", col=4)
Draws samples uniformly (for internal use only)
samplefun(x, index, n0)
samplefun(x, index, n0)
x |
The VD values |
index |
the index for VD value, it can be 1, 2, 3,.... |
n0 |
Sample size |
Uniform sampling (internal use only)
index |
selected ids |
x |
selected VD levels |
Durazo-Arvizu, Ramon, Sempos, Chris and Tian, Lu
x=rnorm(100) index=1:100 samplefun(x, index, 40)
x=rnorm(100) index=1:100 samplefun(x, index, 40)
Estimates the sample size to achived the specified precision in the estimated calibration equation.
samplesize(x0, d0, cutpts = c(7.5, 42.5, 57.5, 72.5, 200), CVx, CVy)
samplesize(x0, d0, cutpts = c(7.5, 42.5, 57.5, 72.5, 200), CVx, CVy)
x0 |
The value at which calibration will be esitmated (e.g., 30 nmol/L) |
d0 |
Targeted width of the 95% confidence interval of the calibrated value (e.g. 5nmol/L) |
cutpts |
Cut points used to define intervals, within which samples would be selected uniformly |
CVx |
CV% of the old method (e.g. 12%) |
CVy |
CV% of the reference (new) method (e.g. 5%) |
The function estimates the sample size to achived the specified precision in the estimated calibration equation. The precision is defined via x0 and d0
Required sample size to achived the specified precision in the estimated calibration equation.
Durazo-Arvizu, Ramon, Sempos, Chris and Tian, Lu
Tian L., Durazo-Arvizu R. A., Myers G., Brooks S., Sarafin K., and Sempos C. T. (2014), The estimation of calibration equations for variables with heteroscedastic measurement errors, Statist. Med., 33, pages 4420-4436
samplesize(30, 5, cutpts=c(7,42,57,72,200),0.12, 0.05)
samplesize(30, 5, cutpts=c(7,42,57,72,200),0.12, 0.05)
Selects samples used in a calibration study
sampletot(x, index, n0, K)
sampletot(x, index, n0, K)
x |
the old sample measurements needing calibration |
index |
the ID list of the old sample measurements needing calibration |
n0 |
the required sample size |
K |
the number of quantiles, it is 4 if we use quartiles (recommended) |
The function selectes samples used in the calibration study
x |
the selected sample measurements to be used in the calibration study |
index |
the id list of the selected samples to be used in the calibration study |
Durazo-Arvizu, Ramon, Sempos, Chris and Tian, Lu
Tian L., Durazo-Arvizu R. A., Myers G., Brooks S., Sarafin K., and Sempos C. T. (2014), The estimation of calibration equations for variables with heteroscedastic measurement errors, Statist. Med., 33, pages 4420-4436
VD.value= 60 + 25*rnorm(1000) VD.index=1:1000 ### x: the VD value ### index: the index for VD value, it can be 1, 2, 3,.... ### n0: the number of samples we want to select ### K: the number of quantiles, it is 4 if we use quartiles sampletot(x=VD.value, index=VD.index, n0=100, K=4)
VD.value= 60 + 25*rnorm(1000) VD.index=1:1000 ### x: the VD value ### index: the index for VD value, it can be 1, 2, 3,.... ### n0: the number of samples we want to select ### K: the number of quantiles, it is 4 if we use quartiles sampletot(x=VD.value, index=VD.index, n0=100, K=4)