Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compound declare/define and vectorization #4

Open
bob-carpenter opened this issue Apr 15, 2019 · 0 comments
Open

compound declare/define and vectorization #4

bob-carpenter opened this issue Apr 15, 2019 · 0 comments

Comments

@bob-carpenter
Copy link

I only looked at one of these models:

data {
  int<lower=1> n;
  vector[n] y;
}
parameters {
  # 確率的レベル
  vector[n] mu;
  # レベル撹乱項
  real<lower=0> sigma_level;
  # 観測撹乱項
  real<lower=0> sigma_irreg;
}
transformed parameters {
  vector[n] yhat;
  yhat = mu;
}
model {
  for(t in 2:n)
    mu[t] ~ normal(mu[t-1], sigma_level);

  y ~ normal(yhat, sigma_irreg);
}

and would like to make a few suggestions.

  1. Use compound declare define wherever possible. Here, you can have a one-liner
vector[n] yhat = mu;

I'm not sure why you want to give this parameter vector two names. I'd suggest just removing the variable yhat altogether and sticking to mu.

  1. Vectorize the time series model
mu[2:T] ~ normal(mu[1:T - 1], sigma_level);
  1. Provide some kind of prior on mu[1],
mu[1] ~ normal(?, ??);

where the location and scale should be chosen based on problem knowledge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant