Package 'malp'

Title: Maximum Agreement Linear Prediction
Description: Provides tools for estimation and prediction using Maximum Agreement Linear Predictors (MALPs). MALPs provide an alternative to least squares linear predictors when agreement between predicted and observed values, as measured by Lin's Concordance Correlation Coefficient (CCC), is of primary interest. Applications include missing value imputation and calibration studies. The package includes functions for model estimation, prediction, statistical inference, cross-validation, and model diagnostics. The implemented methodology is described in Kim et al. (2026) <doi:10.1214/26-EJS2550>.
Authors: Pierre Chausse [aut, cre], Taeho Kim [aut], Edsel A. Pena [aut], George Luta [ctb]
Maintainer: Pierre Chausse <[email protected]>
License: GPL (>= 2)
Version: 1.2
Built: 2026-11-05 19:13:09 UTC
Source: https://codeberg.org/pchausse/malp

Help Index


Data on body fat

Description

Lists estimates of the percentage of body fat determined by underwater weighing and various body circumference measurements for 252 men.

Usage

data("bodyFat")

Format

A data frame with 252 observations on the following 15 variables.

BD

Density determined from underwater weighing

PBF

Percent body fat from Siri's (1956) equation

Age

Age (years)

WGT

Weight (lbs)

HGT

Height (inches)

NCK

Neck circumference (cm)

CST

Chest circumference (cm)

ABD

Abdomen 2 circumference (cm)

Hip

Hip circumference (cm)

TGH

Thigh circumference (cm)

KN

Knee circumference (cm)

ANK

Ankle circumference (cm)

BCP

Biceps (extended) circumference (cm)

FA

Forearm circumference (cm)

WRT

Wrist circumference (cm)

Source

Statlib.

https://lib.stat.cmu.edu/datasets/bodyfat


Concordance correlation coefficient

Description

This is a measure of agreement, which evaluates how close the linear relationship between two random variables is from the 45 degree line.

Usage

ccc(x, y, type="Lin")

Arguments

x

A vector of observations.

y

A vector of observations with the same length as x

type

The type of coefficient. The only option for now is the coefficient introduced by Lin (1989)

Value

A numeric vector of length 1.

References

Lin, L. (1989). A concordance correlation coefficient to evaluate reproducibility. Biometrics, 45, 255–268.

Examples

## High concordance: almost y=x
set.seed(112233)
x <- rnorm(100)
u <- rnorm(100, sd=0.1)
y1 <- x + u
ccc(x,y1)

## Lower concordance: almost y=1+x
y2 <- 1+x+u
ccc(x,y2)

## But same Pearson correlation
cor(x,y2)

Data on Optical Coherence Tomography (OCT)

Description

Eye measurements used in Abedi et al. (2011). The original dataset contains two type of measurement for 46 individuals (1 measurement per eye). The data is then filtered to include only observations for which the signal strength is greater or equal to 6 for both measurement methods.

Usage

data("eye")

Format

A data frame with 56 observations on the following 3 variables.

Eye

OD for right eye and OS for left eye.

Stratus

time-domain Stratus OCT.

Cirrus

spectral-domain Cirrus OCT

References

Abedi, G. and Patal, P. and Doros, G. and Subramanian, M.L. (2011). Transitioning from stratus OCT to cirrus OCT: a comparison and a proposed equation to convert central subfield macular thickness measurements in healthy subjects. Graefe's Archive for Clinical and Experimental Ophthalmology, 249, 1353–1357.


Missing value imputation using MALP

Description

It imputes the missing values of a dependent variable in a linear model using the maximum agreement linear predictor. To compare its performence, some alternative methods of imputation are also included in the function.

Usage

impute(formula, data, type = c("MALP", "LSLP", "Mean", "SReg"))

Arguments

formula

A formula for the linear model

data

A data.frame containing all variables included in the formula

type

The imputation method. The default is based on the maximum agreement predictor, "LSLP" is based on least squares predictor, "Mean" replaces all missing values by the sample mean of the non-missing ones, and "SRef" is based on a stochastic regression in which a random number from a normal distribution with the same variance as the least squares residuals is added to the least squares predictor.

Details

The main purpose of this function is to implement the MALP imputation method, not to implement all methods that exist in the literature. A few alternative methods are included for illustration.

Since this method is based on a linear model, only the missing dependent variables associated with the non missing regressors are imputed. This is also true for the method type="Mean", even if it allows all missing values to be imputed.

Value

impute returns an object of class "impute" which inherits from class "data.frame". All specifications associated with the imputation are stored in the attribute "imputeSpec". This attribute is a list with the following elements:

imputed

The observation numbers that have been imputed.

missing

All observation numbers missing from the dependent variable. It may differ from imputed if some regressors associated with missing dependent variable observations are also missing.

imputedName

