BLS: Bivariate Least Square regression (BLS)

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/BLS.R

Description

Estimate the (homoscedastic) Bivariate Least Square regression with unreplicated or replicated data (in a (X,Y) plot).

Usage

1
2
3
BLS(data = NULL, xcol = 1, ycol = 2, var.x = NULL, var.y = NULL,
    df.var.x = Inf, df.var.y = Inf, ratio.var = NULL, conf.level = 0.95,
    pred.level = 0.95, npoints = 1000, qx = 1, qy = 1, xpred = NULL)

Arguments

data

a data set (data frame or matrix).

xcol

a numeric vector to specify the X column(s) or a character vector with the column names.

ycol

a numeric vector to specify the Y column(s) or a character vector with the column names.

var.x

a numeric variable for the variance of the measurement error of device X if known.

var.y

a numeric variable for the variance of the measurement error of device Y if known.

df.var.x

a numeric variable for the degrees of freedom of the variance of the measurement error of device X if known.

df.var.y

a numeric variable for the degrees of freedom of the variance of the measurement error of device Y if known.

ratio.var

a numeric value for λ, the ratio of the measurement error variances (Y over X) if known.

conf.level

a numeric value for the confidence level (expressed between 0 and 1).

pred.level

a numeric value for the predictive level (expressed between 0 and 1).

npoints

an integer (at least 10) for the number of points to smooth the hyperbolic curves.

qx

an integer to predict the mean of qy Y future values from the mean of qx X values (generalized interval).

qy

an integer to predict the mean of qy Y future values from the mean of qx X values (generalized interval).

xpred

a numeric vector for customized predictions at given X values.

Details

The data argument is mandatory. If the data are unreplicated, then the measurement error variances must be given or their ratio (λ). The confidence level is used for the confidence intervals of the parameters (λ_{XY}, β (slope), α (intercept)), the hyperbolic confidence intervals (the prediction of the expectation of Y for a given X) and the hyperbolic confidence bands. The predictive level is used for the hyperbolic predictive intervals (the prediction of a future Y for a given X) and the hyperbolic generalized intervals (the prediction of the mean of qy future Y values from a given (mean of) X).
The results (Xij, Yik, Xi, Yi, nxi, nyi, variances_x, variances_y) are reordered according to the increasing values of Xi (the X mean values).

Value

A BLS class object, a list including the following elements:

Xij

a table with the (replicated) X measurements (replicates are in columns).

Yik

a table with the (replicated) Y measurements (replicates are in columns).

Xi

a vector with the means of the X measurements.

Yi

a vector with the means of the Y measurements.

nxi

a vector with the number of X replicates per sample (patient).

nyi

a vector with the number of Y replicates per sample (patient).

variances_x

a vector with the variances calculated on the X replicates per sample (patient).

variances_y

a vector with the variances calculated on the Y replicates per sample (patient).

Lambda.XY

a table with the value of λXY and its confidence interval.

Ellipse.BLS

a two columns matrix with the coordinates of the joint confidence interval (confidence region, ellipse) for the parameters (β, α).

Estimate.BLS

a table (data frame) with the estimates of the intercept and the slope, standard error, confidence interval and pvalue (null hypothesis: slope = 1, intercept = 0).

Pred.BLS

a data frame with npoints rows (from the minimum to the maximum of the observed X values) and the following columns: the X values where the predictions are calculated (X0), the Y predicted values (Ypred), the lower and upper bounds of the confidence intervals, predictive intervals, generalized intervals and confidence bands.

xpred.BLS

a data frame with the customized predictions and the same columns than Pred.BLS.

Author(s)

Bernard G FRANCQ

References

Francq BG, Govaerts BB. How to regress and predict in a Bland-Altman plot? Review and contribution based on tolerance intervals and correlated-errors-in-variables models. Statistics in Medicine, 2016; 35:2328-2358.
Francq BG, Govaerts BB. Measurement methods comparison with errors-in-variables regressions. From horizontal to vertical OLS regression, review and new perspectives. Chemometrics and Intelligent Laboratory Systems, 2014; 134:123-139.
Francq BG, Govaerts BB. Hyperbolic confidence bands of errors-in-variables regression lines applied to method comparison studies. Journal de la Societe Francaise de Statistique 2014; 155(1):23-45.

See Also

CBLS, BLS.fit, BLS.ht

Examples

1
2
3
4
5
6
library(BivRegBLS)
data(SBP)
# BLS regression on replicated data
res.BLS1=BLS(data=SBP,xcol=c("J1","J2","J3"),ycol=8:10,qx=3,qy=3,xpred=c(100,120,140,160))
# BLS regression on unreplicated data with measurement error variances previously estimated
res.BLS2=BLS(data=SBP,xcol=c("J1"),ycol="S1",var.x=80,var.y=50,df.var.x=100,df.var.y=100)

Example output

Loading required package: ellipse

Attaching package:ellipseThe following object is masked frompackage:graphics:

    pairs

BivRegBLS documentation built on Oct. 11, 2019, 1:05 a.m.