moe_lm_param: Calculate t-based Margin of Error of linear regression...

View source: R/utils.R

moe_lm_paramR Documentation

Calculate t-based Margin of Error of linear regression parameter estimate.

Description

When using add_lm_line(p, show = "tb", ...) to add to the scatter plot p the best fitting line and the table of fit summary (term, estimate, standard error, tstat and pval), we can take some of the info displayed on the plot and feed them into moe_lm_param() to calculate the margin of error (moe) of the slope estimate. The slope est +/- moe gives the confidence interval. moe_lm_param() can also be used to find the margin of error of any parameter estimate of a multiple linear regression.

Usage

moe_lm_param(se, n, k = 1, conf_level = 0.95)

Arguments

se

Standard error of a parameter estimate. It can be read off from the table of fit summary displayed on the scatterplot.

n

Sample size.

k

Number of predictors. Default = 1 (simple linear regression).

conf_level

A number between 0 and 1. Default = 0.95.

Value

The margin of error of the a linear regression parameter estimate.

Examples

inst/examples/ex-moe_lm_param.R

gmlang/ezplot documentation built on Sept. 18, 2022, 6:33 a.m.