b_sim {coreSim}R Documentation

Simulate coefficients from a GLM by making draws from the multivariate normal distribution

Description

Simulate coefficients from a GLM by making draws from the multivariate normal distribution

Usage

b_sim(obj, mu, Sigma, nsim = 1000)

Arguments

obj

a fitted model object.

mu

an optional vector giving the means of the variables. If obj is supplied then mu is ignored.

Sigma

an optional positive-definite symmetric matrix specifying the covariance matrix of the variables. If obj is supplied then Sigma is ignored. If your model includes an intercept, this should be given the name intercept_.

nsim

number of simulations to draw.

Value

A data frame of simulated coefficients from obj.

Examples

library(car)

# Estimate model
m1 <- lm(prestige ~ education + type, data = Prestige)

# Create fitted values
prestige_sims <- b_sim(m1)

# Manually supply coefficient means and covariance matrix
coefs <- coef(m1)
vcov_matrix <- vcov(m1)

prestige_sims_manual <- b_sim(mu = coefs, Sigma = vcov_matrix)


[Package coreSim version 0.2.4 Index]