
Recognise a JAGS/BUGS model-definition file
Source:R/reproducibility_check.R
dot-repro_is_jags_model.RdA JAGS/BUGS model (model { ... }) is written in JAGS's own modelling
language, not R, and is meant to be passed as a text file to
rjags::jags.model()/R2jags::jags()/runjags::run.jags(), never parsed
as R directly — authors frequently save one with a .R extension, which
then fails code_parse_r() and reads identically to a genuine broken R
script. Matched via three signals, any one of which is treated as
sufficient (the third — an actual calling reference from the paper's own
code — is the strongest, since it confirms the paper's own code treats
this file as a JAGS model rather than something to run directly):
Arguments
- code_text
the file's raw text (character vector, one element per line)
- file_name
the file's own name/path (checked for a
jags_script/bugs_script/jags_modelpath component)- other_code_text
optional list of OTHER files' code text (e.g. the paper's other R files) to scan for a
jags.model()/jags()/run.jags()call naming this file —NULLskips this (strongest) signal
Details
the file's first non-comment, non-blank content is the token
modelfollowed by{, also on the next line, or adata { ... }block with amodelblock after it;its path contains a component named
jags_script/bugs_script/jags_model(case-insensitive);it is referenced elsewhere in the SAME paper's own R code as the
file=/first argument torjags::jags.model(),R2jags::jags(), orrunjags::run.jags().