MultipleLinearRegression Class 
Namespace: Accord.Statistics.Models.Regression.Linear
[SerializableAttribute] public class MultipleLinearRegression : TransformBase<double[], double>, ILinearRegression, IFormattable, ICloneable
The MultipleLinearRegression type exposes the following members.
Name  Description  

MultipleLinearRegression 
Initializes a new instance of the MultipleLinearRegression class.
 
MultipleLinearRegression(Int32)  Obsolete.
Creates a new Multiple Linear Regression.
 
MultipleLinearRegression(Int32, Boolean)  Obsolete.
Creates a new Multiple Linear Regression.
 
MultipleLinearRegression(Int32, Double)  Obsolete.
Creates a new Multiple Linear Regression.

Name  Description  

Coefficients  Obsolete.
Gets the coefficients used by the regression model. If the model
contains an intercept term, it will be in the end of the vector.
 
HasIntercept  Obsolete.
Gets whether this model has an additional intercept term.
 
Inputs  Obsolete.
Gets the number of inputs for the regression model.
 
Intercept 
Gets or sets the intercept value for the regression.
 
NumberOfInputs 
Gets the number of inputs accepted by the model.
(Overrides TransformBaseTInput, TOutputNumberOfInputs.)  
NumberOfOutputs 
Gets the number of outputs generated by the model.
(Inherited from TransformBaseTInput, TOutput.)  
NumberOfParameters 
Gets the number of parameters in this model (equals the NumberOfInputs + 1).
 
Weights 
Gets or sets the linear weights of the regression model. The
intercept term is not stored in this vector, but is instead
available through the Intercept property.

Name  Description  

Clone 
Creates a new object that is a copy of the current instance.
 
CoefficientOfDetermination 
Gets the coefficient of determination, as known as R² (rsquared).
 
Compute(Double)  Obsolete.
Computes the Multiple Linear Regression for an input vector.
 
Compute(Double)  Obsolete.
Computes the Multiple Linear Regression for input vectors.
 
Equals  Determines whether the specified object is equal to the current object. (Inherited from Object.)  
Finalize  Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)  
FromCoefficients  Obsolete.
Creates a new linear regression from the regression coefficients.
 
FromData 
Creates a new linear regression directly from data points.
 
GetConfidenceInterval 
Gets the confidence interval for an input point.
 
GetDegreesOfFreedom 
Gets the degrees of freedom when fitting the regression.
 
GetHashCode  Serves as the default hash function. (Inherited from Object.)  
GetPredictionInterval 
Gets the prediction interval for an input point.
 
GetPredictionStandardError 
Gets the standard error of the prediction for a particular input vector.
 
GetStandardError(Double, Double) 
Gets the overall regression standard error.
 
GetStandardError(Double, Double, Double) 
Gets the standard error of the fit for a particular input vector.
 
GetStandardErrors 
Gets the standard error for each coefficient.
 
GetType  Gets the Type of the current instance. (Inherited from Object.)  
MemberwiseClone  Creates a shallow copy of the current Object. (Inherited from Object.)  
Regress(Double, Double)  Obsolete.
Performs the regression using the input vectors and output
data, returning the sum of squared errors of the fit.
 
Regress(Double, Double, Boolean)  Obsolete.
Performs the regression using the input vectors and output
data, returning the sum of squared errors of the fit.
 
Regress(Double, Double, Double, Boolean)  Obsolete.
Performs the regression using the input vectors and output
data, returning the sum of squared errors of the fit.
 
ToString 
Returns a System.String representing the regression.
(Overrides ObjectToString.)  
ToString(String, IFormatProvider) 
Returns a String that represents this instance.
 
Transform(TInput) 
Applies the transformation to a set of input vectors,
producing an associated set of output vectors.
(Inherited from TransformBaseTInput, TOutput.)  
Transform(Double) 
Applies the transformation to an input, producing an associated output.
(Overrides TransformBaseTInput, TOutputTransform(TInput).)  
Transform(TInput, TOutput) 
Applies the transformation to an input, producing an associated output.
(Inherited from TransformBaseTInput, TOutput.) 
Name  Description  

HasMethod 
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)  
ToT  Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)  
ToT  Overloaded.
Converts an object into another type, irrespective of whether
the conversion can be done at compile time or not. This can be
used to convert generic types to numeric types during runtime.
(Defined by Matrix.) 
In multiple linear regression, the model specification is that the dependent variable, denoted y_i, is a linear combination of the parameters (but need not be linear in the independent x_i variables). As the linear regression has a closed form solution, the regression coefficients can be computed by calling the Regress(Double, Double) method only once.
The following example shows how to fit a multiple linear regression model to model a plane as an equation in the form ax + by + c = z.
// We will try to model a plane as an equation in the form // "ax + by + c = z". We have two input variables (x and y) // and we will be trying to find two parameters a and b and // an intercept term c. // We will use Ordinary Least Squares to create a // linear regression model with an intercept term var ols = new OrdinaryLeastSquares() { UseIntercept = true }; // Now suppose you have some points double[][] inputs = { new double[] { 1, 1 }, new double[] { 0, 1 }, new double[] { 1, 0 }, new double[] { 0, 0 }, }; // located in the same Z (z = 1) double[] outputs = { 1, 1, 1, 1 }; // Use Ordinary Least Squares to estimate a regression model MultipleLinearRegression regression = ols.Learn(inputs, outputs); // As result, we will be given the following: double a = regression.Weights[0]; // a = 0 double b = regression.Weights[1]; // b = 0 double c = regression.Intercept; // c = 1 // This is the plane described by the equation // ax + by + c = z => 0x + 0y + 1 = z => 1 = z. // We can compute the predicted points using double[] predicted = regression.Transform(inputs); // And the squared error loss using double error = new SquareLoss(outputs).Loss(predicted);