Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.6%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: sydneykgeisler
- License: other
- Language: R
- Default Branch: main
- Size: 111 KB
Statistics
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 1
Metadata Files
README.md
Overview of power_mm
Thus function allows for estimation of power approximations for generalized linear mixed models. Given an exemplary dataset, fixed and random effects, variance components to be held constant in the model, and a significance level, this formula can approximate power just like the GLIMMIX procedure in SAS. Currently, this method is only available for Gaussian data.
Installation
You can install the development version of power_mm from GitHub with:
``` r
install.packages("devtools")
devtools::installgithub("https://github.com/sydneykgeisler/powermm.git") ```
You can install the development version of power_mm from GitHub with:
r
install.packages("devtools")
devtools::install_github("https://github.com/sydneykgeisler/power_mm.git")
library(powermm)
First Example
Consider a study where researchers are interested in the effects of a nitrogen source, field, and years of thatch accumulation on the chlorophyll content (mg/g) of grass clippings (Kuehl 1994, example 14.1). The four sources of nitrogen that will be investigated are denoted as “Urea”, “AmmSulph”, “IBDU”, and “SCUrea”. The three levels of thatch accumulation that will be tested are 2, 5, and 8 years. Each field is divided into four parts, with each part randomly assigned a nitrogen source level. Then each part is divided into three sub-regions, with each sub-region randomly assigned a level of thatch accumulation. This is a split plot design. The estimated y-value, which comes from the Gaussian family distribution, is the anticipated average chlorophyll measurement that an experimenter would expect to see given the nitrogen source, thatch level, and field number. For two years of thatch accumulation, researchers expect the average chlorophyll content to be 6 mg/g for nitrogen sources of “AmmSulph”, “IBDU”, and “SCUrea” and 4 mg/g for “Urea”. For either five or eight years of thatch accumulation, the expected chlorophyll content for “AmmSulph”, “IBDU”, “SCUrea”, and “Urea” is 6, 7, 8, and 5 mg/g, respectively. In other words, for this example, suppose that researchers hypothesize that the true interaction effect of nitrogen source and thatch is at least as large as represented in the following figure:

