predict.ml.gwqs: SLMix package

Usage Arguments Examples

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

Usage

1
predict.ml.gwqs(fit, mix_name, newdata)

Arguments

fit
mix_name
newdata

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
##---- 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 (fit, mix_name, newdata) 
{
    qname = paste(mix_name, "q", sep = "_")
    w = fit$final_weights$mean_weight
    q.train.quantiles = fit$training.quantiles
    dimw = length(qname)
    dimx = dim(newdata)[2]
    q = ml.quantile_f(newdata, mix_name, q.train.quantiles)[, 
        qname, drop = FALSE]
    newWQS <- as.numeric(as.matrix(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(fit$fit, newZ, envir = fit$env, type = "response")
  }

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