@@ -803,9 +803,9 @@ We draw from a modified "demo 1" DGP
803
803
804
804
``` {r}
805
805
mu <- function(x) {1+g(x)+x[,1]*x[,3]-x[,2]+3*x[,3]}
806
- tau <- function(x) {1+0.5 *x[,1 ]}
806
+ tau <- function(x) {1 - 2*x[,1] + 2 *x[,2] + 1*x[,1]*x[,2 ]}
807
807
n <- 500
808
- snr <- 2
808
+ snr <- 4
809
809
x1 <- rnorm(n)
810
810
x2 <- rnorm(n)
811
811
x3 <- rnorm(n)
@@ -829,7 +829,7 @@ X$x4 <- factor(X$x4, ordered = TRUE)
829
829
X$x5 <- factor(X$x5, ordered = TRUE)
830
830
831
831
# Split data into test and train sets
832
- test_set_pct <- 0.2
832
+ test_set_pct <- 0.5
833
833
n_test <- round(test_set_pct*n)
834
834
n_train <- n - n_test
835
835
test_inds <- sort(sample(1:n, n_test, replace = FALSE))
@@ -857,7 +857,7 @@ Here we simulate from the model with the original MCMC sampler, using all of the
857
857
``` {r}
858
858
num_gfr <- 0
859
859
num_burnin <- 1000
860
- num_mcmc <- 100
860
+ num_mcmc <- 1000
861
861
num_samples <- num_gfr + num_burnin + num_mcmc
862
862
bcf_model_mcmc <- bcf(
863
863
X_train = X_train, Z_train = Z_train, y_train = y_train, pi_train = pi_train,
@@ -879,9 +879,6 @@ abline(0,1,col="red",lty=3,lwd=3)
879
879
plot(rowMeans(bcf_model_mcmc$y_hat_test), y_test,
880
880
xlab = "predicted", ylab = "actual", main = "Outcome")
881
881
abline(0,1,col="red",lty=3,lwd=3)
882
- plot(rowMeans(bcf_model_mcmc$y_hat_test-bcf_model_mcmc$mu_hat_test), tau_test*Z_test,
883
- xlab = "predicted", ylab = "actual", main = "Treatment effect term")
884
- abline(0,1,col="red",lty=3,lwd=3)
885
882
sigma_observed <- var(y-E_XZ)
886
883
plot_bounds <- c(min(c(bcf_model_mcmc$sigma2_samples, sigma_observed)),
887
884
max(c(bcf_model_mcmc$sigma2_samples, sigma_observed)))
@@ -918,14 +915,14 @@ Here we simulate from the model with the original MCMC sampler, using only covar
918
915
``` {r}
919
916
num_gfr <- 0
920
917
num_burnin <- 1000
921
- num_mcmc <- 100
918
+ num_mcmc <- 1000
922
919
num_samples <- num_gfr + num_burnin + num_mcmc
923
920
bcf_model_mcmc <- bcf(
924
921
X_train = X_train, Z_train = Z_train, y_train = y_train, pi_train = pi_train,
925
922
X_test = X_test, Z_test = Z_test, pi_test = pi_test,
926
923
num_gfr = num_gfr, num_burnin = num_burnin, num_mcmc = num_mcmc,
927
924
sample_sigma_leaf_mu = F, sample_sigma_leaf_tau = F,
928
- keep_vars_tau = c("x1")
925
+ keep_vars_tau = c("x1","x2" )
929
926
)
930
927
```
931
928
@@ -941,9 +938,6 @@ abline(0,1,col="red",lty=3,lwd=3)
941
938
plot(rowMeans(bcf_model_mcmc$y_hat_test), y_test,
942
939
xlab = "predicted", ylab = "actual", main = "Outcome")
943
940
abline(0,1,col="red",lty=3,lwd=3)
944
- plot(rowMeans(bcf_model_mcmc$y_hat_test-bcf_model_mcmc$mu_hat_test), tau_test*Z_test,
945
- xlab = "predicted", ylab = "actual", main = "Treatment effect term")
946
- abline(0,1,col="red",lty=3,lwd=3)
947
941
sigma_observed <- var(y-E_XZ)
948
942
plot_bounds <- c(min(c(bcf_model_mcmc$sigma2_samples, sigma_observed)),
949
943
max(c(bcf_model_mcmc$sigma2_samples, sigma_observed)))
@@ -980,7 +974,7 @@ Here we simulate from the model with the warm-start sampler, using all of the co
980
974
``` {r}
981
975
num_gfr <- 10
982
976
num_burnin <- 0
983
- num_mcmc <- 100
977
+ num_mcmc <- 1000
984
978
num_samples <- num_gfr + num_burnin + num_mcmc
985
979
bcf_model_warmstart <- bcf(
986
980
X_train = X_train, Z_train = Z_train, y_train = y_train, pi_train = pi_train,
@@ -1002,9 +996,6 @@ abline(0,1,col="red",lty=3,lwd=3)
1002
996
plot(rowMeans(bcf_model_warmstart$y_hat_test), y_test,
1003
997
xlab = "predicted", ylab = "actual", main = "Outcome")
1004
998
abline(0,1,col="red",lty=3,lwd=3)
1005
- plot(rowMeans(bcf_model_warmstart$y_hat_test - bcf_model_warmstart$mu_hat_test), tau_test*Z_test,
1006
- xlab = "predicted", ylab = "actual", main = "Treatment effect term")
1007
- abline(0,1,col="red",lty=3,lwd=3)
1008
999
sigma_observed <- var(y-E_XZ)
1009
1000
plot_bounds <- c(min(c(bcf_model_warmstart$sigma2_samples, sigma_observed)),
1010
1001
max(c(bcf_model_warmstart$sigma2_samples, sigma_observed)))
@@ -1041,14 +1032,14 @@ Here we simulate from the model with the warm-start sampler, using only covariat
1041
1032
``` {r}
1042
1033
num_gfr <- 10
1043
1034
num_burnin <- 0
1044
- num_mcmc <- 100
1035
+ num_mcmc <- 1000
1045
1036
num_samples <- num_gfr + num_burnin + num_mcmc
1046
1037
bcf_model_warmstart <- bcf(
1047
1038
X_train = X_train, Z_train = Z_train, y_train = y_train, pi_train = pi_train,
1048
1039
X_test = X_test, Z_test = Z_test, pi_test = pi_test,
1049
1040
num_gfr = num_gfr, num_burnin = num_burnin, num_mcmc = num_mcmc,
1050
1041
sample_sigma_leaf_mu = F, sample_sigma_leaf_tau = F,
1051
- keep_vars_tau = c("x1"), random_seed = 2
1042
+ keep_vars_tau = c("x1", "x2")
1052
1043
)
1053
1044
```
1054
1045
@@ -1064,9 +1055,6 @@ abline(0,1,col="red",lty=3,lwd=3)
1064
1055
plot(rowMeans(bcf_model_warmstart$y_hat_test), y_test,
1065
1056
xlab = "predicted", ylab = "actual", main = "Outcome")
1066
1057
abline(0,1,col="red",lty=3,lwd=3)
1067
- plot(rowMeans(bcf_model_warmstart$y_hat_test-bcf_model_warmstart$mu_hat_test), tau_test*Z_test,
1068
- xlab = "predicted", ylab = "actual", main = "Treatment effect term")
1069
- abline(0,1,col="red",lty=3,lwd=3)
1070
1058
sigma_observed <- var(y-E_XZ)
1071
1059
plot_bounds <- c(min(c(bcf_model_warmstart$sigma2_samples, sigma_observed)),
1072
1060
max(c(bcf_model_warmstart$sigma2_samples, sigma_observed)))
0 commit comments