r2adj
- pyoptex.analysis.utils.fit.r2adj(fit)[source]
Computes the adjust r-square from a model fit. When fit is from an OLS, the r2adj is already precomputed as rsquared_adj. When fit is from a mixed LM, the r2adj is based on the average estimated semi-variance as denoted in Piepho (2019).
\[\begin{split}R_{adj}^2 &= 1 - \frac{trace(V1 P)}{trace(V0 P)} \\ P &= I_N - \frac{1}{n} 1_N 1_N^T \end{split}\]N is the number of runs. \(V_0\) and \(V_1\) are the observation covariance matrices of the model fitted with only the intercept and the complete model. \(I_N\) is the identity matrix of size (N, N). \(1_N\) is a vector of ones of size N.
Parameters
- fit
statsmodels.regression.linear_model.RegressionResultsorstatsmodels.regression.mixed_linear_model.MixedLMResults The results after fitting a statsmodels OLS or mixed LM.
Returns
- r2adjfloat
The adjust r-squared of the results.
- fit