Skip to content

Commit

Permalink
Update Docs for CRAN version
Browse files Browse the repository at this point in the history
  • Loading branch information
debruine committed Sep 28, 2020
1 parent 90fa243 commit cf8b119
Show file tree
Hide file tree
Showing 95 changed files with 1,846 additions and 523 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: faux
Title: Simulation for Factorial Designs
Version: 0.0.1.4
Date: 2020-08-12
Version: 0.0.1.5
Date: 2020-09-11
Authors@R: c(
person(
given = "Lisa",
Expand Down Expand Up @@ -45,7 +45,8 @@ Suggests:
ggExtra,
purrr,
broom,
broom.mixed
broom.mixed,
psych
VignetteBuilder: knitr
RoxygenNote: 7.1.1
Encoding: UTF-8
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ S3method(print,design)
S3method(print,nested_list)
S3method(print,psychds_codebook)
export("%>%")
export(average_r2tau_0)
export(check_design)
export(check_mixed_design)
export(check_sim_stats)
Expand Down Expand Up @@ -40,6 +41,7 @@ export(sim_design)
export(sim_df)
export(sim_mixed_cc)
export(sim_mixed_df)
export(std_alpha2average_r)
export(trunc2norm)
export(unif2norm)
export(unique_pairs)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# faux 0.0.1.5 (2020-09-11)

* Removed a test using markdown that failed on Solaris (causing faux to be pulled from CRAN) Back on CRAN!
* `seed` arguments reinstated as deprecated and produce a warning

# faux 0.0.1.4 (2020-08-12)

* Even more fixes for CRAN (on CRAN from 2009-08-19!)
Expand Down
28 changes: 28 additions & 0 deletions R/distribution_convertors.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,31 @@ norm2likert <- function(x, prob, mu = mean(x), sd = stats::sd(x)) {
sapply(p, function(a) n + 1 - sum(a < cprob))
}


#' Standardized Alpha to Average R
#'
#' @param std_alpha The standarized alpha
#' @param n The number of items
#'
#' @return The average inter-item correlation
#' @export
#'
#' @examples
#' std_alpha2average_r(.8, 10)
std_alpha2average_r <- function(std_alpha, n) {
sumR <- -n / ((std_alpha / (n/(n - 1))) - 1)
(sumR - n)/(n * (n - 1))
}

#' Average r to Random Intercept SD
#'
#' @param average_r The average inter-item correlation
#' @param sigma Total error variance
#'
#' @return The standard deviation of the random intercept
#' @export
#'
#' @examples
average_r2tau_0 <- function(average_r, sigma) {
sqrt((average_r * sigma^2) / (1 - average_r))
}
8 changes: 5 additions & 3 deletions R/rnorm_multi.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#' @param varnames optional names for the variables (string vector of length vars) defaults if r is a matrix with column names
#' @param empirical logical. If true, mu, sd and r specify the empirical not population mean, sd and covariance
#' @param as.matrix logical. If true, returns a matrix
#' @param seed DEPRECATED use set.seed() instead
#'
#' @return a tbl of vars vectors
#'
Expand All @@ -21,11 +22,12 @@

rnorm_multi <- function(n, vars = NULL, mu = 0, sd = 1, r = 0,
varnames = NULL, empirical = FALSE,
as.matrix = FALSE) {
# if (!is.null(seed)) {
as.matrix = FALSE, seed = NULL) {
if (!is.null(seed)) {
warning("The seed argument is deprecated. Please set seed using set.seed() instead")
# # reinstate system seed after simulation
# gs <- global_seed(); on.exit(global_seed(gs))
# }
}

# error handling ----
if ( !is.numeric(n) || n %% 1 > 0 || n < 1 ) {
Expand Down
15 changes: 11 additions & 4 deletions R/sim_design.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#' @param interactive whether to run the function interactively
#' @param design a design list including within, between, n, mu, sd, r, dv, id
#' @param rep the number of data frames to return (default 1); if greater than 1, the returned data frame is nested by rep
#' @param seed DEPRECATED use set.seed() instead
#'
#' @return a tbl
#'
Expand All @@ -28,7 +29,7 @@ sim_design <- function(within = list(), between = list(),
id = list(id = "id"),
plot = faux_options("plot"),
interactive = FALSE,
design = NULL, rep = 1) {
design = NULL, rep = 1, seed = NULL) {
# check the design is specified correctly
if (interactive) {
design <- interactive_design(plot = plot)
Expand All @@ -45,6 +46,10 @@ sim_design <- function(within = list(), between = list(),
dv = dv, id = id, plot = plot)
}

if (!is.null(seed)) {
warning("The seed argument is deprecated. Please set seed using set.seed() instead")
}

# simulate the data
data <- sim_data(design, empirical = empirical, long = long, rep = rep)

Expand All @@ -60,12 +65,13 @@ sim_design <- function(within = list(), between = list(),
#' @param long Whether the returned tbl is in wide (default = FALSE) or long (TRUE) format
#' @param rep the number of data frames to return (default 1); if greater than 1, the returned data frame is nested by rep
#' @param sep separator for within-columns, defaults to _
#' @param seed DEPRECATED use set.seed() instead
#'
#' @return a tbl
#' @export
#'
sim_data <- function(design, empirical = FALSE, long = FALSE,
rep = 1, sep = faux_options("sep")) {
rep = 1, sep = faux_options("sep"), seed = NULL) {
if (!is.numeric(rep)) {
stop("rep must be a number")
} else if (rep < 1) {
Expand All @@ -74,11 +80,12 @@ sim_data <- function(design, empirical = FALSE, long = FALSE,
warning("rep should be an integer")
}

# if (!is.null(seed)) {
if (!is.null(seed)) {
warning("The seed argument is deprecated. Please set seed using set.seed() instead")
# # reinstate system seed after simulation
# gs <- global_seed(); on.exit(global_seed(gs))
# set.seed(seed, kind = "Mersenne-Twister", normal.kind = "Inversion")
# }
}

# defaults
within <- list()
Expand Down
8 changes: 5 additions & 3 deletions R/sim_df.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @param id the names of the column(s) for grouping observations
#' @param empirical Should the returned data have these exact parameters? (versus be sampled from a population with these parameters)
#' @param long whether to return the data table in long format
#' @param seed DEPRECATED use set.seed() instead
#'
#' @return a tbl
#' @examples
Expand All @@ -22,12 +23,13 @@

sim_df <- function (data, n = 100, within = c(), between = c(),
id = "id", dv = "value",
empirical = FALSE, long = FALSE) {
# if (!is.null(seed)) {
empirical = FALSE, long = FALSE, seed = NULL) {
if (!is.null(seed)) {
warning("The seed argument is deprecated. Please set seed using set.seed() instead")
# # reinstate system seed after simulation
# gs <- global_seed(); on.exit(global_seed(gs))
# set.seed(seed, kind = "Mersenne-Twister", normal.kind = "Inversion")
# }
}

# error checking ------
if ( !is.numeric(n) || n %% 1 > 0 || n < 3 ) {
Expand Down
8 changes: 5 additions & 3 deletions R/sim_mixed_cc.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#' @param item_sd the SD of item random intercepts (or an item_n-length named vector of random intercepts for each item)
#' @param error_sd the SD of the error term
#' @param empirical Should the returned data have these exact parameters? (versus be sampled from a population with these parameters)
#' @param seed DEPRECATED use set.seed() instead
#'
#' @return a tbl
#' @export
Expand All @@ -18,12 +19,13 @@
#' sim_mixed_cc(10, 10)
sim_mixed_cc <- function(sub_n = 100, item_n = 20, grand_i = 0,
sub_sd = 1, item_sd = 1, error_sd = 1,
empirical = FALSE) {
# if (!is.null(seed)) {
empirical = FALSE, seed = NULL) {
if (!is.null(seed)) {
warning("The seed argument is deprecated. Please set seed using set.seed() instead")
# # reinstate system seed after simulation
# gs <- global_seed(); on.exit(global_seed(gs))
# set.seed(seed, kind = "Mersenne-Twister", normal.kind = "Inversion")
# }
}

# sample subject random intercepts----
if (length(sub_sd) == sub_n) {
Expand Down
16 changes: 8 additions & 8 deletions docs/404.html

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

2 changes: 1 addition & 1 deletion docs/CODE_OF_CONDUCT.html

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

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

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

2 changes: 1 addition & 1 deletion docs/LICENSE.html

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

16 changes: 8 additions & 8 deletions docs/articles/codebook.html

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

2 changes: 1 addition & 1 deletion docs/articles/continuous.html

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

2 changes: 1 addition & 1 deletion docs/articles/index.html

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

16 changes: 8 additions & 8 deletions docs/articles/plots.html

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

Loading

0 comments on commit cf8b119

Please sign in to comment.