Skip to contents

Performs path analysis to determine direct and indirect effects of independent variables on a dependent variable. Essential for understanding yield contributing factors.

Usage

path_analysis(data, dependent, independent, digits = 4, verbose = TRUE)

Arguments

data

Data frame with numeric variables

dependent

Name of dependent variable (e.g., "yield")

independent

Character vector of independent variable names

digits

Number of decimal places

verbose

Logical. If TRUE (default), prints formatted output to console.

Value

List with direct effects, indirect effects, and correlation breakdown

Author

Lalit Kumar Rolaniya, ICAR-IIPR, Bikaner

Examples

data <- data.frame(
  yield = c(1200, 1350, 1100, 1450, 1280, 1380, 1220, 1400),
  pods = c(45, 52, 42, 58, 48, 54, 46, 56),
  seeds = c(8.2, 9.1, 7.8, 9.5, 8.5, 9.0, 8.3, 9.3),
  weight = c(32, 35, 30, 38, 33, 36, 31, 37)
)
path_analysis(data, dependent = "yield", 
              independent = c("pods", "seeds", "weight"))
#> 
#> ==========================================================
#>           PATH COEFFICIENT ANALYSIS
#> ==========================================================
#> Dependent variable: yield 
#> Independent variables: pods, seeds, weight 
#> Number of observations: 8 
#> 
#> --- Direct Effects (Path Coefficients) ---
#> 
#>  Variable Direct_Effect
#>      pods        0.5512
#>     seeds        0.4968
#>    weight       -0.0549
#> 
#> --- Indirect Effects ---
#> 
#>          pods  seeds  weight
#> pods   0.0000 0.4911 -0.0543
#> seeds  0.5448 0.0000 -0.0537
#> weight 0.5456 0.4859  0.0000
#> 
#> --- Correlation Partitioning ---
#> 
#>  Variable Correlation_with_Y Direct_Effect Indirect_Effect
#>      pods             0.9879        0.5512          0.4368
#>     seeds             0.9880        0.4968          0.4912
#>    weight             0.9766       -0.0549          1.0315
#> 
#> --- Model Summary ---
#> R-squared: 0.9818 
#> Residual effect: 0.1351 
#> ==========================================================