Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7971295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:36:19+00:00 2026-06-04T07:36:19+00:00

jags.model expects a file name containing a BUGS model as its first argument. In

  • 0

jags.model expects a file name containing a BUGS model as its first argument.
In order to contain everything in one script, I sometimes use the writeLines command to write the BUGS model to a file. E.g.,

library(rjags)
writeLines("
model {
    for (i in 1:length(Y1)) {
        Y1[i] ~ dnorm(Beta0, Beta1)
    }
    Beta0 ~ dunif(1, 5)
    Beta1 ~ dunif(0, 10000)
}
"
, "m1.jags")

mod1 <- jags.model("m1.jags", data=Data)

However, if I had my choice, I don’t really want the file to be created.

Is there a way of creating some kind of virtual file in R that contains the text?

I was thinking there might be some way of writing the string to a variable using R connections in some way to mimic features of a file.

The rough pseudo code of what I was thinking:

m1.jags <- "model {
        ...
    }
    "
jags.model(SomeRCommand(m1.jags), data=Data)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:36:21+00:00Added an answer on June 4, 2026 at 7:36 am

    Thank you @Andrie for telling me the answer: i.e., just surround the character variable with the textConnection function.

    For the sake of completeness, here is how this applied to my specific problem:

    m1.jags <- "
    model {
        for (i in 1:length(Y1)) {
            Y1[i] ~ dnorm(Beta0, Beta1)
        }
        Beta0 ~ dunif(1, 5)
        Beta1 ~ dunif(0, 10000)
    }
    "
    , "m1.jags")
    
    mod1 <- jags.model(textConnection(m1.jags), data=Data)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to write a script that installs JAGS and rjags on a
I am using Jags and I have defined two different models to estimate a
I ran JAGS with runjags in R and I got a giant list back
I'm relatively new to emacs and bayesian data analysis and the JAGS software. I
I am new to JAGS and am trying to understand how dinterval() works in
I'm using JAGS and R, linked via rjags and R2jags, to fit a series
How can I draw anti-aliased triangle on ListBoxDrawItem? ListBox.Canvas.Polygon draws with jags. Thanks!!!
I am using JAGS for simulating some MCMC distributions. I see the support for
Using a directshow video control to display live video from a camera, it all
I'm trying to profile a C++ application, that I did not write, to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.