NMath User's Guide

TOC | Previous | Next | Index

42.5 Significance of Parameters (.NET, C#, CSharp, VB, Visual Basic, F#)

Instances of class LinearRegressionParameter test statistical hypothesis about individual parameters in a LinearRegression.

Creating Linear Regression Parameter Objects

You can construct a LinearRegressionParameter from a LinearRegression object and the index of the parameter you wish to test. For instance, this code creates a test object for the third parameter:

Code Example – C# linear regression

var param = new LinearRegressionParameter( lr, 2 );

Code Example – VB linear regression

Dim Param As New LinearRegressionParameter(LR, 2)

Alternatively, you can get an array of test objects for all parameters in a linear regression using the ParameterEstimates property on LinearRegression:

Code Example – C# linear regression

LinearRegressionParameter[] params = lr.ParameterEstimates;

Code Example – VB linear regression

Dim Params() As LinearRegressionParameter = LR.ParameterEstimates

Properties Linear Regression Parameters

Class LinearRegressionParameter provides the following properties:

Value gets the value of the parameter.

StandardError gets the standard error of the parameter.

ParameterIndex gets the index of the parameter in the linear regresssion.

Hypothesis Tests

Class LinearRegressionParameter provides the following methods for testing statistical hypotheses regarding parameter values:

TStatisticPValue() returns the p-value for a two-sided t test with the null hypothesis that the parameter is equal to a given test value, versus the alternative hypothesis that it is not.

TStatistic() returns the value of the t statistic for the null hypothesis that the parameter value is equal to a given test value.

TStatisticCriticalValue() gets the critical value for the t-statistic for a given alpha level.

ConfidenceInterval() returns a confidence interval for the parameter for a given alpha level.

For example, this code tests whether the fifth parameter in a model is significantly different than zero:

Code Example – C# linear regression

var param = new LinearRegressionParameter( lr, 4 );
double tstat = param.TStatistic( 0.0 );
double pValue = param.TStatisticPValue( 0.0 );
double criticalValue = param.TStatisticCriticalValue( 0.05 );
Interval confidenceInterval = param.ConfidenceInterval( 0.05 );

Code Example – VB linear regression

Dim Param As New LinearRegressionParameter(LR, 4)
Dim TStat As Double = Param.TStatistic(0.0)
Dim PValue As Double = Param.TStatisticPValue(0.0)
Dim CriticalValue As Double = Param.TStatisticCriticalValue(0.05)
Dim ConfidenceInterval As Interval = Param.ConfidenceInterval(0.05)

Updating Linear Regression Parameters

The SetRegression() method updates the regression and parameter index in a parameter test object:

Code Example – C# linear regression

param.SetRegression( lr, 6 );

Code Example – VB linear regression

Param.SetRegression(LR, 6)

Top

Top