Skip to content

Commit

Permalink
Updating example in help
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith Goldfeld committed Jun 5, 2024
1 parent 79986cf commit a363865
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 40 deletions.
60 changes: 36 additions & 24 deletions R/add_correlated_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -333,37 +333,49 @@ addCorFlex <- function(dt, defs, rho = 0, tau = NULL, corstr = "cs",
#' @references Emrich LJ, Piedmonte MR. A Method for Generating High-Dimensional
#' Multivariate Binary Variates. The American Statistician 1991;45:302-4.
#' @examples
#' # Wide example
#'
#' def <- defData(varname = "xbase", formula = 5, variance = .4, dist = "gamma", id = "cid")
#' def <- defData(def, varname = "lambda", formula = ".5 + .1*xbase", dist = "nonrandom", link = "log")
#'
#' dt <- genData(100, def)
#'
#' # Ungrouped data
#'
#' cMat <- genCorMat(nvars = 4, rho = .2, corstr = "ar1", nclusters = 1)
#'
#' def <-
#' defData(varname = "xbase", formula = 5, variance = .4, dist = "gamma") |>
#' defData(varname = "lambda", formula = ".5 + .1*xbase", dist = "nonrandom", link = "log") |>
#' defData(varname = "n", formula = 3, dist = "noZeroPoisson")
#'
#' dd <- genData(101, def, id = "cid")
#'
#' ## Specify with nvars, rho, and corstr
#'
#' addCorGen(
#' dtOld = dt, idvar = "cid", nvars = 3, rho = .7, corstr = "cs",
#' dtOld = dd, idvar = "cid", nvars = 3, rho = .7, corstr = "cs",
#' dist = "poisson", param1 = "lambda"
#' )
#'
#' # Long example
#'
#' def <- defData(varname = "xbase", formula = 5, variance = .4, dist = "gamma", id = "cid")
#'
#' def2 <- defDataAdd(
#' varname = "p", formula = "-3+.2*period + .3*xbase",
#' dist = "nonrandom", link = "logit"
#'
#' ## Specify with covMatrix
#'
#' addCorGen(
#' dtOld = dd, idvar = "cid", corMatrix = cMat,
#' dist = "poisson", param1 = "lambda"
#' )
#'
#' dt <- genData(100, def)
#'
#' dtLong <- addPeriods(dt, idvars = "cid", nPeriods = 3)
#' dtLong <- addColumns(def2, dtLong)
#'
#' # Grouped data
#'
#' cMats <- genCorMat(nvars = dd$n, rho = .5, corstr = "cs", nclusters = nrow(dd))
#'
#' dx <- genCluster(dd, "cid", "n", "id")
#'
#' ## Specify with nvars, rho, and corstr
#'
#' addCorGen(
#' dtOld = dtLong, idvar = "cid", nvars = NULL, rho = .7, corstr = "cs",
#' dist = "binary", param1 = "p"
#' dtOld = dx, idvar = "cid", rho = .8, corstr = "ar1", dist = "poisson", param1 = "xbase"
#' )
#'
#'
#' ## Specify with covMatrix
#'
#' addCorGen(
#' dtOld = dx, idvar = "cid", corMatrix = cMats, dist = "poisson", param1 = "xbase"
#' )
#'
#' @concept correlated
#' @export
#' @md
Expand Down
44 changes: 28 additions & 16 deletions man/addCorGen.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a363865

Please sign in to comment.