Quantcast
Channel: Math.NET Numerics - Math.NET
Viewing all articles
Browse latest Browse all 224

Residuals multiple linear regression OLS; partial correlation

$
0
0

@GerS wrote:

How can I get the residuals of a multiple linear regression with OLS?

In Java (Apache.Common.Math3) there is the function OLS.estimateResiduals() after the input OLS.newSampleData with a one dimensional array, the variable nobs and nvars). I would like to use a similar function in C#.

For a partial correlation I would like to get the residues of
regression 1 - y values and x1 values and
regression 2 - y values and x2 values and
using pearson to do a correlaton between the two residual arrays.

Each multiple regression has a one dimensional x array, not a two dimensional x array.

How can I achive that with Math.net?

The description from
https://commons.apache.org/proper/commons-math/javadocs/api-3.6/org/apache/commons/math3/stat/regression/OLSMultipleLinearRegression.html

public void newSampleData(double[] data, int nobs, int nvars)

Loads model x and y sample data from a flat input array, overriding any previous sample.

Assumes that rows are concatenated with y values first in each row. For example, an input data array containing the sequence of values (1, 2, 3, 4, 5, 6, 7, 8, 9) with nobs = 3 and nvars = 2 creates a regression dataset with two independent variables, as below:

y x[0] x[1]

1 2 3
4 5 6
7 8 9

Posts: 2

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 224

Trending Articles