The goal of ppwdeming is to provide functions for weighted Deming regression, using weights modeled via precision profile (used commonly in the realm of clinical chemistry). Functions are included for implementing weights in situations of known and unknown precision profile settings.
Source code may be reviewed on GitHub.
You can install the development version of ppwdeming
like so:
install.packages("ppwdeming") # once available on CRAN
This is a basic example which shows you how to run the main functions:
# library
library(ppwdeming)
# parameter specifications
<- 1
sigma <- 0.08
kappa <- 1
alpha <- 1.1
beta <- 8*10^((0:99)/99)
true <- alpha+beta*true
truey # simulate single sample - set seed for reproducibility
set.seed(1039)
# specifications for predicate method
<- sigma*rnorm(100)+true *(1+kappa*rnorm(100))
X # specifications for test method
<- sigma*rnorm(100)+truey*(1+kappa*rnorm(100))
Y
# fit RL with given sigma and kappa
<- PWD_RL(X,Y,sigma,kappa)
RL_results cat("\nWith given sigma and kappa, the estimated intercept is",
signif(RL_results$alpha,4), "and the estimated slope is",
signif(RL_results$beta,4), "\n")
# fit with RL precision profile to estimate parameters
<- PWD_get_gh(X,Y,printem=TRUE)
RL_gh_fit # RL precision profile estimated parameters
cat("\nsigmahat=", signif(RL_gh_fit$sigma,6),
"and kappahat=", signif(RL_gh_fit$kappa,6))
# run the residual analysis from the model output
<- PWD_resi(X, RL_gh_fit$resi, printem=TRUE)
post
# fit with RL precision profile to estimate parameters and variability
<- PWD_inference(X,Y,MDL=12,printem=TRUE) RL_inf
along with the outlier review:
# add some outliers
c(1,2,100)] <- Y[c(1,2,100)] + c(7,4,-45)
Y[
# check for outliers, re-fit, and store output
<- PWD_outlier(X,Y,K=5) outliers_assess
An alternative example in which the precision profiles are known:
# parameter specifications
<- 1
alpha <- 1.1
beta <- 8*10^((0:99)/99)
true <- alpha+beta*true
truey # forms of precision profiles
<- function(true, gparms) {
gfun = gparms[1]+gparms[2]*true^gparms[3]
gvals
gvals
}<- function(true, hparms) {
hfun = hparms[1]+hparms[2]*true^hparms[3]
hvals
hvals
}
# Loosely motivated by Vitamin D data set
<- 4e-16+0.07*true^1.27
g <- 6e-2+7e-5*truey^2.2
h # simulate single sample - set seed for reproducibility
set.seed(1039)
# specifications for predicate method
<- true +sqrt(g)*rnorm(100)
X # specifications for test method
<- truey+sqrt(h)*rnorm(100)
Y
# fit with to estimate linear parameters
<- PWD_known(X, Y, gfun, hfun,
pwd_known_fit c(4e-16, 0.07, 1.27), c(6e-2, 7e-5, 2.2))