The name of the dependent variable.

type

The imputation method.

allMiss

All observation numbers that contain at least one missing variable.

corr

A list with the elements observed and imputed. They are the correlation between the least squares fitted values and the dependent variable before and after the imputation.

The print method for this object prints the imputation method used, the number of missing values and the number of imputed observations.

References

Kim, T. & Chausse, P & Matteo Bottai & Doros, G. & Giurcanu, M. & Luta, G. & Pena, E.A. (2026). “Maximum Agreement Linear Predictors.” Electronic Journal of Statistics, 20(2), 2892–2942. doi:10.1214/26-EJS2550

van Buuren S (2018). Flexible imputation of missing data. CRC press.

Examples

obj <- impute(Ozone~Solar.R, airquality)
obj

## Regression with the imputed data
## The object inherits from class data.frame

lm(Ozone~Solar.R, obj)

## Trying to impute a data set
## with no missing values that can be imputed

impute(Ozone~Solar.R, obj)

K-fold cross-validation for Maximum Agreement Linear Predictor

Description

It returns some goodness of fit measures using the k-fold cross-validation method.

Usage

kFoldMalp(obj, k=5, repeated=1)

Arguments

obj

An object of class "malp"

k

The number of folds.

repeated

The number of times the k-fold method is repeated. If it is greater than 1, the function returns the average accuracy measures.

Value

A numeric named vector with three goodness of fit measures: the Pearson correlation (PCC) and the concordance correlation (CCC) coefficients between the predictions and observed observations, and the mean squared error (MSE).

References

Kim, T. & Chausse, P & Matteo Bottai & Doros, G. & Giurcanu, M. & Luta, G. & Pena, E.A. (2026). “Maximum Agreement Linear Predictors.” Electronic Journal of Statistics, 20(2), 2892–2942. doi:10.1214/26-EJS2550

Examples

## Stratus VS Cirrus OCT (optimal coherence tomography)

# Left eye
data(eye)
fitL <- malp(Stratus~Cirrus, data=subset(eye, Eye=="OS"))
kFoldMalp(fitL)

# Right eye
fitR <- malp(Stratus~Cirrus, data=subset(eye, Eye=="OD"))
kFoldMalp(fitR)

Maximum Agreement Linear Predictor

Description

This is the main function to estimate the maximum agreement linear predictor. Instead of estimating the predictor directly, as in Kim et al. (2026), the coefficients are estimated like linear models fitted by lm and saved in the "malp" object created by this function.

Usage

malp(formula, data, obj=TRUE)

Arguments

formula

A formula for the linear model

data

A data.frame containing all variables included in the formula

obj

If set to FALSE, the function only returns the coefficients. It saves a little bit of time for large models if all we need is the coefficients (e.g. in simulation studies).

Value

malp returns an object of class "malp", with the following components:

coefficients

Coefficient estimates.

gamma

Correlation between the dependent variable and the least squares fitted values.

lm

Least squares object fitted by lm.

varY

Estimated variance of the dependent variable.

muY

Sample mean of the dependent variable.

call

The original function call.

data

The data set used for the estimation. The missing values are therefore omitted.

na.action

A vector indicating the rows that were omitted from the dataset due to missing values. It is NULL if the dataset does not contain missing values.

The print method for this object is like the method for objects of class "lm". It prints the call and coefficient estimates.

References

Kim, T. & Chausse, P & Matteo Bottai & Doros, G. & Giurcanu, M. & Luta, G. & Pena, E.A. (2026). “Maximum Agreement Linear Predictors.” Electronic Journal of Statistics, 20(2), 2892–2942. doi:10.1214/26-EJS2550

Examples

## Stratus VS Cirrus OCT (optimal coherence tomography)

# Left eye
data(eye)
fitL <- malp(Stratus~Cirrus, data=subset(eye, Eye=="OS"))
fitL
# Right eye
fitR <- malp(Stratus~Cirrus, data=subset(eye, Eye=="OD"))
fitR

## Body fat

data(bodyFat)
fit <- malp(PBF~ABD+WGT+FA+WRT+Age+TGH+NCK+Hip, bodyFat)
fit

Plot methods for objects of class "malp" and "impute"

Description

For objects of class "malp", the function plots the dependent variable against the fitted values from the maximum agreement method. The purpose is to compare the fit with the 45 degree line representing the absolute agreement. For objects of class "impute", it plots the histogram of the dependent variable with and without the imputed observations to compare their distributions.

Usage

## S3 method for class 'malp'
plot(x, y=NULL, which=c("MALP", "LSLP", "Both"),
                       pch=21:22, col=2:3, bg=2:3, ...)
## S3 method for class 'impute'
plot(x, y = NULL, title = NULL, xlab = NULL,
                      col_obs = rgb(0, 0, 1, 0.3), col_imp = rgb(1, 0, 0, 0.3),
                      legendPos = "topright", breaks = NULL, ...)

