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

Simplify eta_agd_arm_noRE #31

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions inst/stan/binomial_1par.stan
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ transformed parameters {

// -- AgD model (arm-based) --
if (ni_agd_arm) {
if (nint_max > 1) { // -- If integration points are used --
vector[nint_max * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;
vector[nint_max * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;

if (nint_max > 1) { // -- If integration points are used --
if (RE) {
if (link == 1) { // logit link
for (i in 1:ni_agd_arm) {
Expand Down Expand Up @@ -81,10 +81,6 @@ transformed parameters {
}
} else { // -- If no integration --
if (RE) {
vector[nint * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;

if (link == 1) { // logit link
for (i in 1:ni_agd_arm) {
if (which_RE[narm_ipd + i])
Expand All @@ -109,17 +105,11 @@ transformed parameters {
}
} else {
if (link == 1) // logit link
theta_agd_arm_bar = has_offset ?
inv_logit(X_agd_arm * beta_tilde + offset_agd_arm) :
inv_logit(X_agd_arm * beta_tilde);
theta_agd_arm_bar = inv_logit(eta_agd_arm_noRE);
else if (link == 2) // probit link
theta_agd_arm_bar = has_offset ?
Phi(X_agd_arm * beta_tilde + offset_agd_arm) :
Phi(X_agd_arm * beta_tilde);
theta_agd_arm_bar = Phi(eta_agd_arm_noRE);
else if (link == 3) // cloglog link
theta_agd_arm_bar = has_offset ?
inv_cloglog(X_agd_arm * beta_tilde + offset_agd_arm) :
inv_cloglog(X_agd_arm * beta_tilde);
theta_agd_arm_bar = inv_cloglog(eta_agd_arm_noRE);
}
}
}
Expand Down
24 changes: 7 additions & 17 deletions inst/stan/binomial_2par.stan
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ transformed parameters {

// -- AgD model (arm-based) --
if (ni_agd_arm) {
if (nint_max > 1) { // -- If integration points are used --
vector[nint_max * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;
vector[nint_max * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;

if (nint_max > 1) { // -- If integration points are used --
if (RE) {

if (link == 1) { // logit link
Expand Down Expand Up @@ -88,10 +88,6 @@ transformed parameters {
}
} else { // -- If no integration --
if (RE) {
vector[nint * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;

if (link == 1) { // logit link
for (i in 1:ni_agd_arm) {
if (which_RE[narm_ipd + i])
Expand All @@ -116,17 +112,11 @@ transformed parameters {
}
} else {
if (link == 1) // logit link
theta_agd_arm_bar = has_offset ?
inv_logit(X_agd_arm * beta_tilde + offset_agd_arm) :
inv_logit(X_agd_arm * beta_tilde);
theta_agd_arm_bar = inv_logit(eta_agd_arm_noRE);
else if (link == 2) // probit link
theta_agd_arm_bar = has_offset ?
Phi(X_agd_arm * beta_tilde + offset_agd_arm) :
Phi(X_agd_arm * beta_tilde);
theta_agd_arm_bar = Phi(eta_agd_arm_noRE);
else if (link == 3) // cloglog link
theta_agd_arm_bar = has_offset ?
inv_cloglog(X_agd_arm * beta_tilde + offset_agd_arm) :
inv_cloglog(X_agd_arm * beta_tilde);
theta_agd_arm_bar = inv_cloglog(eta_agd_arm_noRE);
}

theta2_agd_arm_bar = theta_agd_arm_bar .* theta_agd_arm_bar;
Expand Down
20 changes: 6 additions & 14 deletions inst/stan/normal.stan
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ transformed parameters {

// -- AgD model (arm-based) --
if (ni_agd_arm) {
if (nint_max > 1) { // -- If integration points are used --
vector[nint_max * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;
vector[nint_max * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;

if (nint_max > 1) { // -- If integration points are used --
if (RE) {

if (link == 1) { // identity link
Expand Down Expand Up @@ -77,10 +77,6 @@ transformed parameters {
}
} else { // -- If no integration --
if (RE) {
vector[nint * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;

if (link == 1) { // identity link
for (i in 1:ni_agd_arm) {
if (which_RE[narm_ipd + i])
Expand All @@ -98,13 +94,9 @@ transformed parameters {
}
} else {
if (link == 1) // identity link
theta_agd_arm_bar = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;
theta_agd_arm_bar = eta_agd_arm_noRE;
else if (link == 2) // log link
theta_agd_arm_bar = has_offset ?
exp(X_agd_arm * beta_tilde + offset_agd_arm) :
exp(X_agd_arm * beta_tilde);
theta_agd_arm_bar = exp(eta_agd_arm_noRE);
}
}
}
Expand Down
16 changes: 5 additions & 11 deletions inst/stan/poisson.stan
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ transformed parameters {

// -- AgD model (arm-based) --
if (ni_agd_arm) {
if (nint_max > 1) { // -- If integration points are used --
vector[nint_max * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;
vector[nint_max * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;

if (nint_max > 1) { // -- If integration points are used --
if (RE) {

if (link == 1) { // log link
Expand Down Expand Up @@ -62,10 +62,6 @@ transformed parameters {
}
} else { // -- If no integration --
if (RE) {
vector[nint * ni_agd_arm] eta_agd_arm_noRE = has_offset ?
X_agd_arm * beta_tilde + offset_agd_arm :
X_agd_arm * beta_tilde;

if (link == 1) { // log link
for (i in 1:ni_agd_arm) {
if (which_RE[narm_ipd + i])
Expand All @@ -76,9 +72,7 @@ transformed parameters {
}
} else {
if (link == 1) // log link
theta_agd_arm_bar = has_offset ?
exp(X_agd_arm * beta_tilde + offset_agd_arm) :
exp(X_agd_arm * beta_tilde);
theta_agd_arm_bar = exp(eta_agd_arm_noRE);
}
}
}
Expand Down
Loading