-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
134 lines (98 loc) · 4.72 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
125
126
127
128
129
130
131
132
133
134
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
dpi = 300,
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# melt <a href="https://docs.ropensci.org/melt/"><img src="man/figures/logo.png" align="right" height="139" alt="melt website" /></a>
<!-- badges: start -->
[![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)
[![R-CMD-check](https://github.com/ropensci/melt/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ropensci/melt/actions/workflows/R-CMD-check.yaml)
[![pkgcheck](https://github.com/ropensci/melt/workflows/pkgcheck/badge.svg)](https://github.com/ropensci/melt/actions?query=workflow%3Apkgcheck)
[![Codecov test coverage](https://codecov.io/gh/ropensci/melt/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ropensci/melt?branch=main)
[![CRAN status](https://www.r-pkg.org/badges/version/melt)](https://CRAN.R-project.org/package=melt)
[![runiverse](https://ropensci.r-universe.dev/badges/melt)](http://ropensci.r-universe.dev/ui/#package:melt)
[![ropensci review](https://badges.ropensci.org/550_status.svg)](https://github.com/ropensci/software-review/issues/550)
<!-- badges: end -->
## Overview
melt provides a unified framework for data analysis with empirical likelihood methods.
A collection of functions is available to perform multiple empirical likelihood tests and construct confidence intervals for various models in 'R'.
melt offers an easy-to-use interface and flexibility in specifying hypotheses and calibration methods, extending the framework to simultaneous inferences.
The core computational routines are implemented with the 'Eigen' 'C++' library and 'RcppEigen' interface, with 'OpenMP' for parallel computation.
Details of the testing procedures are provided in [Kim, MacEachern, and Peruggia (2023)](https://doi.org/10.1080/10485252.2023.2206919).
The package has a companion paper by [Kim, MacEachern, and Peruggia (2024)](https://doi.org/10.18637/jss.v108.i05).
This work was supported by the U.S. National Science Foundation under Grants No. [SES-1921523](https://www.nsf.gov/awardsearch/showAward?AWD_ID=1921523) and [DMS-2015552](https://www.nsf.gov/awardsearch/showAward?AWD_ID=2015552).
## Installation
You can install the latest stable release of melt from CRAN.
```{r, eval = FALSE}
install.packages("melt")
```
You can install the development version of melt from GitHub or [R-universe](http://ropensci.r-universe.dev/ui/#package:melt).
```{r, eval = FALSE}
# install.packages("pak")
pak::pak("ropensci/melt")
```
```{r eval = FALSE}
install.packages("melt", repos = "https://ropensci.r-universe.dev")
```
## Main functions
melt provides an intuitive API for performing the most common data analysis tasks:
* `el_mean()` computes empirical likelihood for the mean.
* `el_lm()` fits a linear model with empirical likelihood.
* `el_glm()` fits a generalized linear model with empirical likelihood.
* `confint()` computes confidence intervals for model parameters.
* `confreg()` computes confidence region for model parameters.
* `elt()` tests a hypothesis with various calibration options.
* `elmt()` performs multiple testing simultaneously.
## Usage
```{r usage, eval = TRUE}
library(melt)
set.seed(971112)
## Test for the mean
data("precip")
(fit <- el_mean(precip, par = 30))
## Adjusted empirical likelihood calibration
elt(fit, rhs = 30, calibrate = "ael")
## Bootstrap calibration
elt(fit, rhs = 30, calibrate = "boot")
## F calibration
elt(fit, rhs = 30, calibrate = "f")
## Linear model
data("mtcars")
fit_lm <- el_lm(mpg ~ disp + hp + wt + qsec, data = mtcars)
summary(fit_lm)
cr <- confreg(fit_lm, parm = c("disp", "hp"), npoints = 200)
plot(cr)
data("clothianidin")
fit2_lm <- el_lm(clo ~ -1 + trt, data = clothianidin)
summary(fit2_lm)
confint(fit2_lm)
## Generalized linear model
data("thiamethoxam")
fit_glm <- el_glm(visit ~ log(mass) + fruit + foliage + var + trt,
family = quasipoisson(link = "log"), data = thiamethoxam,
control = el_control(maxit = 100, tol = 1e-08, nthreads = 4)
)
summary(fit_glm)
## Test of no treatment effect
contrast <- c(
"trtNaked - trtFungicide", "trtFungicide - trtLow", "trtLow - trtHigh"
)
elt(fit2_lm, lhs = contrast)
## Multiple testing
contrast2 <- rbind(
c(0, 0, 0, 0, 0, 1, 0, 0),
c(0, 0, 0, 0, 0, 0, 1, 0),
c(0, 0, 0, 0, 0, 0, 0, 1)
)
elmt(fit_glm, lhs = contrast2)
```
---
Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms.