resid.bayes
By tholscla on Sat, 11/02/2013 - 20:41
Fitted values of a regression are used to obtain residuals. Residuals are created for every draw of the posterior.
#input: X (no as.factors allowed)
#output: residual values - N by n matrix
bayes.resid=function(reg2,X,y)
{ yy=matrix(y,nrow(reg2),length(y), byrow=T)
residval=yy-t(X%*%t(reg2[,1:(ncol(reg2)-1)]))
residval
}
### Example: need a lm.bayes() object called reg2
resid2=bayes.resid(reg2, X, y)