Error when running model in brms

Hello,

I am having an issue with the model recognizing the variables within the data frame and I am not entirely sure why this is happening.

Error: The following variables can neither be found in ‘data’ nor in ‘data2’: ‘RSLUpper’.

Code

#Read csv
Wap<-read.csv(“Wapengo.csv”,header=TRUE)
#Bind
Wap ← rbind(Wap)
#Arrange by age
Wap ← Wap %>% arrange(Age)

#Run model

library(brms)

m1 ← brm(RSL|mi(RSLUpper)~me(Age, Ageupper), data = Wap, save_mevars = TRUE)

Head of data so you can see structure

structure(list(Site = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = “Wapengo”, class = “factor”),
RSL = c(-0.068238463, -0.073155693, -0.02581141, -0.017379805,
-0.014178649, 0.026706959), RSLupper = c(0.16795545, 0.168146638,
0.16916378, 0.16951953, 0.168921232, 0.168238356), RSLlower = c(0.16795545,
0.168146638, 0.16916378, 0.16951953, 0.168921232, 0.168238356
), Age = c(1832L, 1860L, 1881L, 1894L, 1906L, 1913L), Ageupper = c(14.09253495,
13.7156267, 12.99997671, 12.25404364, 10.13081851, 10.19587526
), Agelower = c(14.09253495, 13.7156267, 12.99997671, 12.25404364,
10.13081851, 10.19587526), Rate = c(-0.037244426, -0.174854911,
2.332632731, 0.61776332, 0.279128313, 5.371978495)), row.names = c(NA,
6L), class = “data.frame”)

In brms you’ve referred to RSLUpper, but in the data it’s spelled RSLupper (lower-case u), so brms can’t find it

Oh yes I see - that teaches me not to code on a Monday morning… thank you!

1 Like

Sorry I now have a new error. I have changed the code to:

m1 <- brm(RSL|mi(RSLupper)~me(Age, Ageupper), data = Wap)

That results in this error:

SAMPLING FOR MODEL ‘d7e503b7b07e1f8b09c966d1d3ccec06’ NOW (CHAIN 2).
Chain 2:
Chain 2: Gradient evaluation took 2.5e-05 seconds
Chain 2: 1000 transitions using 10 leapfrog steps per transition would take 0.25 seconds.
Chain 2: Adjust your expectations accordingly!
Chain 2:
Chain 2:
Chain 2: Iteration: 1 / 2000 [ 0%] (Warmup)
[1] “Error in sampler$call_sampler(args_list[[i]]) : " " c++ exception (unknown reason)”
error occurred during calling the sampler; sampling not done

Any idea what may be causing this issue?