Patterns in static

Apophenia

Macros | Functions
OLS/GLS: The linear projection methods

Macros

#define apop_estimate_r_squared(in)
 

Functions

apop_dataapop_estimate_coefficient_of_determination (apop_model *m)
 

Detailed Description

Macro Definition Documentation

#define apop_estimate_r_squared (   in)

Function Documentation

apop_data* apop_estimate_coefficient_of_determination ( apop_model m)

Good ol' $R^2$. Let $Y$ be the dependent variable, $\epsilon$ the residual, $n$ the number of data points, and $k$ the number of independent vars (including the constant). Returns an apop_data set with the following entries (in the vector element):

  • $ SST \equiv \sum (Y_i - \bar Y) ^2 $
  • $ SSE \equiv \sum \epsilon ^2 $
  • $ R^2 \equiv 1 - {SSE\over SST} $
  • $ R^2_{adj} \equiv R^2 - {(k-1)\over (n-k-1)}(1-R^2) $

Internally allocates (and frees) a vector the size of your data set.

Returns
: a $5 \times 1$ apop_data table with the following fields:
  • "R squared"
  • "R squared adj"
  • "SSE"
  • "SST"
  • "SSR"
If the output is in sss, use apop_data_get(sss, .rowname="SSE") to get the SSE, and so on for the other items.
Parameters
mA model. I use the pointer to the data set used for estimation and the info page named "<Predicted>". The Predicted page should include observed, expected, and residual columns, which I use to generate the sums of squared errors and residuals, et cetera. All generalized linear models produce a page with this name and of this form, as do a host of other models. Nothing keeps you from finding the $R^2$ of, say, a kernel smooth; it is up to you to determine whether such a thing is appropriate to your given models and situation.
  • apop_estimate(yourdata, apop_ols) does this automatically
  • If I don't find a Predicted page, I throw an error on the screen and return NULL.
  • The number of observations equals the number of rows in the Predicted page
  • The number of independent variables, needed only for the adjusted $R^2$, is from the number of columns in the main data set's matrix (i.e. the first page; i.e. the set of parameters if this is the parameters output from a model estimation).
  • If your data (first page again) has a weights vector, I will find weighted SSE, SST, and SSR (and calculate the $R^2$s using those values).

Autogenerated by doxygen on Sun Oct 26 2014 (Debian 0.999b+ds3-2).