From 140b1f202b0a05c4bff885edd13a846ac376852a Mon Sep 17 00:00:00 2001 From: rpsychologist <1629860+rpsychologist@users.noreply.github.com> Date: Wed, 18 Apr 2018 15:13:17 +0200 Subject: [PATCH] fix #10 --- NEWS.md | 7 +++++++ R/simulate.R | 2 +- tests/testthat/tests.simulation.R | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index e453a37..db79a60 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,11 @@ +# Changes in version 0.3.9000 + + +## Bug fixes +* `summary.plcp_sim()` now show fixed effect `theta`s in the correct order, thanks to +GitHub user Johnzav888 (#10). + # Changes in version 0.3.0 ## New features diff --git a/R/simulate.R b/R/simulate.R index 658c39d..ad74a13 100644 --- a/R/simulate.R +++ b/R/simulate.R @@ -1064,7 +1064,7 @@ summarize_FE <- function(res, theta, alpha) { pvals_bw <- get_p_val_df(t = estimate/se, df = df_bw, parameter = para) - theta_i <- theta[[i]] + theta_i <- theta[[para]] tmp[[i]] <- data.frame( parameter = para, M_est = mean(estimate), diff --git a/tests/testthat/tests.simulation.R b/tests/testthat/tests.simulation.R index 5b6621e..3c78367 100644 --- a/tests/testthat/tests.simulation.R +++ b/tests/testthat/tests.simulation.R @@ -86,6 +86,9 @@ test_that("extract results", { test_that("simulation summary", { + p <- update(p, fixed_intercept = 4.4, + fixed_slope = -0.22) + set.seed(5446) formula <- list("correct" = "y ~ treatment * time + (1 + time | subject) + (0 + time | cluster)") @@ -93,6 +96,13 @@ test_that("simulation summary", { progress = FALSE) tmp <- summary(res) + # params + x <- as.character(tmp$summary$correct$FE$parameter) + expect_equal(x, c("(Intercept)", "treatment", "time", "time:treatment")) + + # theta + expect_equal(tmp$summary$correct$FE$theta, c(4.4, 0, -0.22, 0.1131371), tolerance = 0.00001) + # Est est <- c(res$res$correct$FE[c(4,8,12), "estimate"]) y <- mean(est)