You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When turning on threading for non-looped non-linear models, the provided non-linear function will get a mix of partial and full data structures. The partial log lik function generated looks like this (see example code below):
// compute partial sums of the log-likelihoodreal partial_log_lik_lpmf(int[] seq, int start, int end, vector Y, matrix X_ult, vector b_ult, matrix X_omega, vector b_omega, matrix X_theta, vector b_theta, int[] C_1, int[] C_2, int[] C_3, real sigma, int[] J_1, vector Z_1_ult_1, vector r_1_ult_1) {
real ptarget =0;
int N = end - start +1;
// initialize linear predictor termvector[N] nlp_ult = X_ult[start:end] * b_ult;
// initialize linear predictor termvector[N] nlp_omega = X_omega[start:end] * b_omega;
// initialize linear predictor termvector[N] nlp_theta = X_theta[start:end] * b_theta;
// initialize non-linear predictor termvector[N] mu;
for (n in1:N) {
// add more terms to the linear predictorint nn = n + start -1;
nlp_ult[n] += r_1_ult_1[J_1[nn]] * Z_1_ult_1[nn];
}
// compute non-linear predictor values
mu = growth_test(nlp_ult , C_1 , nlp_theta , nlp_omega , C_2 , C_3);
ptarget +=normal_lpdf(Y[start:end] | mu, sigma);
return ptarget;
}
The issue is that now the parameters have a size according to the partial sum block while the covariates span the entire data-set (and the non-linear function does not get start and end; this cannot figure out how things line up). I think a consistent solution would be this:
// compute partial sums of the log-likelihoodreal partial_log_lik_lpmf(int[] seq, int start, int end, vector Y, matrix X_ult, vector b_ult, matrix X_omega, vector b_omega, matrix X_theta, vector b_theta, int[] C_1, int[] C_2, int[] C_3, real sigma, int[] J_1, vector Z_1_ult_1, vector r_1_ult_1) {
real ptarget =0;
int N = end - start +1;
// initialize linear predictor termvector[N] nlp_ult = X_ult[start:end] * b_ult;
// initialize linear predictor termvector[N] nlp_omega = X_omega[start:end] * b_omega;
// initialize linear predictor termvector[N] nlp_theta = X_theta[start:end] * b_theta;
// initialize non-linear predictor termvector[N] mu;
for (n in1:N) {
// add more terms to the linear predictorint nn = n + start -1;
nlp_ult[n] += r_1_ult_1[J_1[nn]] * Z_1_ult_1[nn];
}
// compute non-linear predictor values
mu = growth_test(nlp_ult , C_1[start:end], nlp_theta , nlp_omega , C_2[start:end] , C_3[start:end]); // <-- here the covariates should be subsetted to start:end to have the same length as the other variables
ptarget +=normal_lpdf(Y[start:end] | mu, sigma);
return ptarget;
}
When turning on threading for non-looped non-linear models, the provided non-linear function will get a mix of partial and full data structures. The partial log lik function generated looks like this (see example code below):
The issue is that now the parameters have a size according to the partial sum block while the covariates span the entire data-set (and the non-linear function does not get
start
andend
; this cannot figure out how things line up). I think a consistent solution would be this:Here is the full toy example:
The text was updated successfully, but these errors were encountered: