Page 1 of 1

Triangular and Johnson's Sb distribution

Posted: 14 Sep 2020, 22:54
by caldeiraga
Hi,

I'm estimating a MMNL model and testing some distributions like Normal, Log-Normal, Johnson's Sb, etc. I tested a triangular distribution based on this paper https://www.jstatsoft.org/article/view/v074i10 but it didn't work. Can anyone give an example of this distribution in Apollo? In the case of Johnson's Sb is it common estimate the l and u parameters: c = l + (u - l)*(exp(b)/(1+exp(b)), or just exp(b)/(1 + exp(b))?

Thanks,
Gabriel

Re: Triangular and Johnson's Sb distribution

Posted: 15 Sep 2020, 10:19
by stephanehess
Hi

could you show us the code that you used and I'll help you improve it

Thanks

Stephane

Re: Triangular and Johnson's Sb distribution

Posted: 24 Sep 2020, 15:55
by caldeiraga
Hi,

Following the code I used for the Sb (it worked, but my question is about the support parameters) and the symmetrical triangular distribution

Code: Select all

### Set parameters for generating draws
apollo_draws = list(
  interDrawsType = 'halton',
  interNDraws = 200,
  interNormDraws = c("draws_tt"),
  interUnifDraws = c("draws_tc")
)

#create random coefficients
apollo_randCoeff <- function(apollo_beta,apollo_inputs){
  
  randcoeff = list()
  
  #Johnson's Sb distribution 
  randcoeff[['b_tt']] = exp(mu_b_tt + sigma_b_tt*draws_tt)/(1 + exp(mu_b_tt + sigma_b_tt*draws_tt))
  
  #Johnson's Sb distribution with support parameters b_l and b_u
  randcoeff[['b_tt']] = b_l + (b_u - b_l)*(exp(mu_b_tt + sigma_b_tt*draws_tt)/(1 + exp(mu_b_tt + sigma_b_tt*draws_tt)))
  
  #symmetrical triangular distribution
  randcoeff[['b_tc']] = if (draws_tc < 0.5) {
    mu_b_tc +  sigma_b_tt*(sqrt(2*draws_tc) - 1)
  } else {
    mu_b_tc +  sigma_b_tc*(1 - sqrt(2*draws_tc))
  }
  
  return(randcoeff)
}

Thanks,

Gabriel

Re: Triangular and Johnson's Sb distribution

Posted: 28 Sep 2020, 14:22
by stephanehess
Hi Gabriel

creating a symmetrical triangular is easy - it is simply the sum of two independent uniforms. Code below. I'm dividing the sum by 2 so that the range parameter is actually the range rather than half the range.

Stephane

Code: Select all

apollo_draws = list(
  interDrawsType = 'halton',
  interNDraws = 200,
  interNormDraws = c("draws_tt"),
  interUnifDraws = c("draws_tc_a","draws_tc_b")
)

#create random coefficients
apollo_randCoeff <- function(apollo_beta,apollo_inputs){
  
  randcoeff = list()
  
  #Johnson's Sb distribution 
  randcoeff[['b_tt']] = exp(mu_b_tt + sigma_b_tt*draws_tt)/(1 + exp(mu_b_tt + sigma_b_tt*draws_tt))
  
  #Johnson's Sb distribution with support parameters b_l and b_u
  randcoeff[['b_tt']] = b_l + (b_u - b_l)*(exp(mu_b_tt + sigma_b_tt*draws_tt)/(1 + exp(mu_b_tt + sigma_b_tt*draws_tt)))
  
  #symmetrical triangular distribution
  randcoeff[['b_tc']] = bound_tt + range_tt * ( draws_tc_a + draws_tc_b ) / 2
  
  return(randcoeff)
}

Re: Triangular and Johnson's Sb distribution

Posted: 29 Sep 2020, 02:42
by caldeiraga
Thanks prof Hess!

Best regards,

Gabriel