Skip to content

Commit

Permalink
fix normal equations
Browse files Browse the repository at this point in the history
  • Loading branch information
go-ski committed Aug 28, 2016
1 parent f11920e commit 228576b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions demo/matrix.r
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,18 @@ comm.print(coefs)
comm.print(names(beta))
a <- deltime(a, "lm.fit:")

beta.coef <- solve(crossprod(xd_mm), crossprod(xd_mm, yd))
xtx <- crossprod(xd_mm)
xty <- crossprod(xd_mm, yd)

beta.coef <- solve(xtx, xty)
beta <- as.matrix(beta.coef)
rownames(beta) <- colnames_x_mm
comm.print(beta)
a <- deltime(a, "solve crossprod:")

xsvd <- svd(xx)
xsvd <- svd(xd_mm)
comm.print(xsvd$d)
a <- deltime(a, "svd xx:")
a <- deltime(a, "svd xd_mm:")


a <- deltime(a0, "T Total time:")
Expand Down

0 comments on commit 228576b

Please sign in to comment.