# Binomial likelihood, logit link# Random effects model for multi-arm trialsmodel{ # *** PROGRAM STARTSfor(i in 1:ns){ # LOOP THROUGH STUDIES w[i,1] <- 0 # adjustment for multi-arm trials is zero for control arm delta[i,1] <- 0 # treatment effect is zero for control arm mu[i] ~ dnorm(0,.0001) # vague priors for all trial baselines for (k in 1:na[i]) { # LOOP THROUGH ARMS r[i,k] ~ dbin(p[i,k],n[i,k]) # binomial likelihood logit(p[i,k]) <- mu[i] + delta[i,k] # model for linear predictor rhat[i,k] <- p[i,k] * n[i,k] # expected value of the numerators #Deviance contribution dev[i,k] <- 2 * (r[i,k] * (log(r[i,k])-log(rhat[i,k])) + (n[i,k]-r[i,k]) * (log(n[i,k]-r[i,k]) - log(n[i,k]-rhat[i,k]))) }# summed residual deviance contribution for this trial resdev[i] <- sum(dev[i,1:na[i]]) for (k in 2:na[i]) { # LOOP THROUGH ARMS# trial-specific LOR distributions delta[i,k] ~ dnorm(md[i,k],taud[i,k])# mean of LOR distributions (with multi-arm trial correction) md[i,k] <- d[t[i,k]] - d[t[i,1]] + sw[i,k]# precision of LOR distributions (with multi-arm trial correction) taud[i,k] <- tau *2*(k-1)/k# adjustment for multi-arm RCTs w[i,k] <- (delta[i,k] - d[t[i,k]] + d[t[i,1]])# cumulative adjustment for multi-arm trials sw[i,k] <- sum(w[i,1:k-1])/(k-1) } } totresdev <- sum(resdev[]) # Total Residual Devianced[1]<-0 # treatment effect is zero for reference treatment# vague priors for treatment effectsfor (k in 2:nt){ d[k] ~ dnorm(0,.0001) }sd ~ dunif(0,5) # vague prior for between-trial SDtau <- pow(sd,-2) # between-trial precision = (1/between-trial variance)# Provide estimates of treatment effects T[k] on the natural (probability) scale# Given a Mean Effect, meanA, for 'standard' treatment A, # with precision (1/variance) precAA ~ dnorm(meanA,precA)for (k in 1:nt) { logit(T[k]) <- A + d[k] }} # *** PROGRAM ENDS data { int<lower=0> ND; // Number of data points int<lower=0> NT; // Number of treatments int<lower=0> NS; // Number of studies int<lower=0> sampleSize[ND]; // Number of patients in study and treatment arm int<lower=0> responders[ND]; // Number of responders in study and treatment arm int<lower=1> treatment[ND]; // Treatment used in study and treatment arm int<lower=1> study[ND]; // Study for data point int<lower=1> treatment_base[ND]; // The first or control treatment per study} parameters { vector[NT] d; vector[NS] mu; real delta[NS,NT]; real<lower=0> sigmasq_delta; real delta_new;}transformed parameters { real<lower=0> sigma_delta; matrix[NS,NT] w; matrix[NS,NT] sw;// matrix[NS,NT] md;// matrix[NS,NT] vard;// matrix[NS,NT] sqrt_vard; sigma_delta <- sqrt(sigmasq_delta); for (i in 1:ND) { if (treatment[i] == 1) { w[study[i],treatment[i]] <- 0.0; // adjustment for multi-arm trials is zero for control arm } else { // adjustment for multi-arm RCTs w[study[i],treatment[i]] <- delta[study[i],treatment[i]] - d[treatment[i]] + d[treatment_base[i]]; // cumulative adjustment for multi-arm RCTs sw[study[i],treatment[i]] <- sum(w[study[i],1:(treatment[i]-1)])/(treatment[i]-1); }// md[study[i],treatment[i]] <- d[treatment[i]] - d[treatment_base[i]] + sw[study[i],treatment[i]];// vard[study[i],treatment[i]] <- (pow(sigmasq_delta, 2) * treatment[i])./(2 * (treatment[i]-1));// sqrt_vard[study[i],treatment[i]] <- sqrt(vard[study[i],treatment[i]]); }} model { for (i in 1:ND) { if (treatment[i] == 1) { responders[i] ~ binomial_logit(sampleSize[i], mu[study[i]]); } else { responders[i] ~ binomial_logit(sampleSize[i], mu[study[i]] + delta[study[i],treatment[i]]); } delta[study[i],treatment[i]] ~ student_t(4,d[treatment[i]],sigma_delta);// delta[study[i],treatment[i]] ~ normal(md[study[i],treatment[i]],sqrt_vard[study[i],treatment[i]]); mu[study[i]] ~ normal(0, sqrt(1E5)); d[treatment[i]] ~ normal(0, sqrt(1E5)); sigmasq_delta ~ inv_gamma(1E-2, 1E-2); }}here are whatever error messages were returned[[1]]Stan model 'TSD2-1cRE_Bi_logit' does not contain samples.
[[2]]Stan model 'TSD2-1cRE_Bi_logit' does not contain samples.
[[3]]Stan model 'TSD2-1cRE_Bi_logit' does not contain samples.
[[4]]Stan model 'TSD2-1cRE_Bi_logit' does not contain samples.
Warning messages:1: class "C++Object" is defined (with package slot ‘Rcpp’) but no metadata object found to revise subclass information---not exported? Making a copy in package ‘.GlobalEnv’ 2: In .local(object, ...) : some chains had errors; consider specifying chains = 1 to debug
consider specifying chains = 1 to debug" Stan can't start sampling from this initial value." [301] "Initialization between (--2, -2) failed after 100 attempts. " [302] " Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model."[1] "error occurred during calling the sampler; sampling not done"
--
You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/stan-users/yKOOfY7hGVg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to stan-users+...@googlegroups.com.