studyStrap.predict: Study Strap Prediction Function: Makes predictions on object...

Description Usage Arguments Value Examples

View source: R/studyStrap.predict.caret.mSSL.R

Description

Study Strap Prediction Function: Makes predictions on object of class "ss"

Usage

1
studyStrap.predict(ss.obj, X)

Arguments

ss.obj

A model object (of class "ss") fit with studyStrap package (e.g., ss, cmss, sse, merge).

X

A dataframe of the study to make predictions on. Must include covariates with the same names as those used to train models.

Value

Matrix of predictions. Each column are predictions with different weighting schemes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
##########################
##### Simulate Data ######
##########################

set.seed(1)
# create half of training dataset from 1 distribution
X1 <- matrix(rnorm(2000), ncol = 2) # design matrix - 2 covariates
B1 <- c(5, 10, 15) # true beta coefficients
y1 <- cbind(1, X1) %*% B1

# create 2nd half of training dataset from another distribution
X2 <- matrix(rnorm(2000, 1,2), ncol = 2) # design matrix - 2 covariates
B2 <- c(10, 5, 0) # true beta coefficients
y2 <- cbind(1, X2) %*% B2

X <- rbind(X1, X2)
y <- c(y1, y2)

study <- sample.int(10, 2000, replace = TRUE) # 10 studies
data <- data.frame( Study = study, Y = y, V1 = X[,1], V2 = X[,2] )

# create target study design matrix for covariate profile similarity weighting and
# accept/reject algorithm (covaraite-matched study strap)
target <- matrix(rnorm(1000, 3, 5), ncol = 2) # design matrix
colnames(target) <- c("V1", "V2")

##########################
##### Model Fitting #####
##########################

# Fit model with 1 Single-Study Learner (SSL): PCA Regression
ssMod1 <- ss(data = data, formula = Y ~.,
            target.study = target,
            bag.size = length(unique(data$Study)), straps = 5, stack = "standard",
            sim.covs = NA, ssl.method = list("pcr"),
            ssl.tuneGrid = list(data.frame("ncomp" = 2)),
            sim.mets = TRUE,
            model = TRUE, customFNs = list() )

#########################
#####  Predictions ######
#########################

preds <- studyStrap.predict(ssMod1, target)

studyStrap documentation built on Feb. 20, 2020, 5:08 p.m.