ols_calc | R Documentation |
Function computes linear OLS regression parameter estimates
The function requires a data frame with columns for observed response and predictors, and a formula object (class = "formula") that describes the OLS model of interest. Alternatively, the function will accept a matrix 'X_mt' and one column matrix 'Y_mt' for the predictor and response values respectively.
ols_calc(
df = NULL,
X_mt = NULL,
Y_mt = NULL,
formula_obj = NULL,
confid_level = 0.95,
na_omit = FALSE,
print_detail = FALSE
)
df |
A data frame with columns for observed response and predictors. |
X_mt |
In lieu of both 'df' and 'formula_obj', a matrix of predictor values can be submitted along with 'Y_mt'. Note that 'X_mt' must have column names. Also, to include an intercept, 'X_mt' should have a column of 1's. |
Y_mt |
In lieu of both 'df' and 'formula_obj', a single column matrix of response values can be submitted along with 'X_mt'. |
formula_obj |
A formula object following the rules of |
confid_level |
A numeric that defines the confidence level for estimating confidence intervals. The default is 0.95. |
na_omit |
A logical which if |
print_detail |
A logical which if |
Returning a named list of dataframes with OLS coefficient estimates, residual statistics, ANOVA of the regression along with residuals, fitted values, and R^2.
library(wooldridge)
library(data.table)
library(RregressPkg)
gpa1_dt <- data.table::as.data.table(wooldridge::gpa1) |>
_[, skipped := -skipped] |>
_[, .(colGPA, hsGPA, ACT, skipped)]
ols_ls <- RregressPkg::ols_calc(
df = gpa1_dt,
formula_obj = colGPA ~ hsGPA + ACT + skipped
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.