Skip to content

Instantly share code, notes, and snippets.

@explodecomputer
Created November 12, 2015 23:07
Show Gist options
  • Save explodecomputer/6940870eb190b7a77b16 to your computer and use it in GitHub Desktop.
Save explodecomputer/6940870eb190b7a77b16 to your computer and use it in GitHub Desktop.
Prediction using absolute values vs positive and negative values
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