/BestFitM

This package is used to select the best-fitting model.

Primary LanguageR

BestFitM

This package selects the best-fit model by comparing AIC and BIC. Currently, seven basic fitting models are supported. The seven basic models include one simple linear fitting model (line2P), one quadratic curve model (line3P), one logarithmic model (log2P), two exponential models (exp2P and exp3P), and two power-law models (power2P and power3P). The formulas of these seven basic fitting models are y = ax+b (line2P), y = ax^2+bx+c (line3P), y = aexp(bx)+ c (exp3P), y=aln(x)+b (log2P), y = aexp(bx) (exp2P), y = ax^b (power2P), y = a*x^b+ c (power3P), respectively.

Installation

##require "devtools"

devtools::install_github("fhruilin/BestFitM")

example

library(BestFitM)

data("mtcars")

bestFitM(data= mtcars, x= "mpg", y = "disp")

image

#Considering that not all data is applicable to the exp3P and power3P models, we give another function, BestFitM2, which contains only five basic fitting models.

example

bestFitM2(data= mtcars, x= "mpg", y = "disp")

image

#Once the best-fitting model has been selected, you can use the FitM function to look at the other parameters of the model.

example

FitM(data= mtcars, x= "mpg", y = "disp",model = "line2P")

image