pub fn ols_regression(
y_json: &str,
x_vars_json: &str,
variable_names: &str,
) -> StringExpand description
Performs OLS regression via WASM.
All parameters and return values are JSON-encoded strings for JavaScript interoperability. Returns regression output including coefficients, standard errors, diagnostic statistics, and VIF analysis.
§Arguments
y_json- JSON array of response variable values:[1.0, 2.0, 3.0]x_vars_json- JSON array of predictor arrays:[[1.0, 2.0], [0.5, 1.0]]variable_names- JSON array of variable names:["Intercept", "X1", "X2"]
§Returns
JSON string containing the complete regression output with coefficients, standard errors, t-statistics, p-values, R², F-statistic, residuals, leverage, VIF, etc.
§Errors
Returns a JSON error object if:
- JSON parsing fails
- Insufficient data (n ≤ k + 1)
- Matrix is singular
- Domain check fails