Arguments

x

An object of class "malp" or "impute".

y

Not used at the moment.

which

Should we plot the fitted from MALP, LSLP or both?

pch

The type of points for the MALP and LS predictions.

col

The colour of points for the MALP and LS predictions.

bg

The bachground colour of points for the MALP and LS predictions.

title, xlab

Optional title and x-label.

col_obs, col_imp

The colour of the bars for the observed and imputed observations.

legendPos

The position of the legend.

breaks

Option arguments for histogram breaks. See hist.

...

Other graphical parameters

Value

No value is returned. This method is called for producing a plot. It invisibly returns NULL.

References

Kim, T. & Chausse, P & Matteo Bottai & Doros, G. & Giurcanu, M. & Luta, G. & Pena, E.A. (2026). “Maximum Agreement Linear Predictors.” Electronic Journal of Statistics, 20(2), 2892–2942. doi:10.1214/26-EJS2550

van Buuren S (2018). Flexible imputation of missing data. CRC press.

Examples

## Eye data example (see reference)

data(eye)
fitL <- malp(Stratus~Cirrus, data=subset(eye, Eye=="OS"))
plot(fitL, which="Both")

## Body fat (see reference)

data(bodyFat)
fit <- malp(PBF~ABD+WGT+FA+WRT+Age+TGH+NCK+Hip, bodyFat)
plot(fit, which="Both")

## Imputation

obj <- impute(Ozone~Solar.R, airquality)
plot(obj)

Predict method for objects of class "malp"

Description

The function predicts the dependent variable using models estimated by the maximum agreement method.

Usage

## S3 method for class 'malp'
predict(object, newdata = NULL, se.fit = FALSE,
                          interval = c("none", "confidence", "prediction"), level = 0.95,
                          includeLS = FALSE, LSdfCorr = FALSE, 
                          vcovMet = c("Asymptotic", "Normal", "Boot", "Jackknife"),
                          bootInterval=FALSE,
                          bootIntType=c("all", "norm", "basic",
                                        "stud", "perc", "bca"),
                          Bse.=100, B.=300,
                          parallel = c("no", "multicore", "snow"),
                          ncpus = getOption("boot.ncpus", 1L), cl =
                          NULL, ...)

Arguments

object

An object of class "malp".

newdata

An optional data.frame that contains new covariates used for the prediction. If not provided, the prediction is performed using the data used for the estimation.

se.fit

Should the function return the standard errors?

interval

If set to "confidence", the confidence interval is returned and if set to "predict", it returns the prediction intervals.

level

The level of the confidence interval.

includeLS

Should the method include the least squares prediction?

LSdfCorr

Should we correct for the degrees of freedom?

vcovMet

Method to compute the standard error of the prediction.

bootInterval

If set to TRUE, a bootstrap condifence interval is computed.

bootIntType

This is the type of bootstrap confidence interval. See boot for details.

Bse.

The number of bootstrap samples to compute the standard errors.

B.

The number of bootstrap sample to compute the confidence intervals.

parallel, ncpus, cl

These arguments are passed to boot.

...

Argument for other type of objects.

Details

By default, standard errors are computed using the Delta Method, which relies on a linear approximation of the solution. This approach is asymptotically valid under weak regularity conditions. However, its accuracy may be poor in small samples, in which case simulation-based methods may provide more reliable standard error estimates.

If you are willing to assume joint normality, you can set vcovMet to "Normal", in which case the exact expression for the standard error of the predictor is used. This method is valid only under the joint normality assumption.

Value

The following applies to all types of prediction. If includeLS is set to TRUE, the returned value is a list with components LS (least squares) and MALP (maximum agreement), each containing the prediction object described below. Otherwise, the prediction object itself is returned.

If interval = "none" and se.fit = FALSE, the prediction object is a numeric vector of predictions.

If interval = "none" and se.fit = TRUE, the prediction object is a list with components fit, containing the numeric vector of predictions, and se.fit, containing the corresponding estimated standard errors.

If interval is set to either "confidence" or "predict", the prediction object is a numeric matrix whose first column contains the predictions, the second the lower bound of the confidence or prediction interval, and the third the upper bound.

Thus, for each type of prediction, the return value follows the same conventions as predict.lm.

References

Kim, T. & Chausse, P & Matteo Bottai & Doros, G. & Giurcanu, M. & Luta, G. & Pena, E.A. (2026). “Maximum Agreement Linear Predictors.” Electronic Journal of Statistics, 20(2), 2892–2942. doi:10.1214/26-EJS2550

Examples

## Stratus VS Cirrus OCT (optimal coherence tomography)

# Left eye

