32 const bool fit_intercept)
37 Eigen::VectorXd residuals;
46 y.array() -= y.mean();
51 auto [ols_intercept, ols_coefs] =
52 detail::fitOls(x.derived(), y, fit_intercept);
53 residuals = y - x.derived() * ols_coefs;
56 residuals.array() -= ols_intercept;
59 df = n - p -
static_cast<int>(fit_intercept) - 1;
64 return residuals.norm() / std::sqrt(df);
double estimateNoise(Eigen::EigenBase< T > &x, Eigen::MatrixXd &y, const bool fit_intercept)
Estimates noise (standard error) in a linear model using OLS residuals.