trendline_sum: Summarized Results of Each Regression Model

View source: R/trendline_sum.R

trendline_sumR Documentation

Summarized Results of Each Regression Model

Description

Summarizing the results of linear or nonlinear regression model which built in the 'ggtrendline()' function. The function includes the following models:
"line2P" (formula as: y=a*x+b),
"line3P" (y=a*x^2+b*x+c),
"log2P" (y=a*ln(x)+b),
"exp2P" (y=a*exp(b*x)),
"exp3P" (y=a*exp(b*x)+c),
"power2P" (y=a*x^b),
and "power3P" (y=a*x^b+c).

Usage

trendline_sum(
  x,
  y,
  model = "line2P",
  Pvalue.corrected = TRUE,
  summary = TRUE,
  eDigit = 5
)

Arguments

x, y

the x and y arguments provide the x and y coordinates for the 'ggplot'. Any reasonable way of defining the coordinates is acceptable.

model

select which model to fit. Default is "line2P". The "model" should be one of c("line2P", "line3P", "log2P", "exp2P", "exp3P", "power2P", "power3P"), their formulas are as follows:
"line2P": y=a*x+b
"line3P": y=a*x^2+b*x+c
"log2P": y=a*ln(x)+b
"exp2P": y=a*exp(b*x)
"exp3P": y=a*exp(b*x)+c
"power2P": y=a*x^b
"power3P": y=a*x^b+c

Pvalue.corrected

if P-value corrected or not, the value is one of c("TRUE", "FALSE").

summary

summarizing the model fits. Default is TRUE.

eDigit

the numbers of digits for summarized results. Default is 3.

Details

The linear models (line2P, line3P, log2P) in this package are estimated by lm function,
while the nonlinear models (exp2P, exp3P, power2P, power3P) are estimated by nls function (i.e., least-squares method).

The argument 'Pvalue.corrected' is workful for non-linear regression only.

If "Pvalue.corrected = TRUE", the P-vlaue is calculated by using "Residual Sum of Squares" and "Corrected Total Sum of Squares (i.e. sum((y-mean(y))^2))".

If "Pvalue.corrected = TRUE", the P-vlaue is calculated by using "Residual Sum of Squares" and "Uncorrected Total Sum of Squares (i.e. sum(y^2))".

Value

R^2, indicates the R-Squared value of each regression model.

p, indicates the p-value of each regression model.

N, indicates the sample size.

AIC, AICc, or BIC, indicate the Akaike's Information Criterion (AIC), the second-order AIC (AICc) for small samples, or Bayesian Information Criterion (BIC) for fitted model. Click AIC for details. The smaller the AIC, AICc or BIC, the better the model.

RSS, indicate the value of "Residual Sum of Squares".

Note

If the output of 'AICc' is 'Inf', not an exact number, please try to expand the sample size of your dataset to >=6.

See Also

ggtrendline, SSexp2P, SSexp3P, SSpower2P, SSpower3P, nls, selfStart, AICc

Examples

library(ggtrendline)
x <- c(1, 3, 6, 9,  13,   17)
y <- c(5, 8, 11, 13, 13.2, 13.5)

trendline_sum(x, y, model="exp3P", summary=TRUE, eDigit=3)


ggtrendline documentation built on April 27, 2022, 9:06 a.m.