From a Model Prediction to a Simulated Measurement
An NLME model can provide a prediction for a particular subject and observation time, but a prediction is not the same as a measurement. The prediction represents the model's conditional mean, given the subject's parameters and the design. A simulated observation also includes residual error: the within-observation deviation that the fitted model assigns to the measurement process.
This distinction matters whenever a simulation is meant to resemble recorded data rather than only the model's expected profile. If residual error is omitted, repeated simulated measurements at the same time and for the same subject parameters will be identical. Adding residual error produces variation around that profile according to the residual model. The subject parameters and design determine the latent prediction; the residual-error model determines how an observation varies around it.
For this tutorial, suppose the fitted residual model is being used at fixed fitted parameter estimates and at already specified subject parameter values. This isolates the step of adding residual error; it does not draw new model parameters. Write \(z_{ij}\) for a draw from the standard normal distribution, \(N(0,1)\). The examples use such draws to make the arithmetic transparent. In an actual simulation, the values would be generated by a random-number generator.
Three Common Residual-Error Forms
An additive error model assigns a constant residual standard deviation over the prediction range. A proportional error model makes the residual standard deviation increase in proportion to the magnitude of the prediction. A combined model includes both components. These are alternative descriptions of the conditional spread around \(f_{ij}\); the model's stated units and scale must be respected.
The proportional term is often described through its coefficient of variation: its conditional residual standard deviation is \(\sigma_p |f_{ij}|\). For a positive prediction, the term \(\sigma_p f_{ij}z_{ij}\) has that standard deviation. The absolute value is relevant when stating the spread; the sign of \(f_{ij}\) does not affect the variance. In the combined model, the two error components are assumed independent, so their variances add.
These formulas rely on explicit assumptions. Conditional on the latent prediction, the residual components have mean zero; the normal draws have variance one; and residual draws for different records are independent unless the fitted model specifies dependence. The additive standard deviation is constant, and the proportional coefficient is constant over the records to which that model is applied. If the fitted model uses another residual distribution, a transformation, or a different variance function, simulations must follow that specification rather than substitute these formulas.
Worked Example: Additive Error at One Observation Time
Suppose a hypothetical fitted model gives a latent prediction of \(12.0\) mg/L for a record, and its additive residual standard deviation is \(1.5\) mg/L. For illustration, let the simulated standard-normal draw be \(z=-0.8\). The prediction is positive and the additive standard deviation is specified in the same units as the observation, so the additive formula is applicable.
The simulated measurement is \(10.8\) mg/L, while the latent prediction remains \(12.0\) mg/L. The draw happens to be below the prediction; additive error does not require every simulated value to be below it or to be positive. Under the assumed zero-mean model, the conditional mean remains \(12.0\) mg/L.
Worked Example: Proportional Error and Relative Spread
Suppose a hypothetical latent prediction is \(20.0\) mg/L and the proportional error coefficient is \(0.12\), corresponding to a residual standard deviation equal to 12% of the prediction. Let the standard-normal draw be \(z=1.25\). Since the prediction is positive and the coefficient is dimensionless, the error term has units of mg/L.
The proportional residual standard deviation at this prediction is \((0.12)(20.0)=2.4\) mg/L. The simulated positive deviation of \(3.0\) mg/L is therefore \(1.25\) conditional standard deviations above the latent prediction, matching the selected \(z\). At a prediction of \(10.0\) mg/L, the same coefficient would instead imply a standard deviation of \(1.2\) mg/L.
Combined Error and Its Conditional Variance
A combined model is useful when the residual spread has both a roughly constant component and a component that grows with the predicted magnitude. Its simulation requires two independent standard-normal draws for each record, one for each component. Using a single draw for both components would impose perfect dependence between them and would not implement the independent-components model stated here.
Worked Example: Simulating With Combined Error
Consider a hypothetical prediction of \(10.0\) mg/L, additive standard deviation \(\sigma_a=0.4\) mg/L, and proportional coefficient \(\sigma_p=0.10\). Let \(z_a=-0.5\) and \(z_p=1.2\). The components are assumed independent standard-normal draws, and the proportional contribution is \(0.10(10.0\ \text{mg/L})(1.2)\).
The additive contribution is \(-0.2\) mg/L and the proportional contribution is \(1.2\) mg/L, for a net residual of \(1.0\) mg/L. The combined conditional variance at this prediction is
Thus, the conditional standard deviation is \(\sqrt{1.16}=1.077\) mg/L. The simulated residual of \(1.0\) mg/L is consistent with that scale; it is not required to equal the conditional standard deviation.
The variance formula follows directly from the assumptions. Each standard-normal draw has mean zero and variance one. The additive component therefore has variance \(\sigma_a^2\), while the proportional component has variance \(\sigma_p^2 f_{ij}^2\). For independent components, the covariance is zero, so the variance of their sum is the sum of their variances.
The conditional mean of each of these three models is \(f_{ij}\), because the residual components have mean zero. For the combined model, the derived variance also shows how the two components affect spread across predictions: at \(f_{ij}=0\), the proportional contribution vanishes, while the additive contribution remains. At larger absolute predictions, the proportional contribution grows quadratically in the variance.
A Practical Simulation Sequence
Once the subject parameters and record design have been specified, the residual step can be organized as follows. The sequence keeps the deterministic model calculation separate from the random measurement step, which makes both implementation and checking easier.
Evaluate \(f_{ij}\) at the record's time and covariates using the subject-specific parameters already selected for the simulation.
Use the additive, proportional, or combined model, and use residual parameter estimates on the scale and in the units where they were estimated.
Use one standard-normal draw for additive or proportional error, and two independent standard-normal draws for the combined model defined above.
Add the sampled residual contribution to \(f_{ij}\). Retain \(f_{ij}\) separately if later summaries need to distinguish expected profiles from noisy measurements.
For several records from the same subject, calculate a latent prediction for each record and apply the residual model at each prediction. Unless dependence is specified, use independent residual draws across records. The same subject parameters can therefore yield a smooth latent profile and a different, noisy set of simulated measurements on every replicate.
Diagnostics, Alternatives, and Limitations
Check the simulated data against the residual model rather than judging a simulation by whether its values look smooth. For an additive model, simulated deviations should have roughly constant spread across the prediction range. For a proportional model, the spread should increase with the magnitude of the prediction. For a combined model, the variance should follow \(\sigma_a^2+\sigma_p^2f_{ij}^2\). These are implications of the model assumptions, not guarantees that any finite simulation will show a perfectly smooth pattern.
A practical check is to compare the saved latent predictions with the simulated observations. Compute each simulated residual as \(y_{ij}^{\mathrm{sim}}-f_{ij}\), then inspect whether its scale changes as the model says it should. Also verify that the estimated residual parameters have the expected units and that the random draws are centered near zero over a sufficiently large simulation. A systematic shift, an unexpectedly constant spread under a proportional model, or a rapidly increasing spread under an additive model may indicate a coding error or a mismatch between the implemented and fitted residual forms.
The main alternative is to report or simulate latent predictions only. That is appropriate when the target is the conditional mean profile, but it does not represent the scatter of individual measurements. Among noisy-observation models, additive error is simple and appropriate when a constant absolute standard deviation is credible; proportional error describes constant relative spread; and combined error allows both patterns. Choosing among them is a modeling decision informed by the fitted residual specification and the observed data, not a choice to make merely because one formula is convenient.
These simulations inherit the residual model's limitations. Normal additive error can produce negative observations, and proportional normal error can also produce a negative result, especially when variability is large relative to a small positive prediction. If the measured quantity cannot be negative, frequent negative simulations are a warning that the assumed error model or scale may be unsuitable; truncating values after simulation changes the implied distribution and is not automatically a valid fix. Likewise, if the fitted model defines error on a transformed response scale, adding noise on the original scale does not reproduce that model. Follow the fitted scale and transformation explicitly.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- A latent prediction is \(8.0\) mg/L, the additive residual standard deviation is \(0.6\) mg/L, and \(z=1.5\). What simulated observation results?
- For \(f=15.0\) mg/L and \(\sigma_p=0.08\), what is the proportional residual standard deviation? If \(z=-0.5\), what observation is simulated?
- In a combined model with \(\sigma_a=0.5\) mg/L, \(\sigma_p=0.10\), and \(f=4.0\) mg/L, calculate the conditional variance and standard deviation.
- Why can repeated simulations for the same subject and design have different observations even when the latent prediction is unchanged?
Solutions. 1. \(y^{\mathrm{sim}}=8.0+(0.6)(1.5)=8.9\) mg/L. 2. The proportional standard deviation is \((0.08)(15.0)=1.2\) mg/L, and \(y^{\mathrm{sim}}=15.0+(1.2)(-0.5)=14.4\) mg/L. 3. The variance is \(0.5^2+(0.10)^2(4.0)^2=0.25+0.16=0.41\ (\text{mg/L})^2\); the standard deviation is \(\sqrt{0.41}=0.6403\) mg/L. 4. Each replicate draws new residual error around the same latent prediction, so its simulated measurement can differ even though its subject parameters and design have not changed.