transf_ function(model, C=0, plotit=F, labs=c(rep("d",model$rows[1]), rep("c",sum(model$ptab.len) - model$rows[1]), rep("p",dim(model$X)[1] - sum(model$ptab.len))) ) { X_ model$X rX1_ model$rows[1] rX1.1_ sum(model$ptab.len) rX_ dim(X)[1] e_ as.matrix(model$mean.theta) yhat_ X %*% e + C E_ model$Y - yhat - C sE_ as.vector(E * model$Ghe) svX_ svd(model$X * model$Ghe) V_ svX$u %*% t(svX$u) yhat_ yhat[1:rX1] if (any(yhat <= 0)) stop("\nnegative fitted values, choose C>0?") G_ as.matrix(c(yhat*log(yhat) - yhat + 1, rep(0, rX - rX1))) * model$Ghe avtx_ as.vector((diag(rX) - V) %*% G) fit.avtx_ lsfit(avtx,sE) if(plotit) { plot(avtx, sE, xlab = "Andrews added variable for transformation", ylab = "Scaled residuals", type="n") text(avtx,sE,labs, cex = 1) abline(fit.avtx) } z_ list(avtx = avtx, scal.res = sE, C=C, lambda = 1 - fit.avtx$coef[2], std.err = ls.diag(fit.avtx)$std.err[2]) z }