Created
November 12, 2015 23:07
-
-
Save explodecomputer/6940870eb190b7a77b16 to your computer and use it in GitHub Desktop.
Prediction using absolute values vs positive and negative values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m <- 100 | |
n <- 100 | |
eff <- rnorm(m) | |
x <- matrix(rbinom(m*n,2,0.5), n, m) | |
yhat <- x %*% eff | |
index <- sign(eff) == -1 | |
eff1 <- abs(eff) | |
x1 <- x | |
for(i in 1:ncol(x)) | |
{ | |
if(index[i]) | |
{ | |
x1[,i] <- 2 - x[, i] | |
} | |
} | |
yhat1 <- x1 %*% eff1 | |
plot(yhat ~ yhat1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment