Cannot add 'brmsprior' objects to the prior

I am in a class and the instructor has provided the following code and attached data.

library(brms)
fit_press <- brm(rt ~ 1,
                 data= df_spacebar,
                 family = gaussian(),
                 prior = c(
         
[df_spacebar.csv|attachment](upload://xHuLcXdeRWcfp7HqiKlfXMRAbJk.csv) (5.1 KB)
          prior(uniform(0, 60000), class = Intercept),
                   prior(uniform(0, 2000, class = sigma)
                        ),
                   chains = 4, 
                   iter = 2000,
                   warmup = 1000
                 ))

When I run the code, I get an error: “Cannot add ‘brmsprior’ objects to the prior.”
I am the only one in the class who gets the error.

My reprex

fit_press ← brm(rt ~ 1,
data= df_spacebar,
family = gaussian(),
prior = c(
prior(uniform(0, 60000), class = Intercept),
prior(uniform(0, 2000, class = sigma)
),
chains = 4,
iter = 2000,
warmup = 1000
))
#> Error in brm(rt ~ 1, data = df_spacebar, family = gaussian(), prior = c(prior(uniform(0, : could not find function “brm”

If I remove the priors, i.e. “prior = c(…),” The code runs.

Any ideas about what is happening? Why is adding priors “hiding” brm function? Or, is it something else?

Thank you.

It looks like maybe you are missing a ‘)’ after the ‘2000’ in your second prior() statement.

1 Like

You’ve got eyes like an eagle. Thank you very much.

1 Like