Learn R Programming

psycho (version 0.4.91)

model_to_priors: Model to Prior.

Description

Convert a Bayesian model's results to priors.

Usage

model_to_priors(fit, autoscale = FALSE)

Arguments

fit

A stanreg model.

autoscale

Set autoscale.

Examples

Run this code
# NOT RUN {
library(rstanarm)
library(psycho)

fit <- stan_glm(Sepal.Length ~ Petal.Width, data = iris)
priors <- model_to_priors(fit)
update(fit, prior = priors$prior)

fit <- stan_glmer(Subjective_Valence ~ Emotion_Condition + (1 | Participant_ID),
  data = psycho::emotion
)
priors <- model_to_priors(fit)

fit1 <- stan_glm(Subjective_Valence ~ Emotion_Condition,
  data = filter(psycho::emotion, Participant_ID == "1S")
)

fit2 <- stan_glm(Subjective_Valence ~ Emotion_Condition,
  data = filter(psycho::emotion, Participant_ID == "1S"),
  prior = priors$prior, prior_intercept = priors$prior_intercept
)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab