I'm trying to use alglib.lsfitcreatef to do a multivariate regression over 15 parameters and 385 samples.
My code is this:
double epsf = 0; double epsx = 1; int maxits = 0; int info; alglib.lsfitstate state; alglib.lsfitreport rep; double diffstep = 0.0001;
double[] solution = new double[15]; for (int i = 0; i < 15; i++) solution[i] = 1;
alglib.lsfitcreatef(independent_vars, dependent_vars, solution, dependent_vars.Length, solution.Length, solution.Length, diffstep, out state); alglib.lsfitsetcond(state, epsf, epsx, maxits); alglib.lsfitfit(state, Function, null, null); alglib.lsfitresults(state, out info, out solution, out rep);
In this case, N = 385, M = 15 and K = 15. As you can see, I'm creating an initial solution of 1 for each parameter, and then I use lsfitcreatef and lsfitfit to solve the linear regression. However, the output solution is always the same as the initial -- every parameter is 1.
If I set K = 1, with everything else unchanged, I get a proper solution for the first parameter -- 9194173.1672351. If I set K = 2, I get 1 for both parameters.
Am I doing something wrong?
Thanks.
|