Learn R Programming

aridagri (version 2.0.3)

sem_analysis: Structural Equation Modeling for Field Experiments

Description

Performs SEM analysis for agricultural field experiments. Allows testing of hypothesized causal relationships among variables.

Usage

sem_analysis(data, model, plot = TRUE, verbose = TRUE)

Value

SEM results including fit indices and parameter estimates

Arguments

data

Data frame with variables

model

Model specification in lavaan syntax

plot

Logical, whether to generate path diagram

verbose

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

Author

Lalit Kumar Rolaniya, ICAR-IIPR, Bikaner

Examples

Run this code
# \donttest{
if (requireNamespace("lavaan", quietly = TRUE)) {
  set.seed(42)
  n <- 100
  nitrogen <- rnorm(n, 60, 10)
  phosphorus <- rnorm(n, 30, 5)
  yield <- 0.5 * nitrogen + 0.3 * phosphorus + rnorm(n, 0, 5)
  df <- data.frame(yield = yield, nitrogen = nitrogen, phosphorus = phosphorus)
  model <- 'yield ~ nitrogen + phosphorus'
  result <- sem_analysis(df, model, plot = FALSE)
}
# }

Run the code above in your browser using DataLab