Brms non-standard variable name modification

Please also provide the following information in addition to your question:

Is there a mapping within the model object from the input column or level names to the names used by brms? (Spaces replaced with periods and such.) If not, is there an exposed function used to sanitize the names? I have a dataframe I regularly use, however it has many non-standard columns. I assume there’s some obvious way to map back to the original names after using tidybayes to spread draws, but I’m honestly not sure what it is.

  • Operating System: osx
  • brms Version: 2.10.0

The function that does it can be access via brms:::rename. It is has some weird conventions I had to keep for backwards compatibility.

Thank you. Using brms:::rename, I am getting spaces removed while in the actual model I am getting spaces replaced with periods. I looked for the specific call in the code to see what the pattern/replacement pair are but couldn’t find it. Could you point me in the right direction?

Anything weird shouldn’t be a problem. I’m going to do something like `plyr::mapvalues(spread_values, brms:::rename(source_values), source_values) to map back to the original values soo as long as I can recreate the process I should be fine.

chunk <- structure(list(enum = structure(1:10, .Label = c("Privilege Misuse", 
"Crimeware", "Web Applications", "Denial of Service", "Everything Else", 
"Cyber-Espionage", "Miscellaneous Errors", "Point of Sale", "Lost and Stolen Assets", 
"Payment Card Skimmers"), class = "factor"), x = c(9, 8, 6, 6, 
3, 2, 1, 0, 0, 0), n = c(34L, 34L, 34L, 34L, 34L, 34L, 34L, 34L, 
34L, 34L), freq = c(0.26471, 0.23529, 0.17647, 0.17647, 0.08824, 
0.05882, 0.02941, 0, 0, 0)), row.names = c(NA, 10L), class = "data.frame")

m <-suppressWarnings(brms::brm(x | trials(n) ~ (1|enum), 
                               data=chunk, 
                               family = binomial(), 
                               control = list(adapt_delta = .90, max_treedepth=10),
                               refresh=0, silent=TRUE))

names(m[['fit']])
# vs
brms:::rename(chunk$enum)

Oh I get it. It is not the variable names themselves but the factor level names which are changed in your case. The call you need is simply

gsub("[ \t\r\n]", ".", names)

Thank-you sir! Sorry for the confusion.