Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/azulgarza/lineartestr
R package to test the linear specification of a model with wild bootstrap. (Domínguez-Lobato test.)
https://github.com/azulgarza/lineartestr
dominguez-lobato-test linear-regression linear-specification lobato r-package reset-test wild-bootstrap
Last synced: about 1 month ago
JSON representation
R package to test the linear specification of a model with wild bootstrap. (Domínguez-Lobato test.)
- Host: GitHub
- URL: https://github.com/azulgarza/lineartestr
- Owner: AzulGarza
- License: gpl-2.0
- Created: 2018-04-29T21:51:41.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-15T00:27:39.000Z (over 3 years ago)
- Last Synced: 2024-04-23T15:43:22.181Z (9 months ago)
- Topics: dominguez-lobato-test, linear-regression, linear-specification, lobato, r-package, reset-test, wild-bootstrap
- Language: R
- Homepage: https://cran.r-project.org/web/packages/lineartestr/index.html
- Size: 700 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "70%"
)
```
# lineartestr[](https://github.com/FedericoGarza/lineartestr)
[](https://cran.r-project.org/web/packages/lineartestr/index.html)
[](https://cran.r-project.org/web/packages/lineartestr/index.html)
[](https://www.gnu.org/licenses/gpl-2.0.en.html)The goal of `lineartestr` is to contrast the linear hypothesis of a model:

Using the Domínguez-Lobato test which relies on wild-bootstrap. Also the Ramsey RESET test is implemented.
## Installation
You can install the released version of `lineartestr` from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("lineartestr")
```And the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("FedericoGarza/lineartestr")
```## References
* Manuel A. Domínguez and Ignacio N. Lobato (2019). [*Specification testing with estimated variables.*](https://www.tandfonline.com/doi/citedby/10.1080/07474938.2019.1687116?) Econometric Reviews.
## Cite as
* Garza F (2020). _lineartestr: Test the linear specification of a model_. R package version 1.0.0, https://github.com/FedericoGarza/lineartestr.
## Examples
### Simplest linear models using `lm` function
```{r example}
library(lineartestr)x <- 1:100
y <- 1:100lm_model <- lm(y~x)
dl_test <- dominguez_lobato_test(lm_model)
```
```{r table}
dplyr::glimpse(dl_test$test)
```Also `lineartestr` can plot the results
```{r plot}
plot_dl_test(dl_test)
```#### Run in **parallel**!
```{r example_parallel}
library(lineartestr)
x_p <- 1:1e5
y_p <- 1:1e5lm_model_p <- lm(y_p~x_p)
dl_test_p <- dominguez_lobato_test(lm_model_p, n_cores=7)
```
```{r table2}
dplyr::glimpse(dl_test_p$test)
```#### *RESET* test can also be used to test the linear hypothesis
```{r example_reset}
library(lineartestr)x <- 1:100 + rnorm(100)
y <- 1:100lm_model <- lm(y~x)
r_test <- reset_test(lm_model)
```
```{r table_reset}
dplyr::glimpse(r_test)
```An then we can plot the results
```{r plot_reset}
plot_reset_test(r_test)
```### Linear fixed effects with [`lfe`](https://CRAN.R-project.org/package=lfe)
```{r example_lfe}
library(lineartestr)
library(dplyr)
library(lfe)# This example was taken from https://www.rdocumentation.org/packages/lfe/versions/2.8-5/topics/felm
x <- rnorm(1000)
x2 <- rnorm(length(x))
# Individuals and firms
id <- factor(sample(20,length(x),replace=TRUE))
firm <- factor(sample(13,length(x),replace=TRUE))
# Effects for them
id.eff <- rnorm(nlevels(id))
firm.eff <- rnorm(nlevels(firm))
# Left hand side
u <- rnorm(length(x))
y <- x + 0.5*x2 + id.eff[id] + firm.eff[firm] + u
new_y <- y + rnorm(length(y))
## Estimate the model
est <- lfe::felm(y ~ x + x2 | id + firm)## Testing the linear hypothesis and plotting results
dominguez_lobato_test(est, n_cores = 7) %>%
plot_dl_test()
```### ARMA models
```{r example_arma}
library(lineartestr)
library(dplyr)x <- rnorm(100)**3
arma_model <- forecast::Arima(x, order = c(1, 0, 1))
dominguez_lobato_test(arma_model) %>%
plot_dl_test()
```