Type: | Package |
Title: | Statistical Methods for Designing and Analyzing a Calibration Study |
Version: | 1.0 |
Date: | 2017-09-01 |
Author: | Ramon Durazo-Arvizu, Chris Sempos, and Lu Tian |
Maintainer: | Lu Tian <lutian@stanford.edu> |
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>. |
License: | GPL-2 | GPL-3 [expanded from: GPL] |
NeedsCompilation: | no |
Packaged: | 2017-09-05 18:12:29 UTC; lutian |
Repository: | CRAN |
Date/Publication: | 2017-09-05 18:19:47 UTC |
Statistical Methods for Designing and Analyzing a Calibration Study
Description
Implements statistical methods for designing and analyzing a calibration study
Details
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.
Author(s)
Ramon Durazo-Arvizu, Chris Sempos, and Lu Tian
References
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
Estimating the Calibration Equation
Description
Estimates the calibration equation based on CV information
Usage
calfun(x, y, CVx, CVy = CVx, lambda0 = 1)
Arguments
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 |
Details
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.
Value
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 |
Author(s)
Durazo-Arvizu, Ramon; Sempos, Chris; Tian, Lu
References
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
Examples
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
Piecewise Regression Estimation
Description
Estimate a piecewise linear regression equation
Usage
chngpt(x, y, start = quantile(x, probs = 0.1,
na.rm = "TRUE"),finish = quantile(x, probs = 0.9, na.rm = "TRUE"),
NbrSteps = 500)
Arguments
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 |
Details
This function uses grid search method to fit a piecewise linear regression model with one changing point
Value
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 |
Author(s)
Durazo-Arvizu, Ramon and Sempos, Chris
References
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
Examples
### 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)
Uniformly Sampling
Description
Draws samples uniformly (for internal use only)
Usage
samplefun(x, index, n0)
Arguments
x |
The VD values |
index |
the index for VD value, it can be 1, 2, 3,.... |
n0 |
Sample size |
Details
Uniform sampling (internal use only)
Value
index |
selected ids |
x |
selected VD levels |
Author(s)
Durazo-Arvizu, Ramon, Sempos, Chris and Tian, Lu
See Also
Examples
x=rnorm(100)
index=1:100
samplefun(x, index, 40)
Uniform Sampling Within Quartiles
Description
Estimates the sample size to achived the specified precision in the estimated calibration equation.
Usage
samplesize(x0, d0, cutpts = c(7.5, 42.5, 57.5, 72.5, 200), CVx, CVy)
Arguments
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%) |
Details
The function estimates the sample size to achived the specified precision in the estimated calibration equation. The precision is defined via x0 and d0
Value
Required sample size to achived the specified precision in the estimated calibration equation.
Author(s)
Durazo-Arvizu, Ramon, Sempos, Chris and Tian, Lu
References
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
Examples
samplesize(30, 5, cutpts=c(7,42,57,72,200),0.12, 0.05)
Samples Selection
Description
Selects samples used in a calibration study
Usage
sampletot(x, index, n0, K)
Arguments
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) |
Details
The function selectes samples used in the calibration study
Value
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 |
Author(s)
Durazo-Arvizu, Ramon, Sempos, Chris and Tian, Lu
References
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
Examples
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)