Title: | A Modeling Approach that Optimizes Future Errors in Least Squares |
---|---|
Description: | Given the date column as an ascending entry, future errors are included in the sum of squares of error that should be minimized based on the number of steps and weights you determine. Thus, it is prevented that the variables affect each other's coefficients unrealistically. |
Authors: | Samet Sokel [aut, cre] |
Maintainer: | Samet Sokel <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.1.0 |
Built: | 2025-03-09 03:11:14 UTC |
Source: | https://github.com/sametsoekel/extreme-least-squares |
Almost the same interface as stats::lm
.
Just includes two parameters more, error_weights and error_ahead_level
xls.fit(formula, data, error_weights = NULL, error_ahead_level = 4)
xls.fit(formula, data, error_weights = NULL, error_ahead_level = 4)
formula |
An object of class "formula": a symbolic description of the model to be fitted. |
data |
A "data.frame" (with no missing values) object containing the variables in the model. |
error_weights |
A numeric vector including error weights by order. If NULL, it is created automatically by error_ahead_level amount, decreasing at equal intervals. |
error_ahead_level |
An integer which represents how many steps further the parameters will be optimized for each data point. |
A lm
object whose coefficients are optimized by the mentioned method.
df <- datasets::airquality ordered_df <- df[with(df,order(Month,Day)),] model <- xls.fit(Ozone ~ Solar.R + Wind + Temp,ordered_df, error_weights = c(0.4,0.3,0.2,0.1),error_ahead_level = 4)
df <- datasets::airquality ordered_df <- df[with(df,order(Month,Day)),] model <- xls.fit(Ozone ~ Solar.R + Wind + Temp,ordered_df, error_weights = c(0.4,0.3,0.2,0.1),error_ahead_level = 4)
Automatically used in xls.fit()
No need to use if the objective function is not specifically desired to be achieved.
xls.objfun(data, error_column_name, error_weights, error_ahead_level)
xls.objfun(data, error_column_name, error_weights, error_ahead_level)
data |
A data.frame object which is returned by |
error_column_name |
Symbolic error column's name. By default, it is named "error_symbolic" by |
error_weights |
A numeric vector including error weights by order. |
error_ahead_level |
An integer which represents how many steps further the parameters will be optimized for each data point. |
A function
object.
Automatically used in xls.fit()
No need to use if the raw data is not specifically desired to be achieved.
xls.prep(formula, data, dependent_var)
xls.prep(formula, data, dependent_var)
formula |
An object of class "formula": a symbolic description of the model to be fitted. |
data |
A data.frame object. |
dependent_var |
A character which is the same as left hand side variable in specified formula. |
A list
object which contains a data.frame
object to be modeled and character vector of independent variables.