| Type: | Package |
| Title: | Nonparametric ANCOVA Methods |
| Version: | 0.1.0 |
| Date: | 2025-11-04 |
| Description: | Nonparametric methods for analysis of covariance (ANCOVA) are distribution-free and provide a flexible statistical framework for situations where the assumptions of parametric ANCOVA are violated or when the response variable is ordinal. This package implements several well-known nonparametric ANCOVA procedures, including Quade, Puri and Sen, McSweeney and Porter, Burnett and Barr, Hettmansperger and McKean, Shirley, and Puri-Sen-Harwell-Serlin. The package provides user-friendly functions to apply these methods in practice. |
| License: | GPL-3 |
| URL: | https://github.com/Mina7Jahangiri7/npANCOVA |
| BugReports: | https://github.com/Mina7Jahangiri7/npANCOVA/issues |
| Depends: | R (≥ 4.0) |
| Imports: | stats |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| NeedsCompilation: | no |
| Author: | Mina Jahangiri |
| Maintainer: | Mina Jahangiri <minajahangiri984@gmail.com> |
| Packaged: | 2025-11-05 15:43:38 UTC; USER |
| Repository: | CRAN |
| Date/Publication: | 2025-11-09 16:30:13 UTC |
npANCOVA: Nonparametric ANCOVA Methods
Description
The npANCOVA package provides a collection of functions to implement various nonparametric Analysis of Covariance (ANCOVA) methods.
Details
This package is designed for researchers and statisticians who need to perform ANCOVA when the assumptions of parametric ANCOVA, such as normality of residuals or the homogeneity of regression slopes, are not met.
Key Functions
The main functions provided by the package are:
Burnett_BarrImplements the Burnett and Barr rank-based method.
Harwell_SerlinPerforms the Harwell and Serlin method using ranked variables.
Hettmansperger_McKeanApplies rank-based residual analysis.
McSweeny_PorterPerforms rank-based ANCOVA with and without interaction.
Puri_Sen_OUPerforms the Puri and Sen method using one covariate with an ubiased variance-covariance matrix.
Puri_Sen_OBPerforms the Puri and Sen method using one covariate with a biased variance-covariance matrix.
Puri_Sen_MUPerforms the Puri and Sen method using multiple covariates with an unbiased variance-covariance matrix.
Puri_Sen_MBPerforms the Puri and Sen method using multiple covariates with a biased variance-covariance matrix.
QuadePerforms Quade's ANCOVA using ranked variables and analysis of residuals.
ShirleyCalculates group and interaction effects based on ranks.
Author(s)
Maintainer: Mina Jahangiri minajahangiri984@gmail.com (ORCID)
Authors:
Other contributors:
See Also
Useful links:
Report bugs at https://github.com/Mina7Jahangiri7/npANCOVA/issues
Burnett and Barr Method for Nonparametric ANCOVA
Description
Implements the Burnett and Barr rank-based method for ANCOVA. This method is suitable for models with one response, one covariate, and one grouping variable.
Usage
Burnett_Barr(data, formula)
Arguments
data |
A data frame containing the variables specified in the formula. |
formula |
An object of class "formula": a symbolic description of the model to be fitted. The structure should be 'response ~ covariate + group'. |
Value
A list containing the following components:
- regression_equation
The summary of the fitted linear model.
- anova
The ANOVA table from the fitted model.
- data
The original data frame with added columns for ranks.
References
Burnett TD, Barr DRJE, Measurement P. A nonparametric analogy of analysis of covariance. 1977;37(2):341-8.
Olejnik SF, Algina JJER. A review of nonparametric alternatives to analysis of covariance. 1985;9(1):51-83.
Examples
# 1. Create a sample data frame
data <- data.frame(
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3),
response = c(16, 60, 82, 126, 137, 44, 67, 87, 100, 142, 17, 28, 105, 149, 160),
covariate1 = c(26, 10, 42, 49, 55, 21, 28, 5, 12, 58, 1, 19, 41, 48, 35)
)
# 2. Run the Burnett and Barr method
results <- Burnett_Barr(
formula = response ~ covariate1 + group,
data = data
)
# 3. View the results
print(results)
print(results$anova)
Harwell and Serlin Method for Nonparametric ANCOVA
Description
Performs the Harwell and Serlin method using ranked response and covariate variables.
Usage
Harwell_Serlin(data, formula)
Arguments
data |
A data frame containing the variables specified in the formula. |
formula |
An object of class "formula": a symbolic description of the model to be fitted. The structure should be 'response ~ covariate1 + ... + group'. |
Value
A list containing the following components:
- regression_equation
The summary of the fitted linear model.
- anova
The ANOVA table from the fitted model.
- statistics
The Harwell-Serlin test statistic.
- df
The degrees of freedom for the test.
- p_value
The p-value of the test.
- data
The original data frame with added columns for ranks.
References
Harwell MR, Serlin RCJPB. An empirical study of a proposed test of nonparametric analysis of covariance. 1988;104(2):268.
Examples
# 1. Create a sample data frame
data <- data.frame(
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3),
response = c(16, 60, 82, 126, 137, 44, 67, 87, 100, 142, 17, 28, 105, 149, 160),
covariate1 = c(26, 10, 42, 49, 55, 21, 28, 5, 12, 58, 1, 19, 41, 48, 35),
covariate2 = c(12, 21, 24, 29, 34, 17, 2, 40, 38, 36, 8, 1, 9, 28, 16)
)
# 2. Run the Harwell and Serlin method
results <- Harwell_Serlin(
formula = response ~ covariate1 + covariate2 + group,
data = data
)
# 3. View the results
print(results$p_value)
print(paste("Statistic:", results$statistics,"df:", results$df, "P-value:", results$p_value))
Hettmansperger and McKean Method for ANCOVA
Description
Applies rank-based residual analysis for ANCOVA. This method involves fitting a model of the response on the covariate, calculating residuals, ranking them, and then performing an ANOVA on the (weighted) ranked residuals.
Usage
Hettmansperger_McKean(data, formula)
Arguments
data |
A data frame containing the variables specified in the formula. |
formula |
An object of class "formula": a symbolic description of the model to be fitted. The structure should be 'response ~ covariate1 + ... + group'. |
Value
A list containing the following components:
- regression_equation_covariate
The summary of the initial model fitting response on covariates.
- regression_equation_residuals
The summary of the model fitting weighted ranked residuals on the group.
- anova
The ANOVA table for the model based on weighted ranked residuals.
- group_means
A data frame of the mean of weighted ranked residuals for each group.
- group_sds
A data frame of the standard deviation of weighted ranked residuals for each group.
- data
The original data frame augmented with residuals, ranked residuals, and weighted ranked residuals.
References
Hettmansperger TP, McKean JWJT. A robust alternative based on ranks to least squares in analyzing linear models. 1977;19(3):275-84.
Hettmansperger TP, McKean JWJJotASA. A geometric interpretation of inferences based on ranks in the linear model. 1983;78(384):885-93.
Examples
# 1. Create a sample data frame
data <- data.frame(
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3),
response = c(16, 60, 82, 126, 137, 44, 67, 87, 100, 142, 17, 28, 105, 149, 160),
covariate1 = c(26, 10, 42, 49, 55, 21, 28, 5, 12, 58, 1, 19, 41, 48, 35),
covariate2 = c(12, 21, 24, 29, 34, 17, 2, 40, 38, 36, 8, 1, 9, 28, 16)
)
# 2. Run the Hettmansperger and McKean method
results <- Hettmansperger_McKean(
formula = response ~ covariate1 + covariate2 + group,
data = data
)
# 3. View the results
print(results)
print(results$anova)
McSweeny and Porter Method for Nonparametric ANCOVA
Description
Performs rank-based ANCOVA with and without an interaction term between the covariates and the group.
Usage
McSweeny_Porter(data, formula)
Arguments
data |
A data frame containing the variables specified in the formula. |
formula |
An object of class "formula": a symbolic description of the model to be fitted. The structure should be 'response ~ covariate1 + ... + group'. |
Value
A list containing the following components:
- regression_equation_covariate
Summary of the model with only covariates.
- regression_equation_covariate_group
Summary of the model with covariates and group main effects.
- group_effect
The result of an ANOVA test for group effect.
- interaction_effect
The result of an ANOVA test for interaction effect between group and covariate variables.
- regression_equation_interaction
Summary of the model including the interaction term.
- data
The original data frame with added columns for ranks.
References
McSweeney M, Porter AJOp. Small sample properties of nonparametric index of response and rank analysis of covariance. 1971;16.
Olejnik SF, Algina JJER. A review of nonparametric alternatives to analysis of covariance. 1985;9(1):51-83.
Examples
# 1. Create a sample data frame
data <- data.frame(
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3),
response = c(16, 60, 82, 126, 137, 44, 67, 87, 100, 142, 17, 28, 105, 149, 160),
covariate1 = c(26, 10, 42, 49, 55, 21, 28, 5, 12, 58, 1, 19, 41, 48, 35),
covariate2 = c(12, 21, 24, 29, 34, 17, 2, 40, 38, 36, 8, 1, 9, 28, 16)
)
# 2. Run the McSweeny and Porter method
results <- McSweeny_Porter(
formula = response ~ covariate1 + covariate2 + group,
data = data
)
# 3. View the results
print(results)
print(results$group_effect)
print(results$interaction_effect)
Puri and Sen Method with Biased Variance-Covariance Matrix for Nonparametric ANCOVA: Multiple Covariates
Description
Performs the Puri and Sen method for multiple covariates using a biased variance-covariance matrix.
Usage
Puri_Sen_MB(data, formula)
Arguments
data |
A data frame containing the variables specified in the formula. |
formula |
An object of class "formula": a symbolic description of the model to be fitted. The structure should be 'response ~ covariate1 + ... + group'. |
Value
A list containing the following components:
- residuals
A vector of residuals for each group.
- V
The biased variance-covariance matrix.
- inverse_V
The inverse of the variance-covariance matrix.
- L_statistic
The Puri and Sen L-statistic.
- df
The degrees of freedom for the test.
- p_value
The corresponding p-value of the L-statistic.
- data
The original data frame with added columns for ranks.
References
Puri ML, Sen PKJAoMS. Analysis of covariance based on general rank scores. 1969;40(2):610-8.
Olejnik SF, Algina JJER. A review of nonparametric alternatives to analysis of covariance. 1985;9(1):51-83.
Examples
# 1. Create a sample data frame
data <- data.frame(
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3),
response = c(16, 60, 82, 126, 137, 44, 67, 87, 100, 142, 17, 28, 105, 149, 160),
covariate1 = c(26, 10, 42, 49, 55, 21, 28, 5, 12, 58, 1, 19, 41, 48, 35),
covariate2 = c(12, 21, 24, 29, 34, 17, 2, 40, 38, 36, 8, 1, 9, 28, 16)
)
# 2. Run the Puri and Sen (MB) method
results <- Puri_Sen_MB(
formula = response ~ covariate1 + covariate2 + group,
data = data
)
# 3. View the results
print(results)
print(paste("Statistic:", results$L_statistic,"df:", results$df, "P-value:", results$p_value))
Puri and Sen Method with Unbiased Variance-Covariance Matrix for Nonparametric ANCOVA: Multiple Covariates
Description
Performs the Puri and Sen method for multiple covariates using an unbiased variance-covariance matrix.
Usage
Puri_Sen_MU(data, formula)
Arguments
data |
A data frame containing the variables specified in the formula. |
formula |
An object of class "formula": a symbolic description of the model to be fitted. The structure should be 'response ~ covariate1 + ... + group'. |
Value
A list containing the following components:
- residuals
A vector of residuals for each group.
- V
The unbiased variance-covariance matrix.
- inverse_V
The inverse of the variance-covariance matrix.
- L_statistic
The Puri and Sen L-statistic.
- df
The degrees of freedom for the test.
- p_value
The corresponding p-value of the L-statistic.
- data
The original data frame with added columns for ranks.
References
Puri ML, Sen PKJAoMS. Analysis of covariance based on general rank scores. 1969;40(2):610-8.
Olejnik SF, Algina JJER. A review of nonparametric alternatives to analysis of covariance. 1985;9(1):51-83.
Examples
# 1. Create a sample data frame
data <- data.frame(
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3),
response = c(16, 60, 82, 126, 137, 44, 67, 87, 100, 142, 17, 28, 105, 149, 160),
covariate1 = c(26, 10, 42, 49, 55, 21, 28, 5, 12, 58, 1, 19, 41, 48, 35),
covariate2 = c(12, 21, 24, 29, 34, 17, 2, 40, 38, 36, 8, 1, 9, 28, 16)
)
# 2. Run the Puri and Sen (MU) method
results <- Puri_Sen_MU(
formula = response ~ covariate1 + covariate2 + group,
data = data
)
# 3. View the results
print(results)
print(paste("Statistic:", results$L_statistic,"df:", results$df, "P-value:", results$p_value))
Puri and Sen Method with Biased Variance-Covariance Matrix for Nonparametric ANCOVA: One Covariate
Description
Performs the Puri and Sen method for a single covariate using a biased variance-covariance matrix.
Usage
Puri_Sen_OB(data, formula)
Arguments
data |
A data frame containing the variables specified in the formula. |
formula |
An object of class "formula": a symbolic description of the model to be fitted. The structure should be 'response ~ covariate + group'. |
Value
A list containing the following components:
- residuals
A vector of residuals for each group.
- V
The biased variance-covariance matrix.
- inverse_V
The inverse of the variance-covariance matrix.
- L_statistic
The Puri and Sen L-statistic.
- df
The degrees of freedom for the test.
- p_value
The corresponding p-value of the L-statistic.
- data
The original data frame with added columns for ranks.
References
Puri ML, Sen PKJAoMS. Analysis of covariance based on general rank scores. 1969;40(2):610-8.
Olejnik SF, Algina JJER. A review of nonparametric alternatives to analysis of covariance. 1985;9(1):51-83.
Examples
# 1. Create a sample data frame
data <- data.frame(
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3),
response = c(16, 60, 82, 126, 137, 44, 67, 87, 100, 142, 17, 28, 105, 149, 160),
covariate1 = c(26, 10, 42, 49, 55, 21, 28, 5, 12, 58, 1, 19, 41, 48, 35)
)
# 2. Run the Puri and Sen (OB) method
results <- Puri_Sen_OB(
formula = response ~ covariate1 + group,
data = data
)
# 3. View the results
print(results)
print(paste("Statistic:", results$L_statistic,"df:", results$df, "P-value:", results$p_value))
Puri and Sen Method with Unbiased Variance-Covariance Matrix for Nonparametric ANCOVA: One Covariate
Description
Performs the Puri and Sen method for a single covariate using an unbiased variance-covariance matrix.
Usage
Puri_Sen_OU(data, formula)
Arguments
data |
A data frame containing the variables specified in the formula. |
formula |
An object of class "formula": a symbolic description of the model to be fitted. The structure should be 'response ~ covariate + group'. |
Value
A list containing the following components:
- residuals
A vector of residuals for each group.
- V
The unbiased variance-covariance matrix.
- inverse_V
The inverse of the variance-covariance matrix.
- L_statistic
The Puri and Sen L-statistic.
- df
The degrees of freedom for the test.
- p_value
The corresponding p-value of the L-statistic.
- data
The original data frame with added columns for ranks.
References
Puri ML, Sen PKJAoMS. Analysis of covariance based on general rank scores. 1969;40(2):610-8.
Olejnik SF, Algina JJER. A review of nonparametric alternatives to analysis of covariance. 1985;9(1):51-83.
Examples
# 1. Create a sample data frame
data <- data.frame(
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3),
response = c(16, 60, 82, 126, 137, 44, 67, 87, 100, 142, 17, 28, 105, 149, 160),
covariate1 = c(26, 10, 42, 49, 55, 21, 28, 5, 12, 58, 1, 19, 41, 48, 35)
)
# 2. Run the Puri and Sen (OU) method
results <- Puri_Sen_OU(
formula = response ~ covariate1 + group,
data = data
)
# 3. View the results
print(results)
print(paste("Statistic:", results$L_statistic,"df:", results$df, "P-value:", results$p_value))
Quade Method for Nonparametric ANCOVA
Description
Performs Quade's ANCOVA using ranked variables and analysis of residuals. The method fits a linear model of the ranked response on the ranked covariates, and then performs an ANOVA on the residuals of that model.
Usage
Quade(data, formula)
Arguments
data |
A data frame containing the variables specified in the formula. |
formula |
An object of class "formula": a symbolic description of the model to be fitted. The structure should be 'response ~ covariate1 + ... + group'. |
Value
A list containing the following components:
- regression_equation
Summary of the linear model regressing the ranked response on the ranked covariates.
- anova_summary
The summary of the ANOVA model performed on the residuals.
- group_means
A data frame of the mean of residuals for each group.
- group_sds
A data frame of the standard deviation of residuals for each group.
- regression_equation_residuals
The summary of the model fitting residuals on the group.
- data
The original data frame augmented with ranked variables and residuals.
References
Quade DJJotASA. Rank analysis of covariance. 1967;62(320):1187-200.
Olejnik SF, Algina JJER. A review of nonparametric alternatives to analysis of covariance. 1985;9(1):51-83.
Examples
# 1. Create a sample data frame
data <- data.frame(
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3),
response = c(16, 60, 82, 126, 137, 44, 67, 87, 100, 142, 17, 28, 105, 149, 160),
covariate1 = c(26, 10, 42, 49, 55, 21, 28, 5, 12, 58, 1, 19, 41, 48, 35),
covariate2 = c(12, 21, 24, 29, 34, 17, 2, 40, 38, 36, 8, 1, 9, 28, 16)
)
# 2. Run the Quade method
results <- Quade(
formula = response ~ covariate1 + covariate2 + group,
data = data
)
# 3. View the results
print(results)
print(results$anova_summary)
Shirley Method for Nonparametric ANCOVA
Description
Calculates group and interaction effects based on ranked response and covariate variables using changes in R-squared values between models.
Usage
Shirley(data, formula)
Arguments
data |
A data frame containing the variables specified in the formula. |
formula |
An object of class "formula": a symbolic description of the model to be fitted. The structure should be 'response ~ covariate1 + ... + group'. |
Value
A list containing components related to the group and interaction effects, including:
- statistics_group
The test statistic for the main group effect.
- p_value_group
The p-value for the main group effect.
- df_group
Degrees of freedom for the group effect.
- statistics_interaction
The test statistic for the interaction effect.
- p_value_interaction
The p-value for the interaction effect.
- df_interaction
Degrees of freedom for the interaction effect.
- regression_equation_covariate
Summary of the model with only covariates.
- regression_equation_covariate_group
Summary of the model with covariates and group main effects.
- regression_equation_interaction
Summary of the model including the interaction term.
- data
The original data frame with added columns for ranks.
References
Burnett TD, Barr DRJE, Measurement P. A nonparametric analogy of analysis of covariance. 1977;37(2):341-8.
Olejnik SF, Algina JJER. A review of nonparametric alternatives to analysis of covariance. 1985;9(1):51-83.
Examples
# 1. Create a sample data frame
data <- data.frame(
group = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3),
response = c(16, 60, 82, 126, 137, 44, 67, 87, 100, 142, 17, 28, 105, 149, 160),
covariate1 = c(26, 10, 42, 49, 55, 21, 28, 5, 12, 58, 1, 19, 41, 48, 35),
covariate2 = c(12, 21, 24, 29, 34, 17, 2, 40, 38, 36, 8, 1, 9, 28, 16)
)
# 2. Run the Shirley method
results <- Shirley(
formula = response ~ covariate1 + covariate2 + group,
data = data
)
# 3. View the results
print(results)
print(paste("Statistic:", results$statistics_group,
"df_group:", results$df_group,
"P-value:", results$p_value_group))
print(paste("Statistic:", results$statistics_interaction,
"df_interaction:", results$df_interaction,
"P-value:", results$p_value_interaction))