Scott Craner - 1 year ago 158

Vb.net Question

So I am trying to use math.net in vb.net. I have copied the c# excerpt from the website and tried to convert it to vb.net. I have gotten to this point:

`Dim m = Matrix(Of Double).Build.DenseOfArray({{1.0, 4.0}, {2.0, 5.0}, {3.0, 2.0}})`

Dim y = Vector(Of Double).Build.DenseOfArray({15, 20, 10})

Dim p = MultipleRegression.NormalEquations(m, y, True)

Dim a = p(0)

Dim b = p(1)

Dim c = p(2)

it is not liking the multipleregression line and I do not know why.

Any help would be appreciated

Answer Source

The overloads with a boolean intercept parameter currently accept arrays only, not matrices (since you usually have matrices already prepared in the right shape).

Add intercept manually:

```
Dim m = Matrix(Of Double).Build.DenseOfArray({{1.0, 1.0, 4.0}, {1.0, 2.0, 5.0}, {1.0, 3.0, 2.0}})
Dim y = Vector(Of Double).Build.DenseOfArray({15, 20, 10})
Dim p = MultipleRegression.NormalEquations(m,y)
Dim a = p(0)
Dim b = p(1)
Dim c = p(2)
```

Or in code:

```
Dim m = Matrix(Of Double).Build.DenseOfArray({{1.0, 4.0}, {2.0, 5.0}, {3.0, 2.0}})
Dim y = Vector(Of Double).Build.DenseOfArray({15, 20, 10})
' add intercept
Dim mi = m.InsertColumn(0, Vector(Of Double).Build.Dense(m.RowCount, 1.0))
Dim p = MultipleRegression.NormalEquations(mi,y)
Dim a = p(0)
Dim b = p(1)
Dim c = p(2)
```