Hi Emily,
Make sure you have gone through the VPC tutorial - Visual Predictive Checks for Continuous Data Models
It looks like you are running a Visual Predictive Check (VPC) in Pumas and noticing that the lower quantile (e.g., 10th percentile) drops into negative values at later time points, which is not physiologically plausible for your data (e.g., concentrations). This is a common issue, especially when using an additive error model or when the model does not fit the data well at low concentrations. It really depends a lot on the error model that you are using.
Here are some steps and considerations to help you troubleshoot and improve your VPC:
1. Check Your Error Model
If your model uses an additive error structure, it can predict negative concentrations, especially at low values. This is a well-known limitation of additive error models. If your data are concentrations (which cannot be negative), a proportional or combined error model is usually more appropriate.
Example:
# In your model definition, use a proportional or combined error model
@derived begin
dv ~ @. Normal(μ, sqrt(σ_add^2 + (μ * σ_prop)^2))
end
Or, if you only want proportional error:
@derived begin
dv ~ @. Normal(mu, mu * σ_prop)
end
2. Inspect the Model Fit
A poor model fit, especially at the tail end of your data (e.g., late time points), can cause the simulated quantiles to be too low or negative. Check your model diagnostics and consider whether the structural model or parameter estimates need refinement.
3. Consider Prediction Correction
If your study design is heterogeneous (e.g., different doses, covariates), using prediction_correction = true can help normalize the data and simulated values, making the VPC more robust to design differences.
Example:
vpc_result = vpc(
myfitobj;
samples = 500,
observations = [:dv],
quantiles = (0.1, 0.5, 0.9),
level = 0.95,
prediction_correction = true, # Try enabling this
)
Note: You cannot use stratify_by and prediction_correction together. This may be allowed in later versions
4. Adjust the Bandwidth
The bandwidth parameter controls the smoothing of quantile regression. If the bandwidth is too small, the quantile lines may be too wiggly and sensitive to outliers; if too large, they may be overly smoothed and not reflect the data well. Try adjusting the bandwidth (default is 2.0 for continuous VPCs).
Example:
vpc_result = vpc(
myfitobj;
samples = 500,
observations = [:dv],
quantiles = (0.1, 0.5, 0.9),
level = 0.95,
prediction_correction = false,
bandwidth = 2.5 # Try increasing or decreasing this value
)
5. Check for Data Issues
- Are there outliers or unphysiological values in your data?
- Are there very few observations at late time points, making quantile estimation unstable?
6. Plot and Interpret
After running the VPC, use vpc_plot to visualize the results:
using Pumas, AlgebraOfGraphics, CairoMakie
plt = vpc_plot(vpc_result)
Summary Table
| Issue |
Solution/Check |
| Negative quantiles |
Use proportional/combined error model |
| Poor fit at late times |
Refine model, check parameter estimates |
| Outliers/unstable quantiles |
Adjust bandwidth, clean data |
| Heterogeneous design |
Try prediction correction |
If you try these suggestions and still see negative quantiles, please provide more details about your model structure and error model.