dgelsy question
Hello,
I am just learning to use LAPACK for linear regression problems.
I am trying to solve the following problem--
Find x so that the L2 norm ||Ax-b|| is minimized; and the problem data is,
A is a matrix with 3 columns and 4 rows:
A = [1 1 17; 1 2 18; 1 3 19; 1 4 20]
b is a vector with 1 column and 4 rows:
b = [18.75715 18.83939 18.91538 18.98599]
Since this is problem where some columns in A are correlated, I am using the DGELSY subroutine to compute x, with a value of RCOND = 9e-14.
This routine DGELSY returns the matrix rank as 2, but the x array returned is [0.1401 -1.0827 1.1589]. I was wondering if this is correct. I thought that if this routine returns a rank of 2, then only 2 of the 3 columns in A will have non-zero values; but here all three columns have non-zero x-values. Also, the standard errors that I get from this reported solution are [4.68e+13 1.07e-3 5.6e-5]. I am a bit suspicious on the huge standard error value for the first variable.
Solving this same problem in Matlab (using lscov) gives much different results. I get,
x = [0 -1.09149 1.16774], and standard errors as
[0 2.13125e-3 3.14922e-4].
Is there something that I am doing incorrectly? Any feedback would be greatly appreciated.
Thanks.
I am just learning to use LAPACK for linear regression problems.
I am trying to solve the following problem--
Find x so that the L2 norm ||Ax-b|| is minimized; and the problem data is,
A is a matrix with 3 columns and 4 rows:
A = [1 1 17; 1 2 18; 1 3 19; 1 4 20]
b is a vector with 1 column and 4 rows:
b = [18.75715 18.83939 18.91538 18.98599]
Since this is problem where some columns in A are correlated, I am using the DGELSY subroutine to compute x, with a value of RCOND = 9e-14.
This routine DGELSY returns the matrix rank as 2, but the x array returned is [0.1401 -1.0827 1.1589]. I was wondering if this is correct. I thought that if this routine returns a rank of 2, then only 2 of the 3 columns in A will have non-zero values; but here all three columns have non-zero x-values. Also, the standard errors that I get from this reported solution are [4.68e+13 1.07e-3 5.6e-5]. I am a bit suspicious on the huge standard error value for the first variable.
Solving this same problem in Matlab (using lscov) gives much different results. I get,
x = [0 -1.09149 1.16774], and standard errors as
[0 2.13125e-3 3.14922e-4].
Is there something that I am doing incorrectly? Any feedback would be greatly appreciated.
Thanks.