bestfit: Best fit models

View source: R/bestfit.R

bestfitR Documentation

Best fit models

Description

Find best transformations of the parameters for Linear Regression.

Usage

bestfit(formula, data, subset, transf = c("rsqrt", "log", "sqrt"))

Arguments

formula

A standard linear regression formula, with no transformation in the parameters.

data

A data frame containing the variables in the model.

subset

a specification of the rows to be used: defaults to all rows. This can be any valid indexing vector (see [.data.frame) for the rows of data or if that is not supplied, a data frame made up of the variables used in formula.

transf

A family of functions to be used to transform the variables in the data frame, in order to find the best combination of transformation to be applied to the data - usually functions of the box-cox family.

Examples

library(sf)
data(centro_2015)
dados <- st_drop_geometry(centro_2015)
best_fit <- bestfit(valor ~ ., data = dados)
print(best_fit, n = 20)
s <- summary(best_fit)

#There still may be outliers:
out <- car::outlierTest(s$fit) #31
outliers <- 31

# There are two ways to handle with them:

# Recalling bestfit with a subset argument ...
best_fit2 <- bestfit(valor ~ ., data = dados, subset = -outliers)

# Or assigning a subset argument directly into summary.bestfit
 s <- summary(best_fit, fit = 1, subset = -outliers)

# The latter takes less computational effort, since it only updates the
# lm call of the chosen fit. The former is more precise, since it runs
# bestfit again without the outliers.


lfpdroubi/appraiseR documentation built on April 14, 2024, 10:27 p.m.