## generate precision matrix and take Cholesky decomposition
Rpre <- chol_s2Dp(im.res = c(3, 3), matrix.type = "prec",
use.spam = TRUE, neighborhood = "ar1",
triangle = "upper", return.prec = TRUE)
## Generate correlation matrix & take Cholesky decomposition
Rcov <- chol_s2Dp(corr.structure = "ar1", im.res = c(3, 3),
rho = 0.5,
triangle = "upper",
use.spam = FALSE, neighborhood = "none")
## Define non-zero beta values
Bex <- beta_builder(row.index = c(2, 3),
col.index = c(3, 3),
im.res = c(3, 3),
B0 = 0, B.values = rep(1, 2),
output.indices = FALSE)
## Simulate Datasets
## parameter values
Nex = 100
set.seed(28743)
## with precision matrix
Gauss.exp <- sim_Y_MVN_X(N = Nex, B = Bex,
R = Rpre$R, Q = Rpre$Q,
dist = "gaussian")
hist(Gauss.exp$Y)
## with covariance matrix
Gauss.exc <- sim_Y_MVN_X(N = Nex, B = Bex,
R = Rcov$R, S = Rcov$S,
dist = "gaussian")
hist(Gauss.exc$Y)
## direct draws from binomial
Bin.ex <- sim_Y_MVN_X(N = Nex, B = Bex, R = Rcov$R, S = Rcov$S,
dist = "binomial", print.out = TRUE)
table(Bin.ex$Y)
## manual cutoff
Bin.ex2 <- sim_Y_MVN_X(N = Nex, B = Bex,
R = Rcov$R, S = Rcov$S,
dist = "binomial",
threshold.method = "manual",
Y.thresh = 1.25)
table(Bin.ex2$Y)
## percentile cutoff
Bin.ex3 <- sim_Y_MVN_X(N = Nex, B = Bex,
R = Rcov$R, S = Rcov$S,
dist = "binomial",
threshold.method = "percentile",
Y.thresh = 0.75)
table(Bin.ex3$Y)
## Poisson Example - note the large counts
Pois.ex <- sim_Y_MVN_X(N = Nex, B = Bex,
R = Rcov$R, S = Rcov$S,
dist = "poisson", print.out = TRUE)
mean(Pois.ex$Y)
quantile(Pois.ex$Y,
probs = c(0, 0.1, 0.25, 0.45, 0.5,
0.75, 0.9, 0.95, 0.99, 1))
hist(Pois.ex$Y)
Run the code above in your browser using DataLab