Learn R Programming

npANCOVA (version 0.1.1)

Puri_Sen_OU: 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)

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.

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`.

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

Run this code
# 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))

Run the code above in your browser using DataLab