predict.ml.wqs: SLMix package

Usage Arguments Examples

View source: R/predict.ml.wqs.R

Usage

1
predict.ml.wqs(ml.wqs.res, newdata)

Arguments

ml.wqs.res
newdata

Examples

 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)
  }

alexpkeil1/SLmix documentation built on Aug. 15, 2020, 9:10 a.m.