Skip to content

Commit

Permalink
drop independent vars with zero variance after transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
daroczig committed Aug 28, 2014
1 parent a4ec71c commit 70c024f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/basic-models.R
Expand Up @@ -17,6 +17,12 @@ OLSonTransformation <- function(mx, my, transformation) {
} else {
mx <- sapply(4:ncol(mx), function(i) transformation(m = mx[, c(1:3, i)]))
}
if (ncol(mx) > 4) {
na <- which(apply(mx, 2, var) == 0)
if (length(na) > 0) {
mx[, na] <- NA
}
}
solve(t(mx) %*% as.matrix(mx)) %*% t(mx) %*% as.matrix(my)
}

Expand Down

0 comments on commit 70c024f

Please sign in to comment.