flexfitr

flexFitR: Flexible Non-Linear Least Square Model Fitting in R.

https://github.com/apariciojohan/flexfitr

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • 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 (20.8%) to scientific vocabulary

Keywords

nls optimization
Last synced: 6 months ago · JSON representation

Repository

flexFitR: Flexible Non-Linear Least Square Model Fitting in R.

Basic Info
Statistics
  • Stars: 6
  • Watchers: 1
  • Forks: 1
  • Open Issues: 1
  • Releases: 3
Topics
nls optimization
Created over 1 year ago · Last pushed 10 months ago
Metadata Files
Readme Changelog License Code of conduct

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "",
  fig.path = "man/figures/README_",
  fig.dpi = 600,
  out.width = "100%",
  warning = FALSE,
  message = FALSE
)
```

# {flexFitR} 


[![CRAN status](https://www.r-pkg.org/badges/version/flexFitR)](https://CRAN.R-project.org/package=flexFitR)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
![Minimal R Version](https://img.shields.io/badge/R%3E%3D-4.1-blue.svg)


`{flexFitR}` is an R package designed for efficient modeling and analysis of large and complex datasets. It offers powerful tools for parameter estimation, model fitting, and visualization, leveraging the `{optimx}` package for optimization and the `{future}` package for parallel processing.

## Installation

Install released version from CRAN:
``` r
install.packages("flexFitR")
```

You can also install the development version of flexFitR from [GitHub](https://github.com/AparicioJohan/flexFitR) with:

``` r
# install.packages("devtools")
devtools::install_github("AparicioJohan/flexFitR")
```

## Features

* Parameter Estimation: Utilizes `{optimx}` algorithms to solve and estimate parameters for a given function.
* Parallelization: Implements parallel processing using the `{future}` package, enabling efficient fitting of hundreds of curves simultaneously.
* Visualization Tools: Provides a variety of plots to visualize model fits, correlations, predictions, derivatives, and more.
* Statistical Rigor: Offers standard errors and p-values for coefficients, as well as for predictions, supporting robust conclusions and interpretations.
* Prediction: Supports diverse prediction types, including point predictions, area under the curve (AUC), first and second derivatives, and custom expressions based on model parameters.
* Flexibility: Allows users to fix certain parameters in the model and specify different initial values per grouping factor, accepting both numerical inputs and expressions.
* Custom Modeling Functions: Equipped with built-in modeling functions for common analysis tasks, while also permitting users to supply their own custom functions.

## Example

Here's a simple example to get you started with `{flexFitR}`. This example demonstrates fitting a piecewise regression model:

```{r, fig.dpi=600, fig.height=3, fig.alt= "plot xy"}
library(flexFitR)

dt <- data.frame(
  time = c(0, 29, 36, 42, 56, 76, 92, 100, 108),
  variable = c(0, 0, 0.67, 15.11, 77.38, 99.81, 99.81, 99.81, 99.81)
)
plot(explorer(dt, time, variable), type = "xy")
```

```{r, fig.alt= "plot fun"}
fn_lin_plat <- function(t, t1 = 45, t2 = 80, k = 0.9) {
  ifelse(
    test = t < t1,
    yes = 0,
    no = ifelse(t >= t1 & t <= t2, k / (t2 - t1) * (t - t1), k)
  )
}
```

```{r}
# Fitting a linear plateau function
mod_1 <- dt |>
  modeler(
    x = time,
    y = variable,
    fn = "fn_lin_plat",
    parameters = c(t1 = 45, t2 = 80, k = 90)
  )
```

```{r}
print(mod_1)
```


```{r, fig.alt= "plot fin", fig.height=3}
# Auto plot
plot(mod_1)
```

```{r}
# Coefficients
coef(mod_1)
```

```{r}
# Variance-Covariance Matrix
vcov(mod_1)
```

```{r}
# Making predictions
predict(mod_1, x = 45)
```

## Documentation

For detailed documentation and examples, visit [flexFitR](https://apariciojohan.github.io/flexFitR/reference/index.html) 

* Vignette 1: [How to start](https://apariciojohan.github.io/flexFitR/articles/how_to_start.html) 
* Vignette 2: [Modeling plant emergence and canopy growth using UAV data](https://apariciojohan.github.io/flexFitR/articles/canopy-model.html)
* Vignette 3: [Modeling with constraints](https://apariciojohan.github.io/flexFitR/articles/maturity-model.html) 
* Vignette 4: [Making predictions ](https://apariciojohan.github.io/flexFitR/articles/predicted_values.html) 
* Vignette 5: [Plotting options](https://apariciojohan.github.io/flexFitR/articles/plotting.html) 

## Contributing

Contributions to flexFitR are welcome! If you'd like to contribute, please fork the repository and submit a pull request. For significant changes, please open an issue first to discuss your ideas.

## Code of Conduct

Please note that the flexFitR project is released with a [Contributor Code of Conduct](https://apariciojohan.github.io/flexFitR/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.

## License

flexFitR is licensed under the MIT License. See the [LICENSE](https://apariciojohan.github.io/flexFitR/LICENSE.html) file for more details.

Owner

  • Name: Johan Steven Aparicio
  • Login: AparicioJohan
  • Kind: user
  • Location: Cali, Colombia
  • Company: CIAT

Universidad del Valle

GitHub Events

Total
  • Create event: 3
  • Release event: 3
  • Issues event: 7
  • Watch event: 4
  • Issue comment event: 4
  • Push event: 80
  • Pull request event: 2
  • Pull request review event: 2
Last Year
  • Create event: 3
  • Release event: 3
  • Issues event: 7
  • Watch event: 4
  • Issue comment event: 4
  • Push event: 80
  • Pull request event: 2
  • Pull request review event: 2

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 5
  • Total pull requests: 2
  • Average time to close issues: about 1 month
  • Average time to close pull requests: about 11 hours
  • Total issue authors: 2
  • Total pull request authors: 1
  • Average comments per issue: 0.4
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 2
  • Average time to close issues: about 12 hours
  • Average time to close pull requests: about 11 hours
  • Issue authors: 2
  • Pull request authors: 1
  • Average comments per issue: 0.5
  • Average comments per pull request: 0.0
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • AparicioJohan (3)
  • HenrikBengtsson (2)
Pull Request Authors
  • HenrikBengtsson (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 543 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 1
cran.r-project.org: flexFitR

Flexible Non-Linear Least Square Model Fitting

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 543 Last month
Rankings
Dependent packages count: 27.4%
Dependent repos count: 33.8%
Average: 49.4%
Downloads: 86.9%
Maintainers (1)
Last synced: 7 months ago

Dependencies

DESCRIPTION cran
  • R >= 2.10 depends
  • agriutilities * imports
  • dplyr * imports
  • ggplot2 * imports
  • optimx * imports
  • rlang * imports
  • subplex * imports
  • tibble * imports
  • tidyr * imports
  • ggpubr * suggests
  • kableExtra * suggests
  • knitr * suggests
  • purrr * suggests
  • rmarkdown * suggests