Attachment "mvlr.man.txt" to
ticket [1663970fff]
added by
erickb
2007-02-28 17:33:49.
mvlinreg 1.0
NAME
----
mvlinreg - Multivariate linear regression
SYNOPSIS
--------
mvlinreg::tstat dof ?alpha?
mvlinreg::wls wt1 {y1 x11 x12 ... x1N} wt2 {y2 x21 x22 ... x2N} ...
mvlinreg::ols {y1 x11 x12 ... x1N} {y2 x21 x22 ... x2N} ...
DESCRIPTION
-----------
The mvlinreg package requires
::math::linearalgebra 1.0
::math::statistics 0.1.1
The mvlinreg package provides procedures for doing ordinary least
squares (OLS) and weighted least squares (WLS) linear regression.
It also provides a procedure for calculating the value of the
t-statistic for the specified number of degrees of freedom that is
required to demonstrate a given level of significance.
PROCEDURES
----------
::mvlinreg::tstat dof ?alpha?
Returns the value of the t-distribution t* satisfying
P(t*) = 1 - alpha/2
P(-t*) = alpha/2
for the number of degrees of freedom dof.
Given a sample of normally-distributed data x, with an
estimate xbar for the mean and sbar for the standard deviation,
the alpha confidence interval for the estimate of the mean can
be calculated as
( xbar - t* sbar , xbar + t* sbar)
The return values from this procedure can be compared to
an estimated t-statistic to determine whether the estimated
value of a parameter is significantly different from zero at
the given confidence level.
::mvlinreg::wls wt1 {y1 x11 x12 ... x1N} wt2 {y2 x21 x22 ... x2N} ...
Carries out a weighted least squares linear regression for
the data points provided, with weights assigned to each point.
The linear model is of the form
y = b0 + b1 * x1 + b2 * x2 ... + bN * xN + error
and each point satisfies
yi = b0 + b1 * xi1 + b2 * xi2 + ... + bN * xiN + Residual_i
The procedure returns a list with the following elements:
* The r-squared statistic
* The adjusted r-squared statistic
* A list containing the estimated coefficients b1, ... bN, b0
(The constant b0 comes last in the list.)
* A list containing the standard errors of the coefficients
* A list containing the 95% confidence bounds of the coefficients,
with each set of bounds returned as a list with two values
::mvlinreg::ols {y1 x11 x12 ... x1N} {y2 x21 x22 ... x2N} ...
Carries out an ordinary least squares linear regression for
the data points provided.
This procedure simply calls ::mvlinreg::wls with the weights
set to 1.0, and returns the same information.
EXAMPLE
-------
# Store the value of the unicode value for the "+/-" character
set pm "\u00B1"
# Provide some data
set data {{-.67 14.18 60.03 -7.5} \
{36.97 15.52 34.24 14.61} \
{-29.57 21.85 83.36 -7.} \
{-16.9 11.79 51.67 -6.56} \
{14.09 16.24 36.97 -12.84} \
{31.52 20.93 45.99 -25.4} \
{24.05 20.69 50.27 17.27} \
{22.23 16.91 45.07 -4.3} \
{40.79 20.49 38.92 -.73} \
{-10.35 17.24 58.77 18.78}}
# Call the ols routine
set results [eval mvlinreg::ols $data]
# Pretty-print the results
puts "R-squared: [lindex $results 0]"
puts "Adj R-squared: [lindex $results 1]"
puts "Coefficients $pm s.e. -- \[95% confidence interval\]:"
foreach val [lindex $results 2] se [lindex $results 3] bounds [lindex $results 4] {
set lb [lindex $bounds 0]
set ub [lindex $bounds 1]
puts " $val $pm $se -- \[$lb to $ub\]"
}
SEE ALSO
--------
::math::statistics