Description Usage Arguments Value Examples
LR is used to fit linear model. It yields the same results as lm( ), summary(lm( )), confint( ), and hatvalues(lm( )) functions. In addition to the conventional residuals, LR also yields standardized residuals, studentized residuals, and externally studentized residuals. Further, this function can also be used to predict outcome based on fitted model.
1 |
formula |
An object of class "formula": a symbolic description of the model to be fitted. A typical model has the form outcome ~ covariates where outcome is the numeric response vector (which people usually denote as Y in statistical formula) and covariates are predictor of response. |
data |
A data frame (or object coercible by as.data.frame to a data frame) containing the variables in the model. |
include.intercept |
If the model should fit with intercept, include.intercept = TRUE; if model should fit without intercept, then include.intercept = FALSE. The default setting for include.intercept is TRUE. |
to.predict |
The default argument is set to NULL. If wants to use the current model for prediction, enter a n by p matrix (or object coercible by as.matrix to a matrix) to obtain predicted values. n is the number of prediction desired, p is the number of covariates included in the model. |
LR does not explicitly return anything unless extract the value with $ followed with the name of desired output. The returned output is a list containing at least the following components:
a named vector of coefficients
the residuals (i.e. response minus fitted values)
the standardized residuals
the internally studentized residuals
the externally studentized residuals
the predicted value
the residual standard error
obtain leverage
degrees of freedom
mimic the result from using summary(lm()) which includes estimates of beta coefficients, standard error, t value, and p-value
the proportion of the variance for a dependent variable that's explained by independent variable(s)
a penalized version of R_squared
95% confidence interval of estimates (i.e. coefficients)
Give the overall F statistic and its corresponding degrees of freedom of numerator and denominator
p-value for overall F test
Give the predicted value using the current fitted model
1 2 3 4 5 6 7 | LR(mpg ~ cyl + wt, mtcars)$coefficients ## Obtain beta coefficient estimates
LR(mpg ~ cyl + wt + disp, mtcars)$coeff_summary ## Obtain summary of beta coefficients
LR(mpg ~ cyl + wt, mtcars)$sigma ## Obtain residual standard error
LR(mpg ~ cyl + wt + qsec, mtcars)$CI ## Obtain 95% confidence interval
LR(mpg ~ cyl + wt, mtcars, include.intercept = FALSE) ## omitting intercept
LR(mpg ~ cyl + wt + qsec + disp, mtcars, include.intercept = FALSE)$df ## Extract degrees of freedom when fitting a model without an intercept
LR(cyl~mpg+wt, mtcars, to.predict = matrix(c(mean(mtcars$mpg), mean(mtcars$wt)), 1, 2))$predicted
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.