Skip to content

Commit

Permalink
testing (#128)
Browse files Browse the repository at this point in the history
* testing

* closes #126 closes #127

* fix formatting issue in README

* modernize test skipping, remove travis
  • Loading branch information
jknowles committed Mar 17, 2023
1 parent b39f927 commit d43aa34
Show file tree
Hide file tree
Showing 26 changed files with 274 additions and 281 deletions.
37 changes: 19 additions & 18 deletions .Rbuildignore
@@ -1,18 +1,19 @@
^Meta$
^doc$
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
^cran-comments\.md$
.Rhistory
^README\.Rmd$
CONTRIBUTING.md
^revdep$
^README-.*\.png$
readmeplot
.gitignore
^vignettes/merToolsIntro\.Rmd\.orig$
^vignettes/marginal_effects\.Rmd\.orig$
^vignettes/Using_predictInterval\.Rmd\.orig$
^vignettes/imputation\.Rmd\.orig$
^CRAN-RELEASE$
^Meta$
^doc$
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
^cran-comments\.md$
.Rhistory
^README\.Rmd$
CONTRIBUTING.md
^revdep$
^README-.*\.png$
readmeplot
.gitignore
^vignettes/merToolsIntro\.Rmd\.orig$
^vignettes/marginal_effects\.Rmd\.orig$
^vignettes/Using_predictInterval\.Rmd\.orig$
^vignettes/imputation\.Rmd\.orig$
^CRAN-RELEASE$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
@@ -0,0 +1 @@
*.html
49 changes: 49 additions & 0 deletions .github/workflows/check-standard.yaml
@@ -0,0 +1,49 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

86 changes: 43 additions & 43 deletions DESCRIPTION
@@ -1,43 +1,43 @@
Package: merTools
Title: Tools for Analyzing Mixed Effect Regression Models
Version: 0.6.0
Authors@R: c(
person(c("Jared", "E."), "Knowles", email = "jknowles@gmail.com", role = c("aut", "cre")),
person("Carl", "Frederick", email="carlbfrederick@gmail.com", role = c("aut")),
person("Alex", "Whitworth", email="whitworth.alex@gmail.com", role = c("ctb")))
Description: Provides methods for extracting results from mixed-effect model
objects fit with the 'lme4' package. Allows construction of prediction intervals
efficiently from large scale linear and generalized linear mixed-effects models.
This method draws from the simulation framework used in the Gelman and Hill (2007) textbook:
Data Analysis Using Regression and Multilevel/Hierarchical Models.
Depends:
R (>= 3.0.2),
arm,
lme4 (>= 1.1-11),
methods
Suggests:
testthat,
knitr,
rmarkdown,
parallel,
nlme,
future.apply,
rstanarm,
Amelia,
DT
Imports:
dplyr,
mvtnorm,
foreach,
shiny,
abind,
ggplot2,
blme,
broom.mixed,
Matrix
License: GPL (>=2)
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 7.2.0
Encoding: UTF-8
BugReports: https://www.github.com/jknowles/merTools
Package: merTools
Title: Tools for Analyzing Mixed Effect Regression Models
Version: 0.6.1
Authors@R: c(
person(c("Jared", "E."), "Knowles", email = "jared@civilytics.com", role = c("aut", "cre")),
person("Carl", "Frederick", email="carlbfrederick@gmail.com", role = c("aut")),
person("Alex", "Whitworth", email="whitworth.alex@gmail.com", role = c("ctb")))
Description: Provides methods for extracting results from mixed-effect model
objects fit with the 'lme4' package. Allows construction of prediction intervals
efficiently from large scale linear and generalized linear mixed-effects models.
This method draws from the simulation framework used in the Gelman and Hill (2007) textbook:
Data Analysis Using Regression and Multilevel/Hierarchical Models.
Depends:
R (>= 3.0.2),
arm,
lme4 (>= 1.1-11),
methods
Suggests:
testthat,
knitr,
rmarkdown,
parallel,
nlme,
future.apply,
rstanarm,
Amelia,
DT
Imports:
dplyr,
mvtnorm,
foreach,
shiny,
abind,
ggplot2,
blme,
broom.mixed,
Matrix
License: GPL (>=2)
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 7.2.3
Encoding: UTF-8
BugReports: https://github.com/jknowles/merTools
9 changes: 9 additions & 0 deletions NEWS.md
@@ -1,5 +1,14 @@
# NEWS

## merTools 0.6.1

- Maintenance release to keep package listed on CRAN
- Fix a small bug where parallel code path is run twice (#126)
- Update plotting functions to avoid deprecated `aes_string()` calls (#127)
- Fix (#115) in description
- Speed up PI using @bbolker pull request (#120)
- Updated package maintainer contact information

## merTools 0.5.2

- Streamline vignette building to be precompiled and move tests to limit burden on CRAN check
Expand Down
2 changes: 1 addition & 1 deletion R/REmargins.R
Expand Up @@ -71,7 +71,7 @@
#' Gatz, DF and Smith, L. The Standard Error of a Weighted Mean Concentration.
#' I. Bootstrapping vs other methods. \emph{Atmospheric Environment}.
#' 1995;11(2)1185-1193. Available at
#' \url{http://www.sciencedirect.com/science/article/pii/135223109400210C}
#' \url{https://www.sciencedirect.com/science/article/pii/135223109400210C}
#'
#' Cochran, WG. 1977. Sampling Techniques (3rd Edition). Wiley, New York.
#'
Expand Down
2 changes: 1 addition & 1 deletion R/merData.R
Expand Up @@ -435,7 +435,7 @@ REquantile <- function(merMod, quantile, groupFctr, term = "(Intercept)"){
stop("Random effect group name not found. Please respecify grouping factor.")
}
myRE.tmp <- try(myRE[order(myRE[, term]), ,drop = FALSE], silent = TRUE)
if(class(myRE.tmp) != "data.frame"){
if(!is(myRE.tmp, "data.frame")){
term1 <- names(myRE)[1]
myRE.tmp <- try(myRE[order(myRE[, term1]), ,drop = FALSE], silent = TRUE)
warning(paste0(term, " not found in random effect terms. Returning first term, ",
Expand Down
9 changes: 5 additions & 4 deletions R/merList.R
Expand Up @@ -197,7 +197,7 @@ ranef.merModList <- function(object, ...){
#' fml <- "Reaction ~ Days + (Days | Subject)"
#' mod <- lmerModList(fml, data = sim_list)
#' VarCorr(mod)
VarCorr.merModList <- function(x, sigma = 1, rdig = 3L){
VarCorr.merModList <- function(x, sigma = 1, rdig = 3L, ...){
modList <- x
ngrps <- length(VarCorr(modList[[1]]))
errorList <- vector(mode = 'list', length = ngrps)
Expand Down Expand Up @@ -386,12 +386,13 @@ print.summary.merModList <- function(x, ...){
#' summary(mod)
#' }
lmerModList <- function(formula, data, parallel = FALSE, ...){
if(parallel) {
if (parallel) {
if (requireNamespace("future.apply", quietly=TRUE)) {
ml <- future.apply::future_lapply(data, function(d) lmer(formula, data = d, ...))
} else {
warning("Parallel set but future.apply not available. Running sequentially.")
ml <- lapply(data, function(d) lmer(formula, data = d, ...))
}
warning("Parallel set but future.apply not available. Running sequentially.")
ml <- lapply(data, function(d) lmer(formula, data = d, ...))
} else {
ml <- lapply(data, function(d) lmer(formula, data = d, ...))
}
Expand Down
6 changes: 3 additions & 3 deletions R/merPlots.R
Expand Up @@ -69,8 +69,8 @@ plotREsim <- function(data, level = 0.95, stat = "median", sd = TRUE,
xlabs.tmp <- element_blank()
}

p <- ggplot(data, aes_string(x = "xvar", y = stat, ymax = "ymax", ymin = "ymin")) +
geom_hline(yintercept = hlineInt, color = I("red"), size = I(1.1)) +
p <- ggplot(data, aes(x = .data[["xvar"]], y = .data[[stat]], ymax = .data[["ymax"]], ymin = .data[["ymin"]])) +
geom_hline(yintercept = hlineInt, color = I("red"), linewidth = I(1.1)) +
geom_point(color="gray75", alpha=1/(nrow(data)^.33), size=I(0.5)) +
geom_point(data=subset(data, sig==TRUE), size=I(3)) +
labs(x = "Group", y = "Effect Range", title = "Effect Ranges") +
Expand Down Expand Up @@ -140,7 +140,7 @@ plotFEsim <- function(data, level=0.95, stat = "median", sd = TRUE,
xvar <- "term"
data$term <- as.character(data$term)
data$term <- factor(data$term , levels = data[order(data[, stat]), 1])
p <- ggplot(aes_string(x = xvar, y = stat, ymax = "ymax", ymin = "ymin"), data = data) +
p <- ggplot(aes(x = .data[[xvar]], y = .data[[stat]], ymax = .data[["ymax"]], ymin = .data[["ymin"]]), data = data) +
geom_hline(yintercept = hlineInt, color = I("red")) +
geom_point(size=I(3)) +
coord_flip() +
Expand Down
41 changes: 13 additions & 28 deletions README.Rmd
Expand Up @@ -5,20 +5,19 @@ output:
---


[![Travis-CI Build Status](https://travis-ci.org/jknowles/merTools.png?branch=master)](https://travis-ci.org/jknowles/merTools)
[![Coverage Status](https://coveralls.io/repos/jknowles/merTools/badge.svg?branch=master)](https://coveralls.io/r/jknowles/merTools?branch=master)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/merTools)](https://cran.r-project.org/package=merTools)
[![Downloads](http://cranlogs.r-pkg.org/badges/merTools)](https://cran.r-project.org/package=merTools)
[![Downloads](http://cranlogs.r-pkg.org/badges/grand-total/merTools)](https://cran.r-project.org/package=merTools)

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, echo = FALSE}
```{r, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE, echo = TRUE,
comment = "#>",
fig.path = "man/figures/README_"
)
library(merTools)
```

# merTools
Expand Down Expand Up @@ -48,6 +47,15 @@ install.packages("merTools")

## Recent Updates

## merTools 0.6.1 (Spring 2023)

- Maintenance release to keep package listed on CRAN
- Fix a small bug where parallel code path is run twice (#126)
- Update plotting functions to avoid deprecated `aes_string()` calls (#127)
- Fix (#115) in description
- Speed up PI using @bbolker pull request (#120)
- Updated package maintainer contact information

### merTools 0.5.0

#### New Features
Expand Down Expand Up @@ -75,42 +83,20 @@ correction for multiple imputation
- Contribution by Alex Whitworth (@alexWhitworth) adding error checking to plotting
functions

### merTools 0.4.0

#### New Features
- Added vignette on using multilevel models with multiply imputed data
- Added `fixef` and `ranef` generics for `merModList` objects
- Added `fastdisp` generic for `merModList`
- Added `summary` generic for `merModList`
- Added `print` generic for `merModList`
- Documented all generics for `merModList` including examples and a new
imputation vignette
- Added `modelInfo` generic for `merMod` objects that provides simple summary
stats about a whole model

#### Bug Fixes
- Fix bug that returned NaN for `std.error` of a multiply imputed `merModList`
when calling `modelRandEffStats`
- Fixed bug in `REimpact` where some column names in `newdata` would prevent the
prediction intervals from being computed correctly. Users will now be warned.
- Fixed bug in `wiggle` where documentation incorrectly stated the arguments to
the function and the documentation did not describe function correctly

See [NEWS.md](https://github.com/jknowles/merTools/blob/master/NEWS.md) for
more details.

## Shiny App and Demo

The easiest way to demo the features of this application is to use the bundled
Shiny application which launches a number of the metrics here to aide in exploring
the model. To do this:

```{r, echo = TRUE, eval=FALSE}
```
library(merTools)
m1 <- lmer(y ~ service + lectage + studage + (1|d) + (1|s), data=InstEval)
shinyMer(m1, simData = InstEval[1:100, ]) # just try the first 100 rows of data
```


```{r, include=FALSE}
library(merTools)
m1 <- lmer(y ~ service + lectage + studage + (1|d) + (1|s), data=InstEval)
Expand Down Expand Up @@ -159,7 +145,6 @@ With `predictInterval` we obtain predictions that are more like the standard
objects produced by `lm` and `glm`:

```{r}
#predictInterval(m1, newdata = InstEval[1:10, ]) # all other parameters are optional
predictInterval(m1, newdata = InstEval[1:10, ], n.sims = 500, level = 0.9,
stat = 'median')
```
Expand Down

0 comments on commit d43aa34

Please sign in to comment.