qr-decomposition

Find the Rotation and Skew of a Matrix transformation

谁说胖子不能爱 提交于 2019-11-30 06:58:36
问题 I have the the following Transform Matrix in CSS // rotate the element 60deg element.style.transform = "matrix(0.5,0.866025,-0.866025,0.5,0,0)" And i can find the rotation using this... // where a = [0.710138,0.502055,-0.57735,1,0,0] var rotation = ((180/Math.PI) * Math.atan2( ((0*a[2])+(1*a[3])),((0*a[0])-(1*a[1]))) - 90 console.log(rotation); // ~60 Similarly for skew if... // skew(30deg,-50deg) element.style.transform = "matrix(1,-1.19175,0.57735,1,0,0)" var skewY = ((180/Math.PI) * Math

Multiple regression analysis in R using QR decomposition

試著忘記壹切 提交于 2019-11-30 05:50:29
I am trying to write a function for solving multiple regression using QR decomposition. Input: y vector and X matrix; output: b, e, R^2. So far I`ve got this and am terribly stuck; I think I have made everything way too complicated: QR.regression <- function(y, X) { X <- as.matrix(X) y <- as.vector(y) p <- as.integer(ncol(X)) if (is.na(p)) stop("ncol(X) is invalid") n <- as.integer(nrow(X)) if (is.na(n)) stop("nrow(X) is invalid") nr <- length(y) nc <- NCOL(X) # Householder for (j in seq_len(nc)) { id <- seq.int(j, nr) sigma <- sum(X[id, j]^2) s <- sqrt(sigma) diag_ej <- X[j, j] gamma <- 1.0 /

How to calculate variance of least squares estimator using QR decomposition in R?

♀尐吖头ヾ 提交于 2019-11-29 00:18:16
I'm trying to learn QR decomposition, but can't figure out how to get the variance of beta_hat without resorting to traditional matrix calculations. I'm practising with the iris data set, and here's what I have so far: y<-(iris$Sepal.Length) x<-(iris$Sepal.Width) X<-cbind(1,x) n<-nrow(X) p<-ncol(X) qr.X<-qr(X) b<-(t(qr.Q(qr.X)) %*% y)[1:p] R<-qr.R(qr.X) beta<-as.vector(backsolve(R,b)) res<-as.vector(y-X %*% beta) Thanks for your help! setup (copying in your code) y <- iris$Sepal.Length x <- iris$Sepal.Width X <- cbind(1,x) n <- nrow(X) p <- ncol(X) qr.X <- qr(X) b <- (t(qr.Q(qr.X)) %*% y)[1:p]

How to calculate variance of least squares estimator using QR decomposition in R?

坚强是说给别人听的谎言 提交于 2019-11-27 15:20:28
问题 I'm trying to learn QR decomposition, but can't figure out how to get the variance of beta_hat without resorting to traditional matrix calculations. I'm practising with the iris data set, and here's what I have so far: y<-(iris$Sepal.Length) x<-(iris$Sepal.Width) X<-cbind(1,x) n<-nrow(X) p<-ncol(X) qr.X<-qr(X) b<-(t(qr.Q(qr.X)) %*% y)[1:p] R<-qr.R(qr.X) beta<-as.vector(backsolve(R,b)) res<-as.vector(y-X %*% beta) Thanks for your help! 回答1: setup (copying in your code) y <- iris$Sepal.Length x

Compute projection / hat matrix via QR factorization, SVD (and Cholesky factorization?)

若如初见. 提交于 2019-11-27 02:48:49
问题 I'm trying to calculate in R a projection matrix P of an arbitrary N x J matrix S : P = S (S'S) ^ -1 S' I've been trying to perform this with the following function: P <- function(S){ output <- S %*% solve(t(S) %*% S) %*% t(S) return(output) } But when I use this I get errors that look like this: # Error in solve.default(t(S) %*% S, t(S), tol = 1e-07) : # system is computationally singular: reciprocal condition number = 2.26005e-28 I think that this is a result of numerical underflow and/or