#' @title Generate data
#'
#' @details
#' We first generate covariates X from standard normal distribution function.
#' Then we will use the following propensity score model with the binomial
#' distribution to generate treatment indicator T:
#'
#' \eqn{Pr(T = 1 | X) = 1/ (1 + exp(X_1 + ... + X_{10}))}
#'
#' Finally, the outcome model will be generated by
#' \eqn{Y = (X_1 + ... + X_{10}) + noise},
#' where noise follows standard normal distribution.
#'
#' @description Generate data for testing our main function \code{MB} and \code{hdMB}..
#' @param sample.size sample size for data, Default: 500,
#' @param dimension dimension for covariate, it should be larger than 10, Default: 10.
#'
#' @return data object with the following attributes:
#' \itemize{
#' \item{X:}{ covariates.}
#' \item{Tr:}{ treatment indicator.}
#' \item{Y:}{ observed outcome.}
#' }
#'
#' @examples
#' data <- si.data()
#' @rdname si.data
#' @export
si.data <- function(sample.size = 500, dimension = 10){
X <- matrix(rnorm(sample.size * dimension), nrow = sample.size, ncol = dimension)
ps1 <- rep(1,sample.size)
ps2 <- exp(1 * apply(X[,1:10],1,sum))
ps <- cbind(ps1 / (ps1 + ps2),ps2 / (ps1 + ps2))
uniform <- runif(sample.size)
index <- cbind(ps[,1] > uniform)
noise <- rnorm(sample.size)
Tr <- apply(index,1,sum)
Y <- 1 * apply(X[,1:10],1,sum) + noise
return(list(X = X, Tr = Tr, Y = Y))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.