Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

me

Predictors with Measurement Error in brms Models


Description

Specify predictors with measurement error. The function does not evaluate its arguments – it exists purely to help set up a model.

Usage

me(x, sdx, gr = NULL)

Arguments

x

The variable measured with error.

sdx

Known measurement error of x treated as standard deviation.

gr

Optional grouping factor to specify which values of x correspond to the same value of the latent variable. If NULL (the default) each observation will have its own value of the latent variable.

Details

For detailed documentation see help(brmsformula).

By default, latent noise-free variables are assumed to be correlated. To change that, add set_mecor(FALSE) to your model formula object (see examples).

See Also

Examples

## Not run: 
# sample some data
N <- 100
dat <- data.frame(
  y = rnorm(N), x1 = rnorm(N), 
  x2 = rnorm(N), sdx = abs(rnorm(N, 1))
 )
# fit a simple error-in-variables model 
fit1 <- brm(y ~ me(x1, sdx) + me(x2, sdx), data = dat, 
           save_mevars = TRUE)
summary(fit1)

# turn off modeling of correlations
bform <- bf(y ~ me(x1, sdx) + me(x2, sdx)) + set_mecor(FALSE)
fit2 <- brm(bform, data = dat, save_mevars = TRUE)
summary(fit2)

## End(Not run)

brms

Bayesian Regression Models using 'Stan'

v2.15.0
GPL-2
Authors
Paul-Christian Bürkner [aut, cre], Jonah Gabry [ctb], Sebastian Weber [ctb], Andrew Johnson [ctb], Martin Modrak [ctb]
Initial release
2021-03-10

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.