Find best transformations of the parameters for Linear Regression.
bestfit(formula, data, subset, transf = c("rsqrt", "log", "sqrt"))
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 |
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. |
dados <- st_drop_geometry(centro_2015)#> Error in st_drop_geometry(centro_2015): could not find function "st_drop_geometry"best_fit <- bestfit(valor ~ ., data = dados)#> Error in as.data.frame(data): object 'dados' not found#> Error in print(best_fit, n = 20): object 'best_fit' not found#> Error in summary(best_fit): object 'best_fit' not found#> Error in car::outlierTest(s$fit): object 's' not found#> Error in match(names(out$p), rownames(dados)): object 'out' not found# There are two ways to handle with them: # Recalling bestfit with a subset argument ... best_fit <- bestfit(valor ~ ., data = dados, subset = -outliers)#> Error in as.data.frame(data): object 'dados' not found# Or assigning a subset argument directly into summary.bestfit s <- summary(best_fit, fit = 1, subset = -outliers)#> Error in summary(best_fit, fit = 1, subset = -outliers): object 'best_fit' not found# 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.