Description Usage Arguments Value Examples
View source: R/similarity.metrics.R
Study Strap similarity measures: Supporting function used as the default similarity measures in Study Strap, SSE, and CMSS algorithms. Compares similarity in covaraite profiles of 2 studies.
1 | sim.metrics(dat1, dat2)
|
dat1 |
A design matrix of the first study. |
dat2 |
A design matrix of the second study to be compared to the first study. |
Vector of similarity measures.
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 | set.seed(1)
##########################
##### Simulate Data ######
##########################
# create training dataset with 10 studies, 2 covariates
X <- matrix(rnorm(2000), ncol = 2)
# true beta coefficients
B <- c(5, 10, 15)
# outcome vector
y <- cbind(1, X) %*% B
# study names
study <- sample.int(10, 1000, replace = TRUE)
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), ncol = 2) # design matrix only
colnames(target) <- c("V1", "V2")
#############################
#### Similarity Measures ####
#############################
# compare the covariate profile of the entire training dataset with that of the target study.
sim.vec <- sim.metrics(target, data[-c(1,2)])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.