data(eye)
fitL <- malp(Stratus~Cirrus, data=subset(eye, Eye=="OS"))
newd <- data.frame(Cirrus=200:205)
pr <- predict(fitL, newdata=newd, interval="confidence", includeLS=TRUE)
pr

## Body fat

data(bodyFat)
fit <- malp(PBF~ABD+WGT+FA+WRT+Age+TGH+NCK+Hip, bodyFat)
newd <- data.frame(Age=20:25, ABD=85, WGT=155, FA=27, WRT=17, TGH=60,
NCK=40, Hip=100)
pr <- predict(fit, newdata=newd, se.fit=TRUE)
pr

Summary for objects of class "malp" or "impute"

Description

For objects of class "malp", the method computes a coefficient matrix similar to the summary method for "lm" objects. For objects of class "impute", it returns a matrix that contains some summary statistics of the dependent variables before and after the imputation of the missing values.

Usage

## S3 method for class 'malp'
summary(object,
                       vcovMet=c("Asymptotic", "Normal", "Boot", "Jackknife"),
                       se=TRUE, LSdfCorr=FALSE, ...)

## S3 method for class 'impute'
summary(object, ...)

Arguments

object

An object of class "malp" or "impute"

vcovMet

Method to compute the covariance matrix of the coefficients. See the details in vcov.

se

Should the standard error of the coefficients be computed? This argument was included when "Boot" was the default method. It is no longer needed, but we keep it for now.

LSdfCorr

Should we apply the least squares degrees of freedom correction?

...

Argument to pass to vcov.

Value

symmary.malp returns an object of class "summary.malp", with the following components:

coefficients

The coefficient matrix with estimates, standard errors, t-ratios and p-values.

fitMALP

Measures of goodness of fit for maximum agreement predictors.

fitLSLP

Measures of goodness of fit for least squares predictors.

call

The original function call.

A print method is also available for this class of objects.

summary.impute returns an object of class "summary.impute". It is also a matrix that contains the sample mean, the sample standard deviation, the correlation between the fitted values and the dependent variable and the sample size, before imputation in the first column and after in the second.

The "+.summary.impute" operator allows to combine two summary tables into one, without repeating the first column. See the example below.

References

Kim, T. & Chausse, P & Matteo Bottai & Doros, G. & Giurcanu, M. & Luta, G. & Pena, E.A. (2026). “Maximum Agreement Linear Predictors.” Electronic Journal of Statistics, 20(2), 2892–2942. doi:10.1214/26-EJS2550

van Buuren S (2018). Flexible imputation of missing data. CRC press.

Examples

## Stratus VS Cirrus OCT (optimal coherence tomography)

# Left eye
data(eye)
fitL <- malp(Stratus~Cirrus, data=subset(eye, Eye=="OS"))
summary(fitL)
# Right eye
fitR <- malp(Stratus~Cirrus, data=subset(eye, Eye=="OD"))
summary(fitR)

## Body fat

data(bodyFat)
fit <- malp(PBF~ABD+WGT+FA+WRT+Age+TGH+NCK+Hip, bodyFat)
summary(fit)

## Imputation

obj1 <- summary(impute(Ozone~Solar.R, airquality))
obj2 <- summary(impute(Ozone~Solar.R, airquality, "LSLP"))
obj3 <- summary(impute(Ozone~Solar.R, airquality, "Mean"))

obj1+obj2+obj3

Covariance estimation method for objects of class malp

Description

It returns the covariance matrix of the coefficients obtained using the maximum agreement method.

Usage

## S3 method for class 'malp'
vcov(object, method=c("Asymptotic", "Normal", "Boot", "Jackknife"),
                    B=400, LSdfCorr=FALSE, ...)

Arguments

object

An object of class malp

method

Method to compute the covariance matrix of the coefficients. See details.

LSdfCorr

Should we apply the least squares degrees of freedom correction?

B

The number of replications for the bootstrap method.

...

Argument for other type of objects.

Details

Kim et al. (2026) derive expressions for the standard errors of the predictor directly, rather than for the covariance matrix of the estimated coefficients. The different methods available for estimating these standard errors are described in the Details section of predict.

The covariance matrix of the estimated coefficients is obtained by deriving an expression from the predictor variance formula presented in Kim et al. (2026).

Value

It returns the variance covariance matrix of the coefficient

References

Kim, T. & Chausse, P & Matteo Bottai & Doros, G. & Giurcanu, M. & Luta, G. & Pena, E.A. (2026). “Maximum Agreement Linear Predictors.” Electronic Journal of Statistics, 20(2), 2892–2942. doi:10.1214/26-EJS2550

Examples

## Stratus VS Cirrus OCT (optimal coherence tomography)

# Left eye
data(eye)
fitL <- malp(Stratus~Cirrus, data=subset(eye, Eye=="OS"))
vcov(fitL)