calc_moments_inla: Compute the moments of a marginal

Description Usage Arguments Details Value Examples

View source: R/summaries.R

Description

Compute the moments of a marginal.

Usage

1

Arguments

marg

Marginal from an inla object.

Details

Compute the moments of a marginal from inla using its densities .

Value

Vector with mean and standard deviation of the marginal.

Examples

1
2
3
4
5
6
7
8
df <- data.frame(
 x1 = rnorm(50, mean = 1, sd = 0.5),
 x2 = rnorm(50, mean = 2, sd = 1),
 sigma = rexp(50, rate = 1))
df$mu <- df$x1 + df$x2
df$y <- rnorm(nrow(df), mean = df$mu, sd = df$sigma)
the_fit <- INLA::inla(formula = y ~ x1 + x2, data = df)
calc_moments_inla(the_fit$marginals.fixed[[1]])

FrankLef/eflINLA documentation built on Dec. 17, 2021, 8:30 p.m.