estimation parameter GB2 in stan

45 views
Skip to first unread message

a.kordba...@gmail.com

unread,
Feb 15, 2017, 12:21:21 AM2/15/17
to Stan users mailing list

Hello everybody

i have a question for you all , It is my pleasure if you can help me to solve the problem.
my question is :

I want to estimate the parameters of finite mixture model .
please check the attachment.  

but i can not do it very well.
functions {
  real GB2_lpdf(real y, real a, real b, real p, real q) {
    log_gb2 = log(fabs(a)) + log(y) * (a * p - 1)
             - (log(b) * a * p + lbeta(p, q)
                + log(1 + (y / b)^a) * (p + q));
    return log_gb2;
  }
}

data {
  int<lower=0> N;
  int<lower=0> K; // maybe K = 2
  vector[N] Y;
  matrix[3, N] x;
}

parameters {
  vector[K] mu;
  vector[K] alpha;
  vector[K] beta[3];
  vector[K] a;
  vector<lower=0>[K] p;
  vector<loser=0>[K] q;
}

model {
  real log_E;

  for (i in 1:N)  {
    for (k in 1:K) {
      log_E = mu[k] + alpha[k] * F[i] + beta[1, k] * x[1, i]
             + beta[2, k] * x[2, i] + beta[3, k] * x[3, i];
      b[i, k] = exp(log_E + lbeta(p[k], q[k])
                    - lbeta(p[k] + 1 / a[k], q[k] - 1 / a[k]));
      Y[i] ~ GB2(a[k], b[i, k], p[k], q[k]);
    }
  }
  
  // Priors
  mu ~ normal(0, 100);
  alpha ~ normal(0, 100);
  for (j in 1:3)
    beta[j] ~ normal(0, 100);
  a ~ normal(0, 100);
  p ~ gamma(0.001, 0.001);
  q ~ gamma(0.001, 0.001);
}
333.docx

Bob Carpenter

unread,
Feb 15, 2017, 11:09:45 AM2/15/17
to stan-...@googlegroups.com
What problem are you having.

First, test your function. You can use generated quantities to
run it on particular values or use RStan to expose the function
and test it through R.

Second, generate fake data and make sure you can fit that.

- Bob
> --
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
> To post to this group, send email to stan-...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
> <333.docx>

Reply all
Reply to author
Forward
0 new messages