Description Usage Arguments References Examples
Wrapper function for testing TODO
1 2 3 |
y |
vector of length |
x |
vector of length |
index_sup |
vector of length |
surrogate |
matrix with |
adjust_covariates |
optional matrix with |
sampling_weights |
optional vector of length |
nperturb |
The number of perturbations to be run. Default is |
do_interact |
logical flag indicating whether interactins between |
condi |
logical flag indicating whether the covariance estimated should be condition on the
covariates indicated in . Default is |
do_ptb |
logical flag indicating whether to use perturbation to calculate the variance instead of using the asymptotic variance |
S Chan, BP Hejblum, A Chakrabortty, T Cai, Semi-Supervised Estimation of Covariance with Application to Phenome-wide Association Studies with Electronic Medical Records Data, 2017, submitted.
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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | ## Not run:
#rm(list=ls())
#Simulate data
nn_divide <- 10
NN <- 2000
nn <- NN/nn_divide
mySigma <- matrix(rep(0.6,16), 4, 4) + 0.4*diag(4)
mySigma[3,4] <- mySigma[3,4] + 0.2
mySigma[4,3] <- mySigma[4,3] + 0.2
beta <- 0 #0.6 #
beta_X <- c(0, 0, 0) # c(0.02, 0.3, -0.12) #
#set.seed(54321)
data_sim <- sim_data(ntot = NN, Sigma = 3*mySigma, b_G = beta, b_X = beta_X, cond_cov = TRUE)
cov_sim <- data_sim$cov_cond
data_sim <- data_sim$data
cov_sim
cov(data_sim[,"Y"], data_sim[,"G"])
es <- extremeSampling(data_sim, nn=nn, surrogate_name=c("S1", "S2", "S3"))
data_sampled <- rbind(data_sim[es$extreme_index,], data_sim[-es$extreme_index,])
#True Covariance:
cov(data_sim[,"Y"], log(1+data_sim[,"G"]))
cov(data_sampled[1:nn,"Y"], log(1+data_sampled[1:nn,"G"]))
cov(data_sim[1:nn,"Y"], log(1+data_sim[1:nn,"G"]))
res_ssl_randomsampling <- sslcov_test(y = data_sim[,"Y"], x = log(1 + data_sim[,"G"]),
index_sup = 1:nn,
surrogate = data_sim[,c("S1", "S2", "S3")],
do_interact=FALSE, condi = FALSE, do_ptb=FALSE)
res_ssl_extremeWeighted <- sslcov_test(y = data_sim[,"Y"], x = log(1 + data_sim[,"G"]),
index_sup = es$extreme_index,
sampling_weights = es$weights,
surrogate = data_sim[,c("S1", "S2", "S3")],
do_interact=FALSE, condi = FALSE, do_ptb=FALSE)
res_ssl <- sslcov_test(y = data_sampled[,"Y"], x = log(1 + data_sampled[,"G"]),
index_sup = 1:nn,
surrogate = data_sampled[,c("S1", "S2", "S3")],
sampling_weights = es$weights,
do_interact=FALSE, condi = FALSE, do_ptb=FALSE)
res_ssl_noWeights <- sslcov_test(y = data_sampled[,"Y"], x = log(1 + data_sampled[,"G"]),
index_sup = 1:nn,
surrogate = data_sampled[,c("S1", "S2", "S3")],
do_interact=FALSE, condi = FALSE, do_ptb=FALSE)
# Conditional:
cov_sim
cov(data_sim[,"Y"], data_sim[,"G"])
cov(data_sim[,"Y"], log(1+data_sim[,"G"]))
cov(lm(data_sim[,"Y"]~data_sim[, c("Age", "Race", "Gender")])$residuals, data_sim[,"G"] -
exp(MASS::glm.nb(data_sim[,"G"]~data_sim[, c("Age", "Race", "Gender")])$linear.predictors))
#library(profvis)
#profvis(
res_ssl_random_condi <- sslcov_test(y = data_sim[,"Y"], x = data_sim[,"G"], index_sup = 1:nn,
surrogate = data_sim[,c("S1", "S2", "S3")],
adjust_covariates = data_sim[, c("Age", "Race", "Gender"),
drop=FALSE],
do_interact=FALSE, condi = TRUE, do_ptb=FALSE)
#)
res_ssl_condi <- sslcov_test(y = data_sampled[,"Y"], x = data_sampled[,"G"], index_sup = 1:nn,
surrogate = data_sampled[,c("S1", "S2", "S3")],
adjust_covariates = data_sampled[, c("Age", "Race", "Gender"),
drop=FALSE],
sampling_weights = es$weights,
do_interact=FALSE, condi = TRUE, do_ptb=FALSE)
#
res_ssl_noWeights_condi <- sslcov_test(y = data_sampled[,"Y"], x = data_sampled[,"G"],
index_sup = 1:nn, surrogate = data_sampled[,c("S1", "S2", "S3")],
adjust_covariates = data_sampled[, c("Age", "Race", "Gender"),
drop=FALSE],
do_interact=FALSE, condi = TRUE, do_ptb=FALSE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.