Weighted Multidim Regression: Fit.MultiDimWeighted


(Vladimir) #1

Hello, guys.
I need to regress 2D weighted sample like this:

(X11, X12) -> Y1, Weight1
(X21, X22) -> Y2, Weight2

(XN1, XN2) ->YN, WeightN.

into linear surface with parameters: a0 + b1 * x1 + b2 * x2

Pretty standard procedure.

When I use

double[] p = MultipleRegression.QR(
new[] { new[] { 1.0, 4.0 }, new[] { 2.0, 5.0 }, new[] { 3.0, 2.0 } },
new[] { 15.0, 20, 10 },
intercept: true);

I get:

  •   p	{double[3]}	double[]
      [0]	-1.2500000000000282
      [1]	1.2500000000000049	
      [2]	3.7500000000000049	
    

Alright. Three parameters.

But when I use weighted one,

var p = Fit.MultiDimWeighted(
new[] { new[] { 1.0, 4.0 }, new[] { 2.0, 5.0 }, new[] { 3.0, 2.0 } },
new[] { 15.0, 20, 10 }, new[] { 1.0, 2.0, 3.0 });

I get:

  •   p	{double[2]}	double[]
      [0]	0.94827586206896386	double
      [1]	3.591954022988507	double
    

Only two parameters. What am I missing?

Thank you.


(Vladimir) #2

OK, guys, I think, I have found the issue: in your code

I don’t know how to use git sorry:(