I'd like to create a set of parameters for use in a brms model in R:
library(brms)
tmp <- prior(normal(10,2), nlpar = "x")
Ideally I'd like to extract the values for each prior (e.g. normal(10,2)
) from an imported matrix, for example:
priors <- cbind(c(10,20,30,40), c(2,4,6,8))
i <- 1
tmp <- prior(normal(priors[i,1], priors[i,2]), nlpar = "x")
However, this gives the following output:
#b_x ~ normal(priors[i, 1], priors[i, 2])
instead of the numeric values:
#b_x ~ normal(10, 2)
I realize this is probably pretty basic, but I can't figure out the correct way to do this. I've tried:
prior(normal(as.numeric(priors[i,1]), as.numeric(priors[i,2])), nlpar = "x")
prior(normal(as.list(priors[i,1]), as.list(priors[i,2])), nlpar = "x")
prior(normal(paste(priors[i,1]), paste(priors[i,2])), nlpar = "x")
prior(normal(get(priors[i,1]), paste(get[i,2])), nlpar = "x")
Can someone show me where I'm going wrong here? extracting by position [,] seems to work for other functions, e.g., lm(priors[,1]~priors[,2])
.