-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
124 lines (95 loc) · 5.12 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
---
output:
github_document
bibliography: vignettes/REFERENCES.bib
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
```{r srr, eval = FALSE, echo = FALSE}
#' @srrstats {G1.2} *Statistical Software should include a* Life Cycle Statement *describing current and anticipated future states of development.*
#' @srrstats {G1.1} *Statistical Software should document whether the algorithm(s) it implements are:* - *The first implementation of a novel algorithm*; or - *The first implementation within **R** of an algorithm which has previously been implemented in other languages or contexts*; or - *An improvement on other implementations of similar algorithms in **R***.
#' @srrstats {G5.0} *Where applicable or practicable, tests should use standard data sets with known properties (for example, the [NIST Standard Reference Datasets](https://www.itl.nist.gov/div898/strd/), or data sets provided by other widely-used R packages).*
#' @srrstats {G3.0} *Statistical software should never compare floating point numbers for equality. All numeric equality comparisons should either ensure that they are made between integers, or use appropriate tolerances for approximate equality.*
```
# GLMMcosinor <a href='https://docs.ropensci.org/GLMMcosinor/'><img src='man/figures/logo.png' align="right" height="139" /></a>
<!-- badges: start -->
[![cranlogs](https://www.r-pkg.org/badges/version/GLMMcosinor)](https://CRAN.R-project.org/package=GLMMcosinor)
[![R-CMD-check](https://github.com/ropensci/GLMMcosinor/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ropensci/GLMMcosinor/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/ropensci/GLMMcosinor/graph/badge.svg)](https://app.codecov.io/gh/ropensci/GLMMcosinor)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Status at rOpenSci Software Peer Review](https://badges.ropensci.org/603_status.svg)](https://github.com/ropensci/software-review/issues/603)
<!-- badges: end -->
The goal of `{GLMMcosinor}` is to fit a cosinor model to rhythmic data with all
the flexibility and functionality of a generalized linear (mixed-) model (GLM)
framework using `{glmmTMB}`.
The package is also accessible via a [web app](https://aushsi.shinyapps.io/GLMMcosinor-shinyapp)
developed using shiny.
For an introduction to the cosinor model, see the [getting started vignette](https://docs.ropensci.org/GLMMcosinor/articles/GLMMcosinor.html).
Existing statistical software for circadian data analyses (including `cosinor`
[@sachs2023cosinor] or `circacompare` [@parsons2020circacompare]) allows users
to fit regression models to rhythmic data, but many are limited due to their
inability to specify a link function, multiple components, or a hierarchical
structure. `GLMMcosinor` aims to be comprehensive and flexible and is an
improvement on other implementations of cosinor model fitting in R or Python.
See table below for features available within currently available methods.
`GLMMcosinor` makes use of the `glmmTMB` package framework for estimation of the
cosinor model. If the model has no random effects, `glmmTMB` uses
maximum likelihood estimation to estimate the linear coefficients of the model.
For models with random effects, a Laplace approximation is used to integrate
over the random effects. This approximation is handled by the
[`TMB`](https://cran.r-project.org/package=TMB)
package which uses automatic differentiation of the joint likelihood function to
efficiently compute parameter estimates. A detailed explanation of this process
is described [here](https://doi.org/10.18637/jss.v070.i05) [@Kristensen2016TMB].
```{r, include=FALSE}
source("vignettes/fixtures/methods-table.R")
# flextable::save_as_image(
# dat,
# file.path("man", "figures", "methods-table.png")
# )
```
<img src="man/figures/methods-table.png" width="=900px" alt="flextable formats" align="center" />
## Installation
You can install the development version of GLMMcosinor from
[GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("ropensci/GLMMcosinor")
# or, equivalently
install.packages("GLMMcosinor", repos = "https://ropensci.r-universe.dev")
```
## Example
This is a basic example which shows you how to solve a common problem:
```{r example}
library(GLMMcosinor)
```
```{r}
model <- cglmm(
vit_d ~ X + amp_acro(time, group = "X", period = 12),
data = vitamind
)
summary(model)
```
```{r, eval=FALSE}
autoplot(model, superimpose.data = TRUE)
polar_plot(model)
```
```{r, echo=FALSE}
p1 <- autoplot(model, superimpose.data = TRUE) +
ggplot2::theme(legend.position = "none")
p2 <- polar_plot(model)
cowplot::plot_grid(p1, p2, nrow = 1, rel_widths = c(0.4, 0.6))
```
## Citation
```{r}
citation("GLMMcosinor")
```
## References