※ 引述《brooky (未够班)》之铭言:
: ※ 引述《Yyh (我爱批踢踢)》之铭言:
: : Thank you! I have solved it :p
: Do you get similar coefficient from SVD and from other methods (like qr)?
: I use
: x ^-1 = v %*% w^-1 %*% t(u)
: coef = x^-1 %*% y
: ############
: using lm
: ############
: (Intercept) x1 x2 x3 x4
: 4.340299e+01 1.400204e-01 1.717815e-01 -4.267582e-01 NA
: x5 x6 x7 x8 x9
: -1.114267e+02 8.469963e+00 -6.853315e-02 -2.800156e+00 2.553855e+00
: x10 x11 x12 x13
: NA NA -8.728223e-03 -8.457266e-02
: ############
: code segment
: ############
: d_minus[d_minus > 1e-07] <- 1/d_minus[d_minus > 1e-07];
: d_minus[d_minus <= 1e-07] <- 0;
: x_minus <- v %*% diag(d_minus) %*% t(u);
: coef <- x_minus %*% y;
: I think I may have misunderstood how SVD works. (?)
I don't see any mistake in your code.@@"
What dataset you used in above result?
lm is lsfit?
if yes, I don't remember I have result with "NA" in any dataset.
: I would appreciate any clarification on this.
: Thanks,