sslcov_test: Wrapper function for testing TODO

Description Usage Arguments References Examples

Description

Wrapper function for testing TODO

Usage

1
2
3
sslcov_test(y, x, index_sup, surrogate, adjust_covariates = NULL,
  sampling_weights = rep(length(index_sup)/length(y), length(index_sup)),
  nperturb = 500, do_interact = TRUE, condi = FALSE, do_ptb = TRUE)

Arguments

y

vector of length N of the outcome

x

vector of length N containing the covariate of interest

index_sup

vector of length n indicating which observations whave supervised info

surrogate

matrix with N rows containing the surrogate information

adjust_covariates

optional matrix with N rows containing covariates to adjust on in the semi-supervised estimation. Default is NULL

sampling_weights

optional vector of length n containing the weights with which the n supervised observation were sampled from the population. Default is random sampling (all the weigths equal to 1).

nperturb

The number of perturbations to be run. Default is 500.

do_interact

logical flag indicating whether interactins between x and covariates should be taken into account when imputing y. Default is TRUE.

condi

logical flag indicating whether the covariance estimated should be condition on the covariates indicated in . Default is TRUE.

do_ptb

logical flag indicating whether to use perturbation to calculate the variance instead of using the asymptotic variance

References

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.

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

stepcie/sslcov documentation built on May 30, 2019, 2:39 p.m.