Learn R Programming

hesim (version 0.5.0)

params_lm: Parameters of a linear model

Description

Create a list containing the parameters of a fitted linear regression model.

Usage

params_lm(coefs, sigma = NULL)

Arguments

coefs

Matrix of samples of the coefficients under sampling uncertainty.

sigma

A vector of samples of the standard error of the regression model. Must only be specified if the model is used to randomly simulate values (rather than to predict means).

Value

An object of class params_lm, which is a list containing coefs, sigma, and n_samples. n_samples is equal to the number of rows in coefs.

Details

Fitted linear models are used to predict values, \(y\), as a function of covariates, \(x\), $$y = x^T\beta + \epsilon.$$ Predicted means are given by \(x^T\hat{\beta}\) where \(\hat{\beta}\) is the vector of estimated regression coefficients. Random samples are obtained by sampling the error term from a normal distribution, \(\epsilon \sim N(0, \hat{\sigma}^2)\).

Examples

Run this code
# NOT RUN {
library("MASS")
n <- 2
params <- params_lm(coefs = MASS::mvrnorm(n, mu = c(.5,.6),
                                            Sigma = matrix(c(.05, .01, .01, .05), nrow = 2)),
                      sigma <- rgamma(n, shape = .5, rate = 4))
print(params)

# }

Run the code above in your browser using DataLab