Feb 15, 2013 at 10:21 AM
Edited Feb 15, 2013 at 10:22 AM
I have a certain number of measures. For each datetime I have 1 physic value Xi and N temperature values TKi (K=1...N).
I want to implement a Covariate Adjustement that remove the temperature effect on physic measure.
So I want first to calculate the multiple linear regression between X and TK.
How to obtain it with Meta.Numerics?
I created a MultivariateSample with:
Meta.Numerics.Statistics.MultivariateSample ms = new Meta.Numerics.Statistics.MultivariateSample(Covariates.Length+1);
Foreach datetime I add:
ms.Add(Xi, T1i, T2i, T3i..., TNi)
now I call:
But this don't work with NullReference exception.
My approach isen't correct?
Thank's very much and sorry for my terrible english.
Apr 22, 2015 at 10:01 AM
Edited Apr 22, 2015 at 10:01 AM
I also met a NullReference exception when calling MultivariateSample.LinearRegression, even though such exception should not be raised, according to the documentation.
The cause was that one of my input variables was a constant, hence playing the same role as the intercept parameter (alpha).
A consequence, in the internal implementation (LinearRegression_Internal function), is that the CholeskyDecomposition returns null, which raises the NullReference exception on the following line (which calls CholeskyDecomposition.Solve()).
I guess that, more generally, having non-linearly independent input variables will lead to the same behavior.
Once I found the cause, of course, it was easy to bypass the problem: just remove the constant variable from the MultivariateSample, and then retrieve its weight from the intercept.
One suggestion to the team: throw a more explicit exception rather than the NullReference, and update the documentation accordingly, to quickly guide users towards a solution.