# Non-linear transform warning in GLM with measurement error in outcome variable

Hi everyone,

I am receiving the following warning message:

DIAGNOSTIC(S) FROM PARSER:
Info (non-fatal):
Left-hand side of sampling statement (~) may contain a non-linear transform of a parameter or local variable.
If it does, you need to include a target += statement with the log absolute determinant of the Jacobian of the transform.
Left-hand-side of sampling statement:
date ~ beta(…)

In the online examples I could find where this warning pops up, I understand where the issue arises (e.g., a prior placed on a variable that is a non-linear transformation of another variable). In my own case, I am a little fuzzy on how to proceed.

I am working with a model with a beta likelihood. There is measurement error in the outcome variable, and this takes the form of an unknown value within a known interval. I formulated the model similar to the rounding error section in the Stan user’s guide. Here, the lower bound and range of the known interval are included as data, and the “true” value is obtained by multiplying the range by a parameter and adding it to the lower bound. There is an ordered categorical predictor.

The warning seems to arise as a consequence of the “true” value line in the transformed parameters block and the likelihood statement in the model block. However, I assume that the line in the transformed parameters block is a linear transformation. Is the warning not applicable in this scenario, or am I missing something? I am a novice when it comes to modelling generally, so I assume the latter. The model does seem to sample well (all n_eff/n > 0.2, all rhat < 1.01, trace plots look ok), but that’s little assurance if the posteriors are biased.

This is being done in rstan (2.19.2), R 3.6.1, on a Windows 10 machine.

Thanks
Ryan

``````data{

int<lower=0> n;
int<lower=0> n_bores;
int<lower=1> bore[n];
vector<lower=0,upper=1>[n] date_lower;
vector<lower=0,upper=1>[n] date_range;
int<lower=1> bores[n_bores];
vector[n_bores] alpha;

}
parameters{

vector<lower=0>[n_bores] bore_phi;
real<lower=0> phi_a;
real<lower=0> phi_b;
real<lower=0, upper=1> Bbore;
simplex[n_bores] delta;

// Measurement error parameter vector
vector<lower=0, upper=1>[n] d_err;

}
transformed parameters {

vector[n] date; // true dates

// Model for true  values
// Min bound + measurement error parameter * range
date = date_lower + d_err .* date_range;

}
model{
vector[n] mu;
vector[n] phi;

delta ~ dirichlet( alpha );

// Prior for measurement error
d_err ~ beta( 1, 1 );

bore_phi ~ gamma( phi_a + 1, phi_b );
phi_a ~ exponential( 0.2 );
phi_b ~ exponential( 3 );
Bbore ~ beta( 2, 2 );

// Linear models for mu and phi
for( i in 1:n ){
mu[i] = Bbore * sum( delta[1:bore[i]] );
phi[i] = bore_phi[bore[i]];
}

// Likelihood
date ~ beta( mu .* phi, ( 1 - mu ) .* phi );

}
``````
1 Like

Yes, that transform is linear and the warning is a false alert. Looks like the compiler doesn’t know that vectorized `.*` is still linear.

2 Likes

That’s good to know, thanks!