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 7400425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:14:54+00:00 2026-05-29T04:14:54+00:00

I am using Jags and I have defined two different models to estimate a

  • 0

I am using Jags and I have defined two different models to estimate a parameter theta. Why does this two models return different sample of theta 1 and theta 2? Someone could help me?

#MODEL 1
model {
    for ( i in 1:nFlip)    {
        y[i] ~ dbern ( theta[ mdlI ] )
    }

    theta[1] <- 1/(1+exp( -nu ))
    theta[2] <- exp( -eta )
   nu ~ dnorm(0,.1)      #  0,.1  vs  1,1
   eta ~ dgamma(.1,.1)   # .1,.1  vs  1,1

    # Prob dos modelos
    mdlI ~ dcat ( mdlProb[] )
    mdlProb[1] <- .5
    mdlProb[2] <- .5

}

#MODEL 2
model {
   for ( i in 1:nFlip ) {
      # Likelihood:
      y[i] ~ dbern( theta )
   }
   # Prior
   theta <- ( (2-mdlIdx) * 1/(1+exp( -nu )) # theta from model index 1
            + (mdlIdx-1) * exp( -eta ) )    # theta from model index 2
   nu ~ dnorm(0,.1)      #  0,.1  vs  1,1
   eta ~ dgamma(.1,.1)   # .1,.1  vs  1,1
   # Hyperprior on model index:
   mdlIdx ~ dcat( modelProb[] )
   modelProb[1] <- .5
   modelProb[2] <- .5
}

Thanks in advance for any help.
Diogo Ferrari

  • 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-05-29T04:14:55+00:00Added an answer on May 29, 2026 at 4:14 am

    The samples are random, so they are supposed to be different, but their average values are comparable (and awfully biased, but that is a different issue).

    I used the following data.

    nFlip <- 100
    y <- ifelse( 
      sample(c(TRUE,FALSE), nFlip, replace=TRUE), # Choose a coin at random
      sample(0:1, nFlip, p=c(.5,.5), replace=TRUE), # Fair coin
      sample(0:1, nFlip, p=c(.1,.9), replace=TRUE) # Biased coin
    )
    # Models
    m1 <- "
    model {
        for ( i in 1:nFlip)    {
            y[i] ~ dbern ( theta[ mdlI ] )
        }
        theta[1] <- 1/(1+exp( -nu ))
        theta[2] <- exp( -eta )
        nu  ~ dnorm(0,.1)   
        eta ~ dgamma(.1,.1) 
        mdlI ~ dcat ( mdlProb[] )
        mdlProb[1] <- .5
        mdlProb[2] <- .5
    }
    "
    m2 <- "
    model {
       for ( i in 1:nFlip ) {
          y[i] ~ dbern( theta )
       }
       theta <- ( (2-mdlIdx) * 1/(1+exp( -nu ))
                + (mdlIdx-1) * exp( -eta ) )   
       theta1 <- 1/(1+exp( -nu ))
       theta2 <- exp( -eta )
       nu  ~ dnorm(0,.1)   
       eta ~ dgamma(.1,.1)
       mdlIdx ~ dcat( modelProb[] )
       modelProb[1] <- .5
       modelProb[2] <- .5
    }
    "
    

    and ran the computations as follows.

    library(rjags)
    m <- jags.model(textConnection(m1), n.chains=2)
    s <- coda.samples(m, "theta", n.iter=1e4, thin=100)
    plot(s) # One of the probabilities is around 1, the other around .7
    
    m <- jags.model(textConnection(m2), n.chains=2)
    s <- coda.samples(m, c("theta1", "theta2"), n.iter=1e4, thin=100)
    plot(s) # Similar estimates
    

    For advice on how to check that the chains have converged, and how to write your models so that they are identifiable, https://stats.stackexchange.com/ may be a better place.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using online interfaces to a version control system is a nice way to have
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using report builder 3.0, I have a report that queries a cube. How do
Using Rails 3.2.0.rc2 and ruby 1.9.3p0 In app/views/requests/_form.html.erb I have the following code for
using file_get_contents , I open an Internet URL and get the contents of this
Using restlet, I want to make a post to android's c2dm service. I have
I'm using JAGS and R, linked via rjags and R2jags, to fit a series
Using CRM 4, I have an entity form that contains a tab with an
using VB.Net2010 I need to call a C# DLL The problem I have is

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.