-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
106 changed files
with
6,458 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^NEWS\.md$ | ||
^README\.md$ | ||
^dev\.R$ | ||
^\.travis\.yml$ | ||
^cran-comments\.md$ | ||
^desktop\.ini$ | ||
gendat3* | ||
.vscode | ||
doc | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ | ||
^NEWS\.md$ | ||
^README\.md$ | ||
^dev\.R$ | ||
^\.travis\.yml$ | ||
^cran-comments\.md$ | ||
^desktop\.ini$ | ||
gendat3* | ||
.vscode | ||
^Meta$ | ||
^doc$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
Package: lsasim | ||
Title: Functions to Facilitate the Simulation of Large Scale Assessment Data | ||
Version: 2.0.2 | ||
Version: 2.1.0 | ||
Date: 2021-06-22 | ||
Authors@R: c( | ||
person("Tyler", "Matta", | ||
email = "[email protected]", role = "aut"), | ||
|
@@ -13,18 +14,27 @@ Authors@R: c( | |
person("Kondwani Kajera", "Mughogho", | ||
email = "[email protected]", role = "ctb"), | ||
person("Waldir", "Leoncio", | ||
email = "[email protected]", role = c("aut", "cre")) | ||
email = "[email protected]", role = c("aut", "cre")), | ||
person("Sinan", "Yavuz", role = "ctb"), | ||
person("Paul", "Bailey", role = "ctb") | ||
) | ||
Maintainer: Waldir Leoncio <[email protected]> | ||
BugReports: https://github.com/tmatta/lsasim/issues | ||
Description: Provides functions to simulate data from large-scale educational | ||
assessments, including background questionnaire data and cognitive item | ||
responses that adhere to a multiple-matrix sampled design. | ||
Imports: mvtnorm | ||
responses that adhere to a multiple-matrix sampled design. The theoretical | ||
foundation can be found on | ||
Matta, T.H., Rutkowski, L., Rutkowski, D. et al. (2018) | ||
<doi:10.1186/s40536-018-0068-8>. | ||
Imports: mvtnorm, cli, methods, polycor | ||
Depends: | ||
R (>= 3.3.0) | ||
R (>= 3.6.0) | ||
License: GPL-3 | ||
Encoding: UTF-8 | ||
LazyData: true | ||
RoxygenNote: 7.1.1 | ||
Suggests: testthat, polycor | ||
Suggests: | ||
testthat, | ||
knitr, | ||
formatR, | ||
rmarkdown | ||
VignetteBuilder: knitr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#' @title Generate an ANOVA table for LSASIM clusters | ||
#' @description Prints Analysis of Variance table for `cluster_gen` output. | ||
#' @param object list output of `cluster_gen` | ||
#' @param print if `TRUE`, output will be a list containing estimators; if `FALSE` (default), output are formatted tables of this information | ||
#' @param calc.se if `TRUE`, will try to calculate the standard error of the intreaclass correlation | ||
#' @param ... additional objects of the same type (see `help("anova")` for details) | ||
#' @return Printed ANOVA table or list of parameters | ||
#' @note If the rhos for different levels are varied in scale, the generated rho will be less accurate. | ||
#' @references Snijders, T. A. B., & Bosker, R. J. (1999). Multilevel Analysis. Sage Publications. | ||
#' @importFrom stats anova | ||
#' @method anova lsasimcluster | ||
#' @export | ||
anova.lsasimcluster <- function(object, print = TRUE, calc.se = TRUE, ...) { | ||
# Wrap data in a list (for !separate_questionnaires) ======================= | ||
if (all(sapply(object, class) != "list")) { | ||
data <- list(object) | ||
names(data) <- gsub("[0-9]", "", names(data[[1]])[1]) | ||
} else { | ||
data <- object | ||
} | ||
|
||
# Create summary statistics ================================================ | ||
data_summary <- summary.lsasimcluster(data, print = "none") | ||
|
||
# Create other relevant input ============================================== | ||
out_complete <- list() | ||
for (n in names(data)) { | ||
ds <- data_summary[[n]] | ||
if (ds$N == 1) { | ||
message("There is only one group of ", pluralize(n), | ||
". Skipping ANOVA for that level.") | ||
} else { | ||
## Sample statistics ----------------------------------------------- | ||
s2_within <- calc_var_within(ds$n_j, ds$s2_j, ds$M, ds$N) | ||
s2_between <- calc_var_between(ds$n_j, ds$y_bar_j, ds$y_bar, ds$n_tilde, ds$N) | ||
s2_total <- calc_var_tot(ds$M, ds$N, ds$n_tilde, s2_within, s2_between) | ||
out <- list(sample_statistics = c(s2_within = s2_within, | ||
s2_between = s2_between, | ||
s2_total = s2_total)) | ||
|
||
## Population parameters and ANOVA table --------------------------- | ||
sigma2_hat <- s2_within | ||
X <- names(sigma2_hat) | ||
for (x in X) { | ||
tau2_hat <- max(s2_between[x] - s2_within[x] / ds$n_tilde, 0) | ||
rho_hat <- intraclass_cor(tau2_hat, sigma2_hat[x]) | ||
if (stats::var(ds$n_j) == 0) { | ||
if (calc.se) { | ||
se_rho <- calc_se_rho(rho_hat, ds$n_j, ds$N) | ||
} else { | ||
se_rho <- NA | ||
} | ||
} else { | ||
se_rho <- NA | ||
if (calc.se) { | ||
warning( | ||
"SE not yet implemented for different ", | ||
"sample sizes. You can set calc.se=FALSE ", | ||
"to get rid of this message." | ||
) | ||
} | ||
} | ||
out$population_estimates[[x]] <- c(sigma2_hat = sigma2_hat[x], | ||
tau2_hat = tau2_hat, | ||
rho_hat = rho_hat, | ||
se_rho = se_rho) | ||
|
||
### ANOVA table ................................................ | ||
if (print) { | ||
message("\nANOVA table for ", pluralize(n), ", ", x) | ||
print_anova(s2_within[x], s2_between[x], s2_total[x], | ||
sigma2_hat[x], tau2_hat, rho_hat, se_rho, | ||
ds$n_tilde, ds$M, ds$N) | ||
} | ||
} | ||
if (print & sapply(data, class)[1] == "list" & | ||
(n != names(data)[length(names(data))])) cli::cat_rule() | ||
out_complete[[n]] <- out | ||
} | ||
} | ||
if (!print) { | ||
if (length(out_complete) > 1) { | ||
return(out_complete) | ||
} else { | ||
return(out) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#' @title Attribute Labels in Hierarchical Structure | ||
#' @description Attributes cluster and respondent labels in the context of `cluster_gen`. | ||
#' @seealso cluster_gen | ||
#' @param n numeric vector or list | ||
#' @return list containing appropriate labels for the clusters and their respondents | ||
attribute_cluster_labels <- function(n) | ||
{ | ||
if (!is.null(names(n))) { | ||
cluster_labels <- names(n) | ||
resp_labels <- names(n)[-1] | ||
} else { | ||
# General lists for all level ranges up to 5 --------------------------- | ||
cluster_labels <- list(c("school"), | ||
c("class", "school"), | ||
c("class", "school", "state"), | ||
c("class", "school", "city", "state")) | ||
resp_labels <- list(c("student", "teacher"), | ||
c("student", "teacher", "principal"), | ||
c("student", "teacher", "principal", "mayor"), | ||
c("student", "teacher", "principal", "governor")) | ||
|
||
# Filtering the labels above according to length(n) -------------------- | ||
cluster_labels <- rev(cluster_labels[[length(n) - 1]]) | ||
resp_labels <- rev(resp_labels[[length(n) - 1]])[-1] | ||
} | ||
return(list(cl = cluster_labels, resp = resp_labels)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.