The exgaussian dataset is the exemplary dataset representing the data described above, with four fields. Suppose that from a pilot study or prior literature, the researchers estimate the variance components for random effects Field and Field:NSource to be 0.008 and 0.07, respectively, and they estimate the error variance to be 0.2. Then the following code calls the powermm function to approximate the power of the test for the interaction term given that this interaction between nitrogen source and thatch level exists:
{r example}
power_mm(Formula = estY ~ NSource*Thatch + (1 | Field) + (1|Field:NSource),
Varcomp = c(0.008, 0.07), Resid_var = 0.2, Data = ex_gaussian,
Family = "gaussian", Effect = "NSource*Thatch",
Alpha = 0.05)
The returned messages about singular and unidentifiable model are only due to the variance components being effectively held constant, and are not a reason for concern. The approximated power is about .9475.
Citation and More Details
If you use the power_mm function, please cite the following:
Geisler, Sydney (2022). Power Approximations for Generalized Linear Mixed Models in R Using Steep Priors on Variance Components. MS thesis, Department of Mathematics and Statistics, Utah State University: https://digitalcommons.usu.edu/etd/8617
The methodology employed in the power_mm function is described in greater detail in the above reference.
Included Datasets
'Exemplary Datasets' contains the code to create exemplary data for the Gaussian, binomial, and Poisson examples used.
The binomial dataset, ex_binomial, is an exemplary dataset that mimics a real- life plant experiment. Plants that are exposed to a disease are thought to have a 15% survival rate with a standard treatment. Scientists believe that this percentage will increase to 25% given a new experimental treatment.
The Gaussian dataset, ex_gaussian, describes an experiment in which thatch level accumulation, nitrogen source, and field number would effect the chloropyll content of certain grass clippings.
Lastly, the Poisson dataset, ex_poisson, is a dataset that mimics a split-plot design of a field experiment. This data represents several kinds of experimental setups that scientists might find useful in agronomic or land management practices.
Archived Code
The archived files with the '.sas' extension contain the code that SAS uses to approximate power. A description of the family type, whether it be binomial, Poisson, or Gaussian is included in the file names. These can be used in conjunction with '.R' files to compare results.
Archived Files That Contain Errors in Power Approximation
The file titled 'Errors with Steep Prior Method' shows what happens when 'power_mm' is used on non-Gaussian data.
'Gamma Prior Failures' shows that variance components are not held constant to the values specified in 'power_mm'.
'Optimization Results' shows that the variance components are held constant, but values are inconsistent with SAS results.
Second Example
Should you wish to use multiple fixed effects for power approximations, you can use concatenation as shown below:
{r example}
power_mm(Formula = estY ~ NSource*Thatch + (1 | Field) + (1|Field:NSource),
Varcomp = c(0.008, 0.07), Resid_var = 0.2, Data = ex_gaussian,
Family = "gaussian", Effect = c("NSource", "NSource:Thatch", "Thatch"),
Alpha = 0.05)
Citation (CITATION.cff)
# -----------------------------------------------------------
# CITATION file created with {cffr} R package, v0.2.2
# See also: https://docs.ropensci.org/cffr/
# -----------------------------------------------------------
cff-version: 1.2.0
message: 'To cite package "powermm" in publications use:'
type: software
license: MIT
title: 'powermm: Power Approximations of Generalized Linear Mixed Models'
version: 1.0.0
abstract: Given an exemplary dataset, the power_mm function computes a power approximation
for any number of fixed effects specified in the model. Unlike the lme4 package,
this function can take on variance components for each random effect and essentially
hold them constant within the model. This function is currently only available for
exemplary data following the Gaussian distribution.
authors:
- family-names: Geisler
given-names: Sydney
email: sydneykgeisler@gmail.com
orcid: https://orcid.org/YOUR-ORCID-ID
preferred-citation:
type: manual
title: 'powermm: Power Approximations of Generalized Linear Mixed Models'
authors:
- family-names: Geisler
given-names: Sydney
email: sydneykgeisler@gmail.com
orcid: https://orcid.org/YOUR-ORCID-ID
version: 1.0.0
abstract: Given an exemplary dataset, the power_mm function computes a power approximation
for any number of fixed effects specified in the model. Unlike the lme4 package,
this function can take on variance components for each random effect and essentially
hold them constant within the model. This function is currently only available
for exemplary data following the Gaussian distribution.
contact:
- family-names: Geisler
given-names: Sydney
email: sydneykgeisler@gmail.com
orcid: https://orcid.org/YOUR-ORCID-ID
license: MIT
year: '2022'
contact:
- family-names: Geisler
given-names: Sydney
email: sydneykgeisler@gmail.com
orcid: https://orcid.org/YOUR-ORCID-ID
references:
- type: software
title: lattice
abstract: 'lattice: Trellis Graphics for R'
notes: Imports
authors:
- family-names: Sarkar
given-names: Deepayan
email: deepayan.sarkar@r-project.org
orcid: https://orcid.org/0000-0003-4107-1553
year: '2022'
url: https://CRAN.R-project.org/package=lattice
- type: software
title: lme4
abstract: 'lme4: Linear Mixed-Effects Models using ''Eigen'' and S4'
notes: Imports
authors:
- family-names: Bates
given-names: Douglas
orcid: https://orcid.org/0000-0001-8316-9503
- family-names: Maechler
given-names: Martin
orcid: https://orcid.org/0000-0002-8685-9910
- family-names: Bolker
given-names: Ben
email: bbolker+lme4@gmail.com
orcid: https://orcid.org/0000-0002-2127-0443
- family-names: Walker
given-names: Steven
orcid: https://orcid.org/0000-0002-4394-9078
year: '2022'
url: https://CRAN.R-project.org/package=lme4
- type: software
title: blme
abstract: 'blme: Bayesian Linear Mixed-Effects Models'
notes: Imports
authors:
- family-names: Dorie
given-names: Vincent
email: vdorie@gmail.com
orcid: https://orcid.org/0000-0002-9576-3064
year: '2022'
url: https://CRAN.R-project.org/package=blme
- type: software
title: functional
abstract: 'functional: Curry, Compose, and other higher-order functions'
notes: Imports
authors:
- family-names: Danenberg
given-names: Peter
email: pcd@roxygen.org
year: '2022'
url: https://CRAN.R-project.org/package=functional
- type: software
title: lmerTest
abstract: 'lmerTest: Tests in Linear Mixed Effects Models'
notes: Imports
authors:
- family-names: Kuznetsova
given-names: Alexandra
- family-names: Bruun Brockhoff
given-names: Per
email: perbb@dtu.dk
- family-names: Haubo Bojesen Christensen
given-names: Rune
email: Rune.Haubo@gmail.com
year: '2022'
url: https://CRAN.R-project.org/package=lmerTest
- type: software
title: stringr
abstract: 'stringr: Simple, Consistent Wrappers for Common String Operations'
notes: Imports
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@rstudio.com
year: '2022'
url: https://CRAN.R-project.org/package=stringr
- type: software
title: stats
abstract: 'R: A Language and Environment for Statistical Computing'
notes: Imports
authors:
- name: R Core Team
location:
name: Vienna, Austria
year: '2022'
url: https://www.R-project.org/
institution:
name: R Foundation for Statistical Computing
- type: software
title: testthat
abstract: 'testthat: Unit Testing for R'
notes: Suggests
authors:
- family-names: Wickham
given-names: Hadley
email: hadley@rstudio.com
year: '2022'
url: https://CRAN.R-project.org/package=testthat
version: '>= 3.0.0'
- type: software
title: 'R: A Language and Environment for Statistical Computing'
notes: Depends
authors:
- name: R Core Team
location:
name: Vienna, Austria
year: '2022'
url: https://www.R-project.org/
institution:
name: R Foundation for Statistical Computing
version: '>= 2.10'
GitHub Events
Total
Last Year
Dependencies
- R >= 2.10 depends
- blme * imports
- functional * imports
- lattice * imports
- lme4 * imports
- lmerTest * imports
- stats * imports
- stringr * imports
- testthat >= 3.0.0 suggests