View source: R/predict.ml.wqs.R
1 | predict.ml.wqs(ml.wqs.res, newdata)
|
ml.wqs.res |
|
newdata |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (ml.wqs.res, newdata)
{
w = ml.wqs.res$weights
q.train.quantiles = ml.wqs.res$training.quantiles
dimw = length(w)
dimx = dim(newdata)[2]
q = ml.quantile.fn(newdata[, 1:dimw], q.train.quantiles)
newWQS <- as.numeric(q %*% w)
newZ <- data.frame(WQS = newWQS)
if (dimw < dimx) {
newZ <- cbind(newZ, newdata[, (dimw + 1):dimx])
names(newZ) <- cbind("WQS", names(newdata)[(dimw + 1):dimx])
}
predict.glm(ml.wqs.res$fit, newZ, envir = ml.wqs.res$env)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.