Prof Brian Ripley <ripley <at> stats.ox.ac.uk> writes: > > Here is how I do it: > > write(" > model { > for (year in 1:N) { > D[year] ~ dpois(mu[year]) > log(mu[year]) <- b[1] + step(year - changeyear) * b[2] > } > for (j in 1:2) { b[j] ~ dnorm(0.0, 1.0E-6) } > changeyear ~ dunif(1,N) > } > ", "coalmining.jags") > > which has the advantage that the model description is right there in > the .Rd file. > > If you want a file to be part of the package, put it in e.g. > > <pkg source>/inst/JAGSmodels/model.txt > > and in the example use > > system.file("JAGSmodels", "model.txt", package="whatever")
What Prof Ripley said, but also: for JAGS and WinBUGS models you can actually specify coalmining <- function() { for (year in 1:N) { D[year] ~ dpois(mu[year]) log(mu[year]) <- b[1] + step(year - changeyear) * b[2] } for (j in 1:2) { b[j] ~ dnorm(0.0, 1.0E-6) } changeyear ~ dunif(1,N) } which is even more nicely integrated into the R code ... ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.