how can i modeled a STAN model like this?

19 Views Asked by At

I want to create a model like an (Kumari et al.,2018) study but I don't understand what the authors did, so I was trying to do something like this.

data {
  int<lower=0> N;
  vector[N] freq;
  vector[N] tn;
}

parameters {
  real a0;
  real a1;
  real a2;
  
  real b0;
  real b1;
  real b2;
  
  real g0;
  real g1;
  real g2;

  real<lower=0> sigma;

}

model {
  vector[N] alpha;
  vector[N] beta;
  vector[N] gamma;
  
  alpha = a0 + a1*log10(Rrup) + a2*log10(Rrup)^2;
  beta  = b0 + b1*log10(Rrup) + b2*log10(Rrup)^2;
  gamma = g0 + g1*log10(Rrup) + g2*log10(Rrup)^2;
  
  vector[N] mu;

  for(i in N){
    
  mu[i] = alpha[i] + beta[i]*log10(freq[i]) + gamma*log10(freq[i])^2;
  
  }

  tn ~ normal(mu, sigma);
}

The study model is something like this

U_med(f) = a_0 + a_1*log10(f) + a_2*log10(f)^2

the standard eviation is defined as 

Stdev = sqrt((1/N_c -1)*sum(U(f)-U_med(f))^2))

where N_c is the number of observations

Empirical prediction relations are next developed for the regession coeffiicients a_0, a_1 and 1_2 involve in the next equation, and the standard deviation values (Stdev) as follow:

a_i = c_1 + c_2*log(R) + c_3*log(R)^2

i = 0,1,2

Stdev = c_1 + c_2*log(R) + c_3*log(R)^2

the coefficients c_1, c_2 and c_3 are estimeted by regressions analyses of the values of coeficients a_i (i = 0,1,2) ans the Stdev. the linear mixed-effect teachnique (Pinheiro et al.,2009) has been used fot this porpuse.

The authors then give some graphs about these coefficients.

https://i.stack.imgur.com/EIt0V.png "The graphs"

and they gave a table containing the values.

C_1 C_2 C_3 sigma
a_0 0.92362 (±0.37904) −0.66292 (±0.41491) 0.63449 (±0.11123) 0.328
a_1 −1.35974 (±0.44268) 1.77437 (±0.48574) −0.40108 (±0.13054) 0.368
a_2 0.93758 (±0.28134) −1.04353 (±0.310557) 0.21054 (±0.08400) 0.220
Stdev −0.15041 (±0.08699) 0.350605 (±0.09542) −0.05369 (±0.02563) 0.073

I was trying to replicate this study but with my data, but a dont understand how he make his model, so my STAN code is an intemp to replicate this. I know something about Bayesian models but i don't know what is the "mixed-effects", and i don't know if this model is an hierarchical model.

If you know how to make models like these I would be very grateful if you told me.

0

There are 0 best solutions below