Patterns in static

Apophenia

apop_tests.c File Reference

Functions


Detailed Description


Function Documentation

apop_data* apop_anova ( char *  table,
char *  data,
char *  grouping1,
char *  grouping2 
)

This function produces a traditional one- or two-way ANOVA table. It works from data in an SQL table, using queries of the form select data from table group by grouping1, grouping2.

Parameters:
table The table to be queried.
data The name of the column holding the data
grouping1 The name of the first column by which to group data
grouping2 If this is NULL, then the function will return a one-way ANOVA. Otherwise, the name of the second column by which to group data in a two-way ANOVA.
double apop_test ( double  statistic,
char *  distribution,
double  p1,
double  p2,
char  tail 
)

This is a convenience function to do the lookup of a given statistic along a given distribution. You give me a statistic, its (hypothesized) distribution, and whether to use the upper tail, lower tail, or both. I will return the odds of a Type I error given the model---in statistician jargon, the $p$-value. [Type I error: odds of rejecting the null hypothesis when it is true.]

For example,

   apop_test(1.3);

will return the density of the standard Normal distribution that is more than 1.3 from zero. If this function returns a small value, we can be confident that the statistic is significant. Or,

   apop_test(1.3, "t", 10, tail='u');

will give the appropriate odds for an upper-tailed test using the $t$-distribution with 10 degrees of freedom (e.g., a $t$-test of the null hypothesis that the statistic is less than or equal to zero).

Several more distributions are supported; see below.

  • For a two-tailed test (the default), this returns the density outside the range. I'll only do this for symmetric distributions.
  • For an upper-tail test ('u'), this returns the density above the cutoff
  • For a lower-tail test ('l'), this returns the density below the cutoff
Parameters:
statistic The scalar value to be tested.
distribution The name of the distribution; see below.
p1 The first parameter for the distribution; see below.
p2 The second parameter for the distribution; see below.
tail 'u' = upper tail; 'l' = lower tail; anything else = two-tailed. (default = two-tailed)
Returns:
The odds of a Type I error given the model (the $p$-value).

Here is a list of distributions you can use, and their parameters.

"normal" or "gaussian"

  • p1=mu, p2=sigma
  • default (0, 1)

"lognormal"

  • p1=mu, p2=sigma
  • default (0, 1)
  • Remember, mu and sigma refer to the Normal one would get after exponentiation
  • One-tailed tests only

"uniform"

  • p1=lower edge, p2=upper edge
  • default (0, 1)
  • two-tailed tests are run relative to the center, (p1+p2)/2.

"t"

  • p1=df
  • no default

"chi squared", "chi", "chisq":

  • p1=df
  • no default
  • One-tailed tests only; default='u' ($p$-value for typical cases)

"f"

  • p1=df1, p2=df2
  • no default
  • One-tailed tests only

SourceForge.net Logo

Autogenerated by doxygen on 23 Nov 2009.