Getting an error that I can't figure out how to bypass. I am using R version 4.3.1 and brms version 2.20.4. I have also tried using brms::brm() syntax to no avail.
The error I am getting on the bay_mod line is
Error in names(dat) <- object$term : 'names' attribute [1] must be
the same length as the vector [0].
I am setting up my R code as follows:
TS = ts(act_data$data, start = 2020, frequency = 12)
##fake time series data that mirrors the potential data can be generated
##using the following, but should note that real data will have more patterning
## TS = ts(data = abs(rnorm(43)), start = 2020, frequency = 12)
length(TS)
#length of data is 43
x = seq.Date(from = as.Date("2020-01-01"), by = "1 month", length.out = 43)
df1 = data.frame(x=x, y=TS)
bay_mod = brm(formula = bf(y ~ ar() + s(x, bs = "cc")), data = df1, chains = 4, iter = 2000)
@gregor-fausto answered the question with:
I don't get the error when I run this without the smooth terms, s(). This suggests it's something in that component, and the related question Error in gam function in names(x) <- value: 'names' attribute must be the same length as the vector suggests it might have to do with whether x is numeric or date.
Ultimately the error was due to me using Date in lieu of numeric values.