Skip to content

Commit

Permalink
fix #10
Browse files Browse the repository at this point in the history
  • Loading branch information
rpsychologist committed Apr 18, 2018
1 parent b1ea3e3 commit 140b1f2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/simulate.R
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/tests.simulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,23 @@ 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)")
res <- simulate(p, nsim = 3, formula = formula, satterthwaite = FALSE,
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)
Expand Down

0 comments on commit 140b1f2

Please sign in to comment.