Libraries.Compute.Statistics.Tests.Regression Documentation

This class conducts an Ordinary Least Squares regression on a DataFrame. By default, an intercept is calculated and included in the model. More information about this kind of statistical test can be found at here: https://en.wikipedia.org/wiki/Ordinary_least_squares. It was partially adapted from the same model in Apache Commons, but was expanded upon to simplify the library and add a variety of helper actions that were missing. More information about this class can be found on its documentation page: https://commons.apache.org/proper/commons-math/javadocs/api-3.6/org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html

Example Code

use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Tests.Regression

DataFrame frame
frame:Load("data.csv")
frame:AddSelectedColumn(0)
frame:AddSelectedFactorRange(1,3)

Regression regression = frame:RegressionOnSelected()
output regression:GetSummary()

Inherits from: Libraries.Compute.Statistics.DataFrameCalculation, Libraries.Language.Object

Actions Documentation

Calculate(Libraries.Compute.Statistics.DataFrame frame)

Total sum of squares: index for each dependent variable

Parameters

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetAdjustedEffectSize()

Returns the total adjusted effect size, in statistics typically termed adjusted R^2 (R-squared). This action returns 0 unless the regression has been calculated.

Return

number: The adjusted R^2 if the regression is calculated

GetAdjustedEffectSizeVector()

Returns the total adjusted effect size, in statistics typically termed adjusted R^2 (R-squared). This action returns 0 unless the regression has been calculated.

Return

Libraries.Compute.Vector: The adjusted R^2 if the regression is calculated

GetCoefficientMatrix()

Returns the total beta coefficients. This action returns 0 unless the regression has been calculated.

Return

Libraries.Compute.Matrix: The beta coefficients

GetCoefficientProbabilityValueMatrix()

Returns the probability values for the beta coefficients

Return

Libraries.Compute.Matrix:

GetCoefficientProbabilityValues()

Returns the probability values for the beta coefficients

Return

Libraries.Compute.Vector:

GetCoefficientStandardErrorMatrix()

Returns the standard errors for the beta coefficients

Return

Libraries.Compute.Matrix:

GetCoefficientStandardErrors()

Returns the standard errors for the beta coefficients

Return

Libraries.Compute.Vector:

GetCoefficientTestStatisticMatrix()

Returns the test statistics for the beta coefficients

Return

Libraries.Compute.Matrix:

GetCoefficientTestStatistics()

Returns the test statistics for the beta coefficients

Return

Libraries.Compute.Vector:

GetCoefficients()

Returns the total beta coefficients. This action returns 0 unless the regression has been calculated.

Return

Libraries.Compute.Vector: The beta coefficients

GetCriticalValue()

Outdated, this returns the test statistic not the critical value at alpha.

Return

number:

GetDenominatorDegreesOfFreedom()

This calculates the degrees of freedom of the denominator in the F-ratio. It is equivalent to the number of rows in the matrix - the number of columns

Return

number: The number of rows in the matrix - the number of columns.

GetEffectSize()

Returns the total effect size, in statistics typically termed R^2 (R-squared). This action returns 0 unless the regression has been calculated.

Return

number: The R^2 if the regression is calculated

GetEffectSizeVector()

Returns the total effect size, in statistics typically termed R^2 (R-squared). This action returns 0 unless the regression has been calculated.

Return

Libraries.Compute.Vector: The R^2 if the regression is calculated

GetEquation()

This action return the linear equation for the regression model.

Return

text:

GetEquation(integer index)

This action return the linear equation for the regression model.

Parameters

  • integer index

Return

text:

GetFormalNumericalResult()

This action summarizes the result and places it into formal academic language, in APA format. For more information: https://apastyle.apa.org/instructional-aids/numbers-statistics-guide.pdf

Return

text:

GetFormalNumericalResult(integer index)

This action summarizes the result and places it into formal academic language, in APA format. For more information: https://apastyle.apa.org/instructional-aids/numbers-statistics-guide.pdf

Parameters

  • integer index

Return

text:

GetFormalSummary()

This action summarizes the result and places it into formal academic language, in APA format.

Return

text:

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetNumeratorDegreesOfFreedom()

This calculates the degrees of freedom of the numerator in the F-ratio. It is equivalent to the number of columns in the matrix - 1

Return

number: The number of columns in the matrix - 1

GetProbabilityValue()

Returns the probability value

Return

number:

GetProbabilityValueVector()

Returns the probability value

Return

Libraries.Compute.Vector:

GetRegressionDegreesOfFreedom()

This calculates the degrees of freedom of the numerator in the F-ratio. It is equivalent to the number of columns in the matrix - 1

Return

number: The number of columns in the matrix - 1

GetRegressionSumOfSquares()

Returns the regression/model sum of squares. This action returns 0 unless the regression has been calculated.

Return

number: The regression (model) sum of squares

GetRegressionSumOfSquaresVector()

Returns the regression/model sum of squares. This action returns 0 unless the regression has been calculated.

Return

Libraries.Compute.Vector: The regression (model) sum of squares

GetResidualDegreesOfFreedom()

This calculates the degrees of freedom of the denominator in the F-ratio. It is equivalent to the number of rows in the matrix - the number of columns

Return

number: The number of rows in the matrix - the number of columns.

GetResidualHistogram()

Returns the histogram chart of the residuals. Each column(series) will show each dependent variable's residuals

Return

Libraries.Interface.Controls.Charts.Chart:

GetResidualMatrix()

Returns the residuals. This action returns 0 unless the regression has been calculated.

Return

Libraries.Compute.Matrix: The residuals

GetResidualStandardError()

Returns the standard error for the residuals

Return

number:

GetResidualStandardErrorVector()

Returns the standard error for the residuals

Return

Libraries.Compute.Vector:

GetResidualSumOfSquares()

Returns the total residual sum of squares. This action returns 0 unless the regression has been calculated.

Return

number: The residual sum of squares

GetResidualSumOfSquaresVector()

Returns the total residual sum of squares. This action returns 0 unless the regression has been calculated.

Return

Libraries.Compute.Vector: The residual sum of squares

GetResiduals()

Returns the residuals. This action returns 0 unless the regression has been calculated.

Return

Libraries.Compute.Vector: The residuals

GetSignificanceLevel()

P-Value: index for each dependent variable

Return

number:

GetStatisticalFormatting()

GetSummary()

This action summarizes the result and lists it informally.

Return

text:

GetTestStatistic()

Returns the test statistic

Return

number:

GetTestStatisticVector()

Returns the test statistic

Return

Libraries.Compute.Vector:

GetTotalSumOfSquares()

Returns the total sum of squares. This action returns 0 unless the regression has been calculated.

Return

number: The total sum of squares

GetTotalSumOfSquaresVector()

Returns the total sum of squares. This action returns 0 unless the regression has been calculated.

Return

Libraries.Compute.Vector: The total sum of squares

HasIntercept()

Returns whether or not this regression includes an intercept.

Return

boolean:

Predict(Libraries.Compute.Statistics.DataFrame frame)

Outdated, this returns the test statistic not the critical value at alpha.

Parameters

Return

Libraries.Compute.Statistics.Predictions.RegressionPrediction:

SetHasIntercept(boolean hasIntercept)

Sets whether or not this regression includes an intercept.

Parameters

  • boolean hasIntercept

SetSignificanceLevel(number significanceLevel)

Sets the significance level of the test (default is 0.05).

Parameters

  • number significanceLevel: the significance level between 0 and 1.

SetStatisticalFormatting(Libraries.Compute.Statistics.Reporting.StatisticsFormatting formatting)

Regression sum of squares: index for each dependent variable

Parameters