stan-dev / stan-dev/rstan

Modeling inter-occasion variabile

Open
#908 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.1k
Forks
266
Avg merge
2h 56m
Merged PRs (30d)
1

Description

Hello,
I am working on modeling meta-analysis data that have studies that is considered as individuals and response collected one a few time points. Also each study has two arms which will be defined as an occasion and estimate IOV.
My question is how to add IOV to the model. I am using the Metrum institute as template as shown below:

//doseResponseMBMA1
data{
int<lower = 1> nStudies;
int<lower = 1> nArms;
int<lower = 1> study[nArms];
real<lower = 0> dose[nArms];
vector<lower = 1>[nArms] n;
vector<lower = 0>[nArms] response;
}

transformed data{
vector[nArms] logResponse;

logResponse = log(response);
}

parameters{
real<lower = 0> e0Hat;
real<lower = 0> emaxHat;
real<lower = 0> ed50;
real<lower = 0> sigma;
real<lower = 0> omegaE0;
real<lower = 0> omegaEmax;

vector<lower = 0>[nStudies] e0;// arrays works too
vector<lower = 0>[nStudies] emax; // arrays works too
}
transformed parameters{
vector<lower = 0>[nArms] responseHat;

for(i in 1:nArms){
responseHat[i] = e0[study[i]] + emax[study[i]] * dose[i] / (ed50 + dose[i]);
}

}

model{
e0Hat ~ normal(0, 10);
emaxHat ~ normal(0, 50);
ed50 ~ normal(0, 50);
sigma ~ cauchy(0, 2);
omegaE0 ~ cauchy(0, 2);
omegaEmax ~ cauchy(0, 2);

e0 ~ lognormal(log(e0Hat), omegaE0);
emax ~ lognormal(log(emaxHat), omegaEmax);

logResponse ~ normal(log(responseHat), sigma ./ exp(log(n) / 2));
}

generated quantities{
vector<lower = 0>[nStudies] e0Pred;
vector<lower = 0>[nStudies] emaxPred;
real<lower = 0> responseCond[nArms];
real<lower = 0> responseHatPred[nArms];
real<lower = 0> responsePred[nArms];

Individual predictions

for(i in 1:nArms){
responseCond[i] = exp(normal_rng(log(responseHat[i]), sigma / sqrt(n[i])));
}

Population predictions

for(i in 1:nStudies){
e0Pred[i] = lognormal_rng(log(e0Hat), omegaE0);// generate new e0
emaxPred[i] = lognormal_rng(log(emaxHat), omegaEmax);// generate new emax
}
for(i in 1:nArms){
responseHatPred[i] = e0Pred[study[i]] + emaxPred[study[i]] * dose[i] / (ed50 + dose[i]);
responsePred[i] = exp(normal_rng(log(responseHatPred[i]), sigma / sqrt(n[i])));
}

}
/////

Best regards

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue contains a pasted Stan model for meta-analysis data and asks how to add inter-occasion variability. No repository file, test, or entry point is identified, and the desired completed change is not defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.