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

New Post: Multiple Linear regression in C#

$
0
0
I am having issues using Math.NET for Multiple Linear regression, I have 36 Independent variables and 1 dependent variable, so I am not sure how to set up the matrix to run the Linear regression. I would also like to point out that I am new to Math.Net but have been using C# for some time now. I do however use SPSS and SYSTAT daily to create regression by hand. I am looking for a way to automate this process.

Thanks!

A matrix that I am trying to create would be:
    var xdata = new double[,] { { 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, 
    { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 
    { 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 }, 
    { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }, 
    { 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } };

    var ydata = new double[] { 5, 4, 7, 6, 6, 7 
    Vector<double> p = MathNet.Numerics.LinearRegression.MultipleRegression.NormalEquations(xdata, ydata);
The 0,1 represent the 36 independent variables and the yData represents the dependent variables. Is this correct I cannot get it to run correctly.

The line: Vector<double> p = MathNet.Numerics.LinearRegression.MultipleRegression.NormalEquations(xdata, ydata);
does not seem to like the data.

Viewing all articles
Browse latest Browse all 971

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>