1

Lets say i have model of a form y=a_{i} + b_{i,1}*x_{1} + b_{2}*x_{2}, where i=1,2,...,12 and i would like to estimate this model using rstanarm.

Is it possible to set different priors for each intercept a_{i} (so lets say the first 4 have normal(location = 0, scale = 1, autoscale = TRUE), the next 4 have normal(location = 1, scale = 2, autoscale = TRUE), and the last 4 student_t(df = 1, location = 0, scale = NULL, autoscale = TRUE)). I would also like to set the same priors for the b_{i,1} and lastly b_{2}~normal(location = 3, scale = 1, autoscale = TRUE).

Is it possible to do that with rstanarm ?

quant
  • 4,062
  • 5
  • 29
  • 70

1 Answers1

2

There is at most one intercept in the models supported by rstanarm, but you can suppress the intercept by including a -1 in the formula and treating the coefficients on the dummy variables as coefficients. For coefficients, you can do something like prior = student_t(df = c(rep(Inf, 8), rep(1, 4)), location = c(rep(0, 4), rep(1, 4), rep(0, 4)), scale = c(rep(1, 4), rep(2, 4), rep(1, 4)), autoscale = TRUE) But it seems that you are intending some sort of a hierarchical model, in which case the prior for the deviations from the global parameters can only be multivariate normal. See ?prior_decov.

Ben Goodrich
  • 4,870
  • 1
  • 19
  • 18
  • Thank you for your answer Ben. **1)** If I understanding it correctly, by adding the "-1" will also not cause multicollinearity, right ? It is just that the interpretation changes. **2)** What i meant to say with my example, is if you can instead of a vector with the location and the scale paramaters, you can also pass a vector with different distributions ( please correct me if i am wrong, but in your answer you transform the t distrubution to normal by manipulating the df) – quant Aug 07 '17 at 15:23
  • Yes having `-1` or `+0` in a R formula removes the intercept and thus it can include one more level of a factor as a dummy variable. – Ben Goodrich Aug 07 '17 at 18:44
  • 1
    No, in the **rstanarm** package, you cannot pass a list or character vector of functions to the `prior` argument. You can only pass vectors for `location`, `scale`, `df`, etc. to one function such as `student_t`. However, since the `student_t` is equivalent to `normal` when the degrees of freedom are infinite, that amounts to using "different" functions in the example you gave originally. With the `brm` function in the **brms** R package, you can specify different prior families for different parameters in the model estimated by Stan. – Ben Goodrich Aug 07 '17 at 18:47
  • In **rstanarm**, you can't. But if you are going to use a Beta prior with binomial data, then you can just compute the posterior distribution analytically. – Ben Goodrich Dec 30 '17 at 20:16
  • Hi Ben, I ask something briefly here and if you could answer it, I will ask it formally on SO. I have a pre-post-control design. That is, a control group (c) is pretested (pre.c) and post-tested (pos.c). Similarly, a treatment group (t) is prettested (pre.t) and post-tested (pos.t). So we have two groups (*group factor*) tested at two time points (*time factor*). ***Question:*** I was wondering using `rstanarm` we can fit a multilevel regression with both factors (i.e., *time* and *group*) and their *interaction* can be estimated? – rnorouzian Mar 06 '18 at 21:57
  • Yes, it is the same syntax as in the **lme4** package; something like `(1 | time \ group)`. – Ben Goodrich Mar 07 '18 at 23:02