The lhstats Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The lhstats Reference Manual

This is the lhstats Reference Manual, version 1.1.1, generated automatically by Declt version 2.3 "Robert April" on Tue Feb 20 08:54:18 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

* About
Statistical functions in Common Lisp.
Version 1.01
July 27, 2001

- Sourced from: http://nostoc.stanford.edu/jeff/cllib/utils.lisp
- CLiki: http://www.cliki.net/Stats

Documentation from lhstats.lisp:

This comes in large part from Larry Hunter but has been significantly
augmented by Jeff Shrager, partly from his own stats libraries, and 
partly from open source stuff borrowed from around the web.  Citations
and acknowledgements are given where possible.

Patches welcome (preferably via pull requests at
https://github.com/mrc/lhstats)

* Larry Hunter's Code

Statistical functions in Common Lisp.  Version 1.01 July 27, 2001

This code is copyright (c) 2000 by Larry Hunter (Larry.Hunter@uchsc.edu)
except where otherwise noted.

Thanks to Paul Cohen for the original CLASP package.  Thanks also to bug
reports from Rob St. Amant.

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

The formulas and methods used are largely taken from Bernard Rosner,
"Fundamentals of Biostatistics," 5th edition.  "Rosner x" is a page
number.  Some numeric functions were taken from CLASP, a 1994 common
lisp package that implemented some of the statistical functions from
"Numeric recipes in C" For CLASP functions, see copyright notice below.

These abreviations used in function and variable names:
| ci  | confidence interval          |
| cdf | cumulative density function  |
| ge  | greater than or equal to     |
| le  | less than or equal to        |
| pdf | probability density function |
| sd  | standard deviation           |
| rxc | rows by columns              |
| sse | sample size estimate         |

* Functions provided

** Descriptive statistics
  Mean, median, mode, geometric mean, range, percentile, variance,
  standard-deviation (sd), coefficient-of-variation,
  standard-error-of-the-mean

** Distributional functions
*** Poisson & Binomial
   binomial-probability, binomial-cumulative-probability,
   binomial-ge-probability, poisson-probability,
   poisson-cumulative-probability, poisson-ge-probability, Normal
   normal-pdf, convert-to-standard-normal, phi, z, t-distribution,
   chi-square, chi-square-cdf

** Confidence Intervals
  binomial-probability-ci, poisson-mu-ci, normal-mean-ci,
  normal-mean-ci-on-sequences, normal-variance-ci,
  normal-variance-ci-on-sequence, normal-sd-ci

** Hypothesis tests (parametric)
  z-test, z-test-on-sequence, t-test-one-sample,
  t-test-one-sample-on-sequence, t-test-paired,
  t-test-paired-on-sequences, t-test-two-sample,
  t-test-two-sample-on-sequences, chi-square-test-one-sample, f-test,
  binomial-test-one-sample, binomial-test-two-sample, fisher-exact-test,
  mcnemars-test, poisson-test-one-sample

** Hypothesis tests (non-parametric)
  sign-test, sign-test-on-sequence, wilcoxon-signed-rank-test,
  chi-square-test-rxc, chi-square-test-for-trend

** Sample size estimates
  t-test-one-sample-sse, t-test-two-sample-sse
  t-test-paired-sse, binomial-test-one-sample-sse,
  binomial-test-two-sample-sse,
  binomial-test-paired-sse, correlation-sse

** Correlation and Regression
  linear-regression, correlation-coefficient,
  correlation-test-two-sample, spearman-rank-correlation

** Significance test functions
  t-significance, f-significance (chi square significance is calculated
  from chi-square-cdf in various ways depending on the problem).

** Utilities
  random-sample, random-pick, bin-and-count, fishers-z-transform,
  mean-sd-n, square, choose, permutations, round-float



Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 lhstats

Maintainer

Matt Curtis <matt.r.curtis@gmail.com>

Author

Larry Hunter, Jeff Shrager

License

GNU General Public License version 2 (GPLv2)

Description

Statistical functions by Larry Hunter and Jeff Shrager.

Version

1.1.1

Source

lhstats.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 lhstats.asd

Location

lhstats.asd

Systems

lhstats (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 lhstats/package.lisp

Parent

lhstats (system)

Location

package.lisp

Packages

statistics


Previous: , Up: Lisp files   [Contents][Index]

3.1.3 lhstats/lhstats.lisp

Dependency

package.lisp (file)

Parent

lhstats (system)

Location

lhstats.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 statistics

Statistical functions

Source

package.lisp (file)

Nickname

stats

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: square X
Package

statistics

Source

lhstats.lisp (file)

Macro: test-variables &rest ARGS
Package

statistics

Source

lhstats.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: bin-and-count SEQUENCE N

Make N equal width bins and count the number of elements of sequence that belong in each.

Package

statistics

Source

lhstats.lisp (file)

Function: binomial-cumulative-probability N K P

P(X<k) for X a binomial random variable with parameters n &
p. Bionomial expecations for fewer than k events in N trials, each having probability p.

Package

statistics

Source

lhstats.lisp (file)

Function: binomial-ge-probability N K P

The probability of k or more occurances in N events, each with probability p.

Package

statistics

Source

lhstats.lisp (file)

Function: binomial-probability N K P

P(X=k) for X a binomial random variable with parameters n &
p. Binomial expectations for seeing k events in N trials, each having probability p. Use the Poisson approximation if N>100 and P<0.01.

Package

statistics

Source

lhstats.lisp (file)

Function: binomial-probability-ci N P ALPHA &key EXACT?

Confidence intervals on a binomial probability. If a binomial probability of p has been observed in N trials, what is the 1-alpha confidence interval around p? Approximate (using normal theory approximation) when npq >= 10 unless told otherwise

Package

statistics

Source

lhstats.lisp (file)

Function: binomial-test-one-sample P-HAT N P &key TAILS EXACT?

The significance of a one sample test for the equality of an observed probability p-hat to an expected probability p under a binomial distribution with N observations. Use the normal theory approximation if n*p*(1-p) > 10 (unless the exact flag is true).

Package

statistics

Source

lhstats.lisp (file)

Function: binomial-test-one-sample-sse P-ESTIMATED P-NULL &key ALPHA 1-BETA TAILS

Returns the number of subjects needed to test whether an observed probability is significantly different from a particular binomial null hypothesis with a significance alpha and a power 1-beta.

Package

statistics

Source

lhstats.lisp (file)

Function: binomial-test-paired-sse PD PA &key ALPHA 1-BETA TAILS

Sample size estimate for the McNemar (discordant pairs) test. Pd is the projected proportion of discordant pairs among all pairs, and Pa is the projected proportion of type A pairs among discordant pairs. alpha, 1-beta and tails are as binomal-test-two-sample-sse.

Returns the number of individuals necessary; that is twice the number of matched pairs necessary.

Package

statistics

Source

lhstats.lisp (file)

Function: binomial-test-two-sample P-HAT1 N1 P-HAT2 N2 &key TAILS EXACT?

Are the observed probabilities of an event (p-hat1 and p-hat2) in N1/N2 trials different? The normal theory method implemented here. The exact test is Fisher’s contingency table method, below.

Package

statistics

Source

lhstats.lisp (file)

Function: binomial-test-two-sample-sse P1 P2 &key ALPHA SAMPLE-RATIO 1-BETA TAILS

The number of subjects needed to test if two binomial probabilities are different at a given significance alpha and power 1-beta. The sample sizes can be unequal; the p2 sample is sample-sse-ratio * the size of the p1 sample. It can be a one tailed or two tailed test.

Package

statistics

Source

lhstats.lisp (file)

Function: chi-square DOF PERCENTILE

Returns the point which is the indicated percentile in the Chi Square distribution with dof degrees of freedom.

Package

statistics

Source

lhstats.lisp (file)

Function: chi-square-cdf X DOF

Computes the left hand tail area under the chi square distribution under dof degrees of freedom up to X. Adopted from CLASP 1.4.3, http://eksl-www.cs.umass.edu/clasp.html

Package

statistics

Source

lhstats.lisp (file)

Function: chi-square-test-for-trend ROW1-COUNTS ROW2-COUNTS &optional SCORES

This test works on a 2xk table and assesses if there is an increasing or decreasing trend. Arguments are equal sized lists counts. Optionally, provide a list of scores, which represent some numeric attribute of the group. If not provided, scores are assumed to be 1 to k.

Package

statistics

Source

lhstats.lisp (file)

Function: chi-square-test-one-sample VARIANCE N SIGMA-SQUARED &key TAILS

The significance of a one sample Chi square test for the variance of a normal distribution. Variance is the observed variance, N is the number of observations, and sigma-squared is the test variance.

Package

statistics

Source

lhstats.lisp (file)

Function: chi-square-test-rxc CONTINGENCY-TABLE

Takes contingency-table, an RxC array, and returns the significance of the relationship between the row variable and the column variable. Any difference in proportion will cause this test to be significant – consider using the test for trend instead if you are looking for a consistent change.

Package

statistics

Source

lhstats.lisp (file)

Function: choose N K

How may ways to take n things taken k at a time, when order doesn’t matter

Package

statistics

Source

lhstats.lisp (file)

Function: coefficient-of-variation SEQUENCE
Package

statistics

Source

lhstats.lisp (file)

Function: convert-to-standard-normal X MU SIGMA

Convert X from a Normal distribution with mean mu and variance sigma to standard normal

Package

statistics

Source

lhstats.lisp (file)

Function: correlation-coefficient POINTS

just r from linear-regression. Also called Pearson Correlation

Package

statistics

Source

lhstats.lisp (file)

Function: correlation-sse RHO &key ALPHA 1-BETA

Returns the size of a sample necessary to find a correlation of expected value rho with significance alpha and power 1-beta.

Package

statistics

Source

lhstats.lisp (file)

Function: correlation-test-two-sample R1 N1 R2 N2 &key TAILS

Test if two correlation coefficients are different. Users Fisher’s Z test.

Package

statistics

Source

lhstats.lisp (file)

Function: correlation-test-two-sample-on-sequences POINTS1 POINTS2 &key TAILS
Package

statistics

Source

lhstats.lisp (file)

Function: f-significance F-STATISTIC NUMERATOR-DOF DENOMINATOR-DOF &optional ONE-TAILED-P

Adopted from CLASP, but changed to handle F < 1 correctly in the one-tailed case. The ‘f-statistic’ must be a positive number. The degrees of freedom arguments must be positive integers. The ‘one-tailed-p’ argument is treated as a boolean.

This implementation follows Numerical Recipes in C, section 6.3 and the ‘ftest’ function in section 13.4.

Package

statistics

Source

lhstats.lisp (file)

Function: f-test VARIANCE1 N1 VARIANCE2 N2 &key TAILS

F test for the equality of two variances

Package

statistics

Source

lhstats.lisp (file)

Function: false-discovery-correction P-VALUES &key RATE

A multiple testing correction that is less conservative than Bonferroni. Takes a list of p-values and a false discovery rate, and returns the number of p-values that are likely to be good enough to reject the null at that rate. Returns a second value which is the p-value cutoff. See

Benjamini Y and Hochberg Y. "Controlling the false discovery rate: a practical and powerful approach to multiple testing." J R Stat Soc Ser B 57: 289 300, 1995.

Package

statistics

Source

lhstats.lisp (file)

Function: fisher-exact-test CONTINGENCY-TABLE &key TAILS

Fisher’s exact test. Gives a p value for a particular 2x2 contingency table

Package

statistics

Source

lhstats.lisp (file)

Function: fisher-z-transform R

Transforms the correlation coefficient to an approximately normal distribution.

Package

statistics

Source

lhstats.lisp (file)

Function: geometric-mean SEQUENCE &optional BASE
Package

statistics

Source

lhstats.lisp (file)

Function: linear-regression POINTS

Computes the regression equation for a least squares fit of a line to a sequence of points (each a list of two numbers, e.g. ’((1.0 0.1) (2.0 0.2))) and report the intercept, slope, correlation coefficient r, R^2, and the significance of the difference of the slope from 0.

Package

statistics

Source

lhstats.lisp (file)

Function: mcnemars-test A-DISCORDANT-COUNT B-DISCORDANT-COUNT &key EXACT?

McNemar’s test for correlated proportions, used for longitudinal studies. Look only at the number of discordant pairs (one treatment is effective and the other is not). If the two treatments are A and B, a-discordant-count is the number where A worked and B did not, and b-discordant-count is the number where B worked and A did not.

Package

statistics

Source

lhstats.lisp (file)

Function: mean SEQUENCE
Package

statistics

Source

lhstats.lisp (file)

Function: mean-sd-n SEQUENCE

A combined calculation that is often useful. Takes a sequence and returns three values: mean, standard deviation and N.

Package

statistics

Source

lhstats.lisp (file)

Function: median SEQUENCE
Package

statistics

Source

lhstats.lisp (file)

Function: mode SEQUENCE

Returns two values: a list of the modes and the number of times they occur.

Package

statistics

Source

lhstats.lisp (file)

Function: normal-mean-ci MEAN SD N ALPHA

Confidence interval for the mean of a normal distribution

The 1-alpha percent confidence interval on the mean of a normal distribution with parameters mean, sd & n.

Package

statistics

Source

lhstats.lisp (file)

Function: normal-mean-ci-on-sequence SEQUENCE ALPHA

The 1-alpha confidence interval on the mean of a sequence of numbers drawn from a Normal distribution.

Package

statistics

Source

lhstats.lisp (file)

Function: normal-pdf X MU SIGMA

The probability density function (PDF) for a normal distribution with mean mu and variance sigma at point x.

Package

statistics

Source

lhstats.lisp (file)

Function: normal-sd-ci SD N ALPHA

As normal-variance-ci-on-sequence, but a confidence inverval for the standard deviation.

Package

statistics

Source

lhstats.lisp (file)

Function: normal-sd-ci-on-sequence SEQUENCE ALPHA
Package

statistics

Source

lhstats.lisp (file)

Function: normal-variance-ci VARIANCE N ALPHA

The 1-alpha confidence interval on the variance of a sequence of numbers drawn from a Normal distribution.

Package

statistics

Source

lhstats.lisp (file)

Function: normal-variance-ci-on-sequence SEQUENCE ALPHA
Package

statistics

Source

lhstats.lisp (file)

Function: percentile SEQUENCE PERCENT
Package

statistics

Source

lhstats.lisp (file)

Function: permutations N K

How many ways to take n things taken k at a time, when order matters

Package

statistics

Source

lhstats.lisp (file)

Function: phi X

the CDF of standard normal distribution. Adopted from CLASP 1.4.3, see copyright notice at http://eksl-www.cs.umass.edu/clasp.html

Package

statistics

Source

lhstats.lisp (file)

Function: poisson-cumulative-probability MU K

Probability of seeing fewer than K events over a time period when the expected number events over that time is mu.

Package

statistics

Source

lhstats.lisp (file)

Function: poisson-ge-probability MU X

Probability of X or more events when expected is mu.

Package

statistics

Source

lhstats.lisp (file)

Function: poisson-mu-ci X ALPHA

Confidence interval for the Poisson parameter mu

Given x observations in a unit of time, what is the 1-alpha confidence interval on the Poisson parameter mu (= lambda*T)?

Since find-critical-value assumes that the function is monotonic increasing, adjust the value we are looking for taking advantage of reflectiveness.

Package

statistics

Source

lhstats.lisp (file)

Function: poisson-probability MU K

Probability of seeing k events over a time period when the expected number of events over that time is mu.

Package

statistics

Source

lhstats.lisp (file)

Function: poisson-test-one-sample OBSERVED MU &key TAILS APPROXIMATE?

The significance of a one sample test for the equality of an observed number of events (observed) and an expected number mu under the poisson distribution. Normal theory approximation is not that great, so don’t use it unless told.

Package

statistics

Source

lhstats.lisp (file)

Function: random-normal &key MEAN SD

returns a random number with mean and standard-distribution as specified.

Package

statistics

Source

lhstats.lisp (file)

Function: random-pick SEQUENCE

Random selection from sequence

Package

statistics

Source

lhstats.lisp (file)

Function: random-sample N SEQUENCE

Return a random sample of size N from sequence, without replacement. If N is equal to or greater than the length of the sequence, return the entire sequence.

Package

statistics

Source

lhstats.lisp (file)

Function: range SEQUENCE
Package

statistics

Source

lhstats.lisp (file)

Function: round-float X &key PRECISION

Rounds a floating point number to a specified number of digits precision.

Package

statistics

Source

lhstats.lisp (file)

Function: sd SEQUENCE
Package

statistics

Source

lhstats.lisp (file)

Function: sign-test PLUS-COUNT MINUS-COUNT &key EXACT? TAILS

Really just a special case of the binomial one sample test with p = 1/2. The normal theory version has a correction factor to make it a better approximation.

Package

statistics

Source

lhstats.lisp (file)

Function: sign-test-on-sequences SEQUENCE1 SEQUENCE2 &key EXACT? TAILS

Same as sign-test, but takes two sequences and tests whether the entries in one are different (greater or less) than the other.

Package

statistics

Source

lhstats.lisp (file)

Function: spearman-rank-correlation POINTS

Spearman rank correlation computes the relationship between a pair of variables when one or both are either ordinal or have a distribution that is far from normal. It takes a list of points (same format as linear-regression) and returns the spearman rank correlation coefficient and its significance.

Package

statistics

Source

lhstats.lisp (file)

Function: standard-deviation SEQUENCE
Package

statistics

Source

lhstats.lisp (file)

Function: standard-error-of-the-mean SEQUENCE
Package

statistics

Source

lhstats.lisp (file)

Function: t-distribution DOF PERCENTILE

Returns the point which is the indicated percentile in the T distribution with dof degrees of freedom. Adopted from CLASP 1.4.3, http://eksl-www.cs.umass.edu/clasp.html

Package

statistics

Source

lhstats.lisp (file)

Function: t-significance T-STATISTIC DOF &key TAILS

Lookup table in Rosner; this is adopted from CLASP/Numeric Recipes (CLASP 1.4.3), http://eksl-www.cs.umass.edu/clasp.html

Package

statistics

Source

lhstats.lisp (file)

Function: t-test-one-sample X-BAR SD N MU &key TAILS

The significance of a one sample T test for the mean of a normal distribution with unknown variance. X-bar is the observed mean, sd is the observed standard deviation, N is the number of observations and mu is the test mean.

See also t-test-one-sample-on-sequence

Package

statistics

Source

lhstats.lisp (file)

Function: t-test-one-sample-on-sequence SEQUENCE MU &key TAILS

As t-test-one-sample, but calculates the observed values from a sequence of numbers.

Package

statistics

Source

lhstats.lisp (file)

Function: t-test-one-sample-sse MU MU-NULL VARIANCE &key ALPHA 1-BETA TAILS

Returns the number of subjects needed to test whether the mean of a normally distributed sample mu is different from a null hypothesis mean mu-null and variance variance, with alpha, 1-beta and tails as specified.

Package

statistics

Source

lhstats.lisp (file)

Function: t-test-paired D-BAR SD N &key TAILS

The significance of a paired t test for the means of two normal distributions in a longitudinal study. D-bar is the mean difference, sd is the standard deviation of the differences, N is the number of pairs.

Package

statistics

Source

lhstats.lisp (file)

Function: t-test-paired-on-sequences BEFORE AFTER &key TAILS

The significance of a paired t test for means of two normal distributions in a longitudinal study. Before is a sequence of before values, after is the sequence of paired after values (which must be the same length as the before sequence).

Package

statistics

Source

lhstats.lisp (file)

Function: t-test-paired-sse DIFFERENCE-MU DIFFERENCE-VARIANCE &key ALPHA 1-BETA TAILS

Returns the number of subjects needed to test whether the differences with mean difference-mu and variance difference-variance, with alpha, 1-beta and tails as specified.

Package

statistics

Source

lhstats.lisp (file)

Function: t-test-two-sample X-BAR1 SD1 N1 X-BAR2 SD2 N2 &key VARIANCES-EQUAL? VARIANCE-SIGNIFICANCE-CUTOFF TAILS

The significance of the difference of two means (x-bar1 and x-bar2) with standard deviations sd1 and sd2, and sample sizes n1 and n2 respectively. The form of the two sample t test depends on whether the sample variances are equal or not. If the variable variances-equal? is :test, then we use an F test and the variance-significance-cutoff to determine if they are equal. If the variances are equal, then we use the two sample t test for equal variances. If they are not equal, we use the Satterthwaite method, which has good type I error properties (at the loss of some power).

Package

statistics

Source

lhstats.lisp (file)

Function: t-test-two-sample-on-sequences SEQUENCE1 SEQUENCE2 &key VARIANCE-SIGNIFICANCE-CUTOFF TAILS

Same as t-test-two-sample, but providing the sequences rather than the summaries.

Package

statistics

Source

lhstats.lisp (file)

Function: t-test-two-sample-sse MU1 VARIANCE1 MU2 VARIANCE2 &key SAMPLE-RATIO ALPHA 1-BETA TAILS

Returns the number of subjects needed to test whether the mean mu1 of a normally distributed sample (with variance variance1) is different from a second sample with mean mu2 and variance variance2, with alpha, 1-beta and tails as specified. It is also possible to set a sample size ratio of sample 1 to sample 2.

Package

statistics

Source

lhstats.lisp (file)

Function: variance SEQUENCE
Package

statistics

Source

lhstats.lisp (file)

Function: wilcoxon-signed-rank-test DIFFERENCES &optional TAILS

A test on the ranking of positive and negative differences (are the positive differences significantly larger/smaller than the negative ones). Assumes a continuous and symmetric distribution of differences, although not a normal one. This is the normal theory approximation, which is only valid when N > 15.

This test is completely equivalent to the Mann-Whitney test.

Package

statistics

Source

lhstats.lisp (file)

Function: wilcoxon-signed-rank-test-on-sequences SEQUENCE1 SEQUENCE2 &optional TAILS
Package

statistics

Source

lhstats.lisp (file)

Function: z PERCENTILE &key EPSILON

The inverse normal function, P(X<Zu) = u where X is distributed as the standard normal. Uses binary search.

Package

statistics

Source

lhstats.lisp (file)

Function: z-test X-BAR N &key MU SIGMA TAILS

The significance of a one sample Z test for the mean of a normal distribution with known variance.

mu is the null hypothesis mean, x-bar is the observed mean, sigma is the standard deviation and N is the number of observations. If tails is :both, the significance of a difference between x-bar and mu. If tails is :positive, the significance of x-bar is greater than mu, and if tails is :negative, the significance of x-bar being less than mu.

Returns a p value.

Package

statistics

Source

lhstats.lisp (file)

Function: z-test-on-sequence SEQUENCE &key MU SIGMA TAILS
Package

statistics

Source

lhstats.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *critical-values-of-r*
Package

statistics

Source

lhstats.lisp (file)

Special Variable: *critical-values-of-r-two-tailed-column-interpretaion*
Package

statistics

Source

lhstats.lisp (file)

Special Variable: *f0.05*
Package

statistics

Source

lhstats.lisp (file)

Special Variable: *f0.10*
Package

statistics

Source

lhstats.lisp (file)

Special Variable: *q-table*
Package

statistics

Source

lhstats.lisp (file)

Special Variable: *t-cdf-critical-points-table-for-.05*
Package

statistics

Source

lhstats.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Macros

Macro: display &rest L
Package

statistics

Source

lhstats.lisp (file)

Macro: underflow-goes-to-zero &body BODY

Protects against floating point underflow errors and sets the value to 0.0 instead.

Package

statistics

Source

lhstats.lisp (file)

Macro: z/protect EXPR TESTVAR

Macro to protect from division by zero.

Package

statistics

Source

lhstats.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Functions

Function: 2-tailed-correlation-significance N R

We use the first line for anything less than 5, and the last line for anything over 500. Otherwise, find the nearest value (maybe we should interpolate ... too much bother!)

Package

statistics

Source

lhstats.lisp (file)

Function: all-squares AS BS &aux SQUARES
Package

statistics

Source

lhstats.lisp (file)

Function: anova1 D

One way simple ANOVA, from Neter, et al. p677+. Data is give as a list of lists, each one representing a treatment, and each containing the observations.

Package

statistics

Source

lhstats.lisp (file)

Function: anova2 A1B1 A1B2 A2B1 A2B2

Two-Way Anova. (From Misanin & Hinderliter, 1991, p. 367-) This is specialized for four groups of equal n, called by their plot location names: left1 left2 right1 right2.

Package

statistics

Source

lhstats.lisp (file)

Function: anova2r G1 G2

Two way ANOVA with repeated measures on one dimension. From Ferguson & Takane, 1989, p. 359. Data is organized differently for this test. Each group (g1 g2) contains list of all subjects’ repeated measures, and same for B. So, A: ((t1s1g1 t2s1g1 ...) (t1s2g2 t2s2g2 ...) ...) Have to have the same number of test repeats for each subject, and this assumes the same number of subject in each group.

Package

statistics

Source

lhstats.lisp (file)

Function: average-rank VALUE SORTED-VALUES

Average rank calculation for non-parametric tests. Ranks are 1 based, but lisp is 0 based, so add 1!

Package

statistics

Source

lhstats.lisp (file)

Function: beta-incomplete A B X

Adopted from CLASP 1.4.3, http://eksl-www.cs.umass.edu/clasp.html

Package

statistics

Source

lhstats.lisp (file)

Function: binomial-le-probability N K P
Package

statistics

Source

lhstats.lisp (file)

Function: chi-square-1 EXPECTED OBSERVED
Package

statistics

Source

lhstats.lisp (file)

Function: chi-square-2 TABLE
Package

statistics

Source

lhstats.lisp (file)

Function: correlate X Y

Correlation of two sequences, as in Ferguson & Takane, 1989, p. 125. Assumes NO MISSING VALUES!

Package

statistics

Source

lhstats.lisp (file)

Function: cross-mean L &aux K R

Cross mean takes a list of lists, as ((1 2 3) (4 3 2 1) ...) and produces a list with mean and standard error for each VERTICLE entry, so, as: ((2.5 . 1) ...) where the first pair is computed from the nth 1 of all the sublists in the input set, etc. This is useful in some cases of data cruching.

Note that missing data is assumed to be always at the END of lists. If it isn’t, you’ve got to do something previously to interpolate.

Package

statistics

Source

lhstats.lisp (file)

Function: dumplot V &optional SHOW-VALUES

A dumb terminal way of plotting data.

Package

statistics

Source

lhstats.lisp (file)

Function: error-function X

Adopted from CLASP 1.4.3, http://eksl-www.cs.umass.edu/clasp.html

Package

statistics

Source

lhstats.lisp (file)

Function: error-function-complement X

Adopted from CLASP 1.4.3, http://eksl-www.cs.umass.edu/clasp.html

Package

statistics

Source

lhstats.lisp (file)

Function: even-power-of-two? N
Package

statistics

Source

lhstats.lisp (file)

Function: f-score>p-limit? DF1 DF2 F-SCORE LIMITS-TABLE
Package

statistics

Source

lhstats.lisp (file)

Function: factorial NUMBER
Package

statistics

Source

lhstats.lisp (file)

Function: find-critical-value P-FUNCTION P-VALUE &optional X-TOLERANCE Y-TOLERANCE

Adopted from CLASP 1.4.3, http://eksl-www.cs.umass.edu/clasp.html

Package

statistics

Source

lhstats.lisp (file)

Function: gamma-incomplete A X

Adopted from CLASP 1.4.3, http://eksl-www.cs.umass.edu/clasp.html

Package

statistics

Source

lhstats.lisp (file)

Function: gamma-ln X

Adopted from CLASP 1.4.3, http://eksl-www.cs.umass.edu/clasp.html

Package

statistics

Source

lhstats.lisp (file)

Function: harmonic-mean SEQ

See: http://mathworld.wolfram.com/HarmonicMean.html

Package

statistics

Source

lhstats.lisp (file)

Function: histovalues V* &key NBINS

Take a set of values and produce a histogram binned into n groups, so that you can get a report of the distribution of values. There’s a large chance for off-by-one errores here!

Package

statistics

Source

lhstats.lisp (file)

Function: lmean LL

Lmean takes the mean of entries in a list of lists vertically. So: (lmean ’((1 2) (5 6))) -> (3 4) The args have to be the same length.

Package

statistics

Source

lhstats.lisp (file)

Function: max* L &rest LL &aux M
Package

statistics

Source

lhstats.lisp (file)

Function: min* L &rest LL &aux M
Package

statistics

Source

lhstats.lisp (file)

Function: n-random N L &aux R

Select n random sublists from a list, without replacement. This copies the list and then destroys the copy. N better be less than or equal to (length l).

Package

statistics

Source

lhstats.lisp (file)

Function: normalize V

Normalize a vector by dividing it through by subtracting its min and then dividing through by its range (max-min). If the numbers are all the same, this would screw up, so we check that first and just return a long list of 0.5 if so!

Package

statistics

Source

lhstats.lisp (file)

Function: p2 V
Package

statistics

Source

lhstats.lisp (file)

Function: protected-mean L

Computes a mean protected where there will be a divide by zero, and gives us n/a in that case.

Package

statistics

Source

lhstats.lisp (file)

Function: pround N V

Returns a string that is rounded to the appropriate number of digits, but the only thing you can do with it is print it. It’s just a convenience hack for rounding recursive lists.

Package

statistics

Source

lhstats.lisp (file)

Function: regress X Y

Simple linear regression.

Package

statistics

Source

lhstats.lisp (file)

Function: round-up X
Package

statistics

Source

lhstats.lisp (file)

Function: s2 L N
Package

statistics

Source

lhstats.lisp (file)

Function: safe-exp X

Eliminates floating point underflow for the exponential function. Instead, it just returns 0.0d0

Package

statistics

Source

lhstats.lisp (file)

Function: sign X
Package

statistics

Source

lhstats.lisp (file)

Function: sqr A
Package

statistics

Source

lhstats.lisp (file)

Function: standard-error SEQUENCE
Package

statistics

Source

lhstats.lisp (file)

Function: sum L &aux SUM
Package

statistics

Source

lhstats.lisp (file)

Function: t-p-value X DF &optional WARN?
Package

statistics

Source

lhstats.lisp (file)

Function: t1-test VALUES TARGET &optional WARN?

One way t-test to see if a group differs from a numerical mean target value. From Misanin & Hinderliter p. 248.

Package

statistics

Source

lhstats.lisp (file)

Function: t1-value VALUES TARGET
Package

statistics

Source

lhstats.lisp (file)

Function: t2-test L1 L2

T2-test calculates an UNPAIRED t-test.

From Misanin & Hinderliter p. 268. The t-cdf part is inherent in xlispstat, and I’m not entirely sure that it’s really the right computation since it doens’t agree entirely with Table 5 of M&H, but it’s close, so I assume that M&H have round-off error.

Package

statistics

Source

lhstats.lisp (file)

Function: t2-value L1 L2
Package

statistics

Source

lhstats.lisp (file)

Function: testanova2 ()
Package

statistics

Source

lhstats.lisp (file)

Function: tukey-q K DFWG

Finds the Q table for the appopriate K, and then walks BACKWARDS through it (in a kind of ugly way!) to find the appropriate place in the table for the DFwg, and then uses the level (which must be 0.01 or 0.05, indicating the first, or second col of the table) to determine if the Q value reaches significance, and gives us a + or - final result.

Package

statistics

Source

lhstats.lisp (file)

Function: wilcoxon-1 INITIAL-VALUES TARGET

Nonparametric one-sample (signed) rank test (Wilcoxon).

From http://www.graphpad.com/instatman/HowtheWilcoxonranksumtestworks.htm

Package

statistics

Source

lhstats.lisp (file)

Function: x2test ()

Simple Chi-Squares From Clarke & Cooke p. 431; should = ~7.0

Package

statistics

Source

lhstats.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L  
Index Entry  Section

F
File, Lisp, lhstats.asd: The lhstats<dot>asd file
File, Lisp, lhstats/lhstats.lisp: The lhstats/lhstats<dot>lisp file
File, Lisp, lhstats/package.lisp: The lhstats/package<dot>lisp file

L
lhstats.asd: The lhstats<dot>asd file
lhstats/lhstats.lisp: The lhstats/lhstats<dot>lisp file
lhstats/package.lisp: The lhstats/package<dot>lisp file
Lisp File, lhstats.asd: The lhstats<dot>asd file
Lisp File, lhstats/lhstats.lisp: The lhstats/lhstats<dot>lisp file
Lisp File, lhstats/package.lisp: The lhstats/package<dot>lisp file

Jump to:   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   2  
A   B   C   D   E   F   G   H   L   M   N   P   R   S   T   U   V   W   X   Z  
Index Entry  Section

2
2-tailed-correlation-significance: Internal functions

A
all-squares: Internal functions
anova1: Internal functions
anova2: Internal functions
anova2r: Internal functions
average-rank: Internal functions

B
beta-incomplete: Internal functions
bin-and-count: Exported functions
binomial-cumulative-probability: Exported functions
binomial-ge-probability: Exported functions
binomial-le-probability: Internal functions
binomial-probability: Exported functions
binomial-probability-ci: Exported functions
binomial-test-one-sample: Exported functions
binomial-test-one-sample-sse: Exported functions
binomial-test-paired-sse: Exported functions
binomial-test-two-sample: Exported functions
binomial-test-two-sample-sse: Exported functions

C
chi-square: Exported functions
chi-square-1: Internal functions
chi-square-2: Internal functions
chi-square-cdf: Exported functions
chi-square-test-for-trend: Exported functions
chi-square-test-one-sample: Exported functions
chi-square-test-rxc: Exported functions
choose: Exported functions
coefficient-of-variation: Exported functions
convert-to-standard-normal: Exported functions
correlate: Internal functions
correlation-coefficient: Exported functions
correlation-sse: Exported functions
correlation-test-two-sample: Exported functions
correlation-test-two-sample-on-sequences: Exported functions
cross-mean: Internal functions

D
display: Internal macros
dumplot: Internal functions

E
error-function: Internal functions
error-function-complement: Internal functions
even-power-of-two?: Internal functions

F
f-score>p-limit?: Internal functions
f-significance: Exported functions
f-test: Exported functions
factorial: Internal functions
false-discovery-correction: Exported functions
find-critical-value: Internal functions
fisher-exact-test: Exported functions
fisher-z-transform: Exported functions
Function, 2-tailed-correlation-significance: Internal functions
Function, all-squares: Internal functions
Function, anova1: Internal functions
Function, anova2: Internal functions
Function, anova2r: Internal functions
Function, average-rank: Internal functions
Function, beta-incomplete: Internal functions
Function, bin-and-count: Exported functions
Function, binomial-cumulative-probability: Exported functions
Function, binomial-ge-probability: Exported functions
Function, binomial-le-probability: Internal functions
Function, binomial-probability: Exported functions
Function, binomial-probability-ci: Exported functions
Function, binomial-test-one-sample: Exported functions
Function, binomial-test-one-sample-sse: Exported functions
Function, binomial-test-paired-sse: Exported functions
Function, binomial-test-two-sample: Exported functions
Function, binomial-test-two-sample-sse: Exported functions
Function, chi-square: Exported functions
Function, chi-square-1: Internal functions
Function, chi-square-2: Internal functions
Function, chi-square-cdf: Exported functions
Function, chi-square-test-for-trend: Exported functions
Function, chi-square-test-one-sample: Exported functions
Function, chi-square-test-rxc: Exported functions
Function, choose: Exported functions
Function, coefficient-of-variation: Exported functions
Function, convert-to-standard-normal: Exported functions
Function, correlate: Internal functions
Function, correlation-coefficient: Exported functions
Function, correlation-sse: Exported functions
Function, correlation-test-two-sample: Exported functions
Function, correlation-test-two-sample-on-sequences: Exported functions
Function, cross-mean: Internal functions
Function, dumplot: Internal functions
Function, error-function: Internal functions
Function, error-function-complement: Internal functions
Function, even-power-of-two?: Internal functions
Function, f-score>p-limit?: Internal functions
Function, f-significance: Exported functions
Function, f-test: Exported functions
Function, factorial: Internal functions
Function, false-discovery-correction: Exported functions
Function, find-critical-value: Internal functions
Function, fisher-exact-test: Exported functions
Function, fisher-z-transform: Exported functions
Function, gamma-incomplete: Internal functions
Function, gamma-ln: Internal functions
Function, geometric-mean: Exported functions
Function, harmonic-mean: Internal functions
Function, histovalues: Internal functions
Function, linear-regression: Exported functions
Function, lmean: Internal functions
Function, max*: Internal functions
Function, mcnemars-test: Exported functions
Function, mean: Exported functions
Function, mean-sd-n: Exported functions
Function, median: Exported functions
Function, min*: Internal functions
Function, mode: Exported functions
Function, n-random: Internal functions
Function, normal-mean-ci: Exported functions
Function, normal-mean-ci-on-sequence: Exported functions
Function, normal-pdf: Exported functions
Function, normal-sd-ci: Exported functions
Function, normal-sd-ci-on-sequence: Exported functions
Function, normal-variance-ci: Exported functions
Function, normal-variance-ci-on-sequence: Exported functions
Function, normalize: Internal functions
Function, p2: Internal functions
Function, percentile: Exported functions
Function, permutations: Exported functions
Function, phi: Exported functions
Function, poisson-cumulative-probability: Exported functions
Function, poisson-ge-probability: Exported functions
Function, poisson-mu-ci: Exported functions
Function, poisson-probability: Exported functions
Function, poisson-test-one-sample: Exported functions
Function, protected-mean: Internal functions
Function, pround: Internal functions
Function, random-normal: Exported functions
Function, random-pick: Exported functions
Function, random-sample: Exported functions
Function, range: Exported functions
Function, regress: Internal functions
Function, round-float: Exported functions
Function, round-up: Internal functions
Function, s2: Internal functions
Function, safe-exp: Internal functions
Function, sd: Exported functions
Function, sign: Internal functions
Function, sign-test: Exported functions
Function, sign-test-on-sequences: Exported functions
Function, spearman-rank-correlation: Exported functions
Function, sqr: Internal functions
Function, standard-deviation: Exported functions
Function, standard-error: Internal functions
Function, standard-error-of-the-mean: Exported functions
Function, sum: Internal functions
Function, t-distribution: Exported functions
Function, t-p-value: Internal functions
Function, t-significance: Exported functions
Function, t-test-one-sample: Exported functions
Function, t-test-one-sample-on-sequence: Exported functions
Function, t-test-one-sample-sse: Exported functions
Function, t-test-paired: Exported functions
Function, t-test-paired-on-sequences: Exported functions
Function, t-test-paired-sse: Exported functions
Function, t-test-two-sample: Exported functions
Function, t-test-two-sample-on-sequences: Exported functions
Function, t-test-two-sample-sse: Exported functions
Function, t1-test: Internal functions
Function, t1-value: Internal functions
Function, t2-test: Internal functions
Function, t2-value: Internal functions
Function, testanova2: Internal functions
Function, tukey-q: Internal functions
Function, variance: Exported functions
Function, wilcoxon-1: Internal functions
Function, wilcoxon-signed-rank-test: Exported functions
Function, wilcoxon-signed-rank-test-on-sequences: Exported functions
Function, x2test: Internal functions
Function, z: Exported functions
Function, z-test: Exported functions
Function, z-test-on-sequence: Exported functions

G
gamma-incomplete: Internal functions
gamma-ln: Internal functions
geometric-mean: Exported functions

H
harmonic-mean: Internal functions
histovalues: Internal functions

L
linear-regression: Exported functions
lmean: Internal functions

M
Macro, display: Internal macros
Macro, square: Exported macros
Macro, test-variables: Exported macros
Macro, underflow-goes-to-zero: Internal macros
Macro, z/protect: Internal macros
max*: Internal functions
mcnemars-test: Exported functions
mean: Exported functions
mean-sd-n: Exported functions
median: Exported functions
min*: Internal functions
mode: Exported functions

N
n-random: Internal functions
normal-mean-ci: Exported functions
normal-mean-ci-on-sequence: Exported functions
normal-pdf: Exported functions
normal-sd-ci: Exported functions
normal-sd-ci-on-sequence: Exported functions
normal-variance-ci: Exported functions
normal-variance-ci-on-sequence: Exported functions
normalize: Internal functions

P
p2: Internal functions
percentile: Exported functions
permutations: Exported functions
phi: Exported functions
poisson-cumulative-probability: Exported functions
poisson-ge-probability: Exported functions
poisson-mu-ci: Exported functions
poisson-probability: Exported functions
poisson-test-one-sample: Exported functions
protected-mean: Internal functions
pround: Internal functions

R
random-normal: Exported functions
random-pick: Exported functions
random-sample: Exported functions
range: Exported functions
regress: Internal functions
round-float: Exported functions
round-up: Internal functions

S
s2: Internal functions
safe-exp: Internal functions
sd: Exported functions
sign: Internal functions
sign-test: Exported functions
sign-test-on-sequences: Exported functions
spearman-rank-correlation: Exported functions
sqr: Internal functions
square: Exported macros
standard-deviation: Exported functions
standard-error: Internal functions
standard-error-of-the-mean: Exported functions
sum: Internal functions

T
t-distribution: Exported functions
t-p-value: Internal functions
t-significance: Exported functions
t-test-one-sample: Exported functions
t-test-one-sample-on-sequence: Exported functions
t-test-one-sample-sse: Exported functions
t-test-paired: Exported functions
t-test-paired-on-sequences: Exported functions
t-test-paired-sse: Exported functions
t-test-two-sample: Exported functions
t-test-two-sample-on-sequences: Exported functions
t-test-two-sample-sse: Exported functions
t1-test: Internal functions
t1-value: Internal functions
t2-test: Internal functions
t2-value: Internal functions
test-variables: Exported macros
testanova2: Internal functions
tukey-q: Internal functions

U
underflow-goes-to-zero: Internal macros

V
variance: Exported functions

W
wilcoxon-1: Internal functions
wilcoxon-signed-rank-test: Exported functions
wilcoxon-signed-rank-test-on-sequences: Exported functions

X
x2test: Internal functions

Z
z: Exported functions
z-test: Exported functions
z-test-on-sequence: Exported functions
z/protect: Internal macros

Jump to:   2  
A   B   C   D   E   F   G   H   L   M   N   P   R   S   T   U   V   W   X   Z  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*critical-values-of-r*: Internal special variables
*critical-values-of-r-two-tailed-column-interpretaion*: Internal special variables
*f0.05*: Internal special variables
*f0.10*: Internal special variables
*q-table*: Internal special variables
*t-cdf-critical-points-table-for-.05*: Internal special variables

S
Special Variable, *critical-values-of-r*: Internal special variables
Special Variable, *critical-values-of-r-two-tailed-column-interpretaion*: Internal special variables
Special Variable, *f0.05*: Internal special variables
Special Variable, *f0.10*: Internal special variables
Special Variable, *q-table*: Internal special variables
Special Variable, *t-cdf-critical-points-table-for-.05*: Internal special variables

Jump to:   *  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   L   P   S  
Index Entry  Section

L
lhstats: The lhstats system

P
Package, statistics: The statistics package

S
statistics: The statistics package
System, lhstats: The lhstats system

Jump to:   L   P   S