Pandora-IsoMemo / DSSM

Pandora & IsoMemo spatiotemporal modeling (DSSM)
https://pandora-isomemo.github.io/DSSM/
GNU General Public License v3.0
4 stars 1 forks source link

Warning Message in IsoMemo #199

Closed CarloCocozza closed 2 months ago

CarloCocozza commented 4 months ago

Warning Message

For every Bayesian model I run, I receive this warning message. However, this does not seem to affect the modelling which is still run fine.

Try the attached dataset as reference: North American Animals Filtered for Baseline.xlsx

@arunge

arunge commented 3 months ago

@CarloCocozza as mentioned in https://github.com/Pandora-IsoMemo/iso-app/issues/207#issuecomment-2079356815 I also got the warning:

image

Chatgpt explains the warning as follows bellow. Maybe this helps to understand the problem.

The warning message "simpleWarning in smooth.construct.ds.smooth.spec(object, dk$data, dk$knots): s value modified to give continuous function" you're seeing in R typically comes from using smoothing functions, such as those found in the gam package for Generalized Additive Models (GAMs), or other similar statistical modeling functions that involve smoothing splines. This warning is related to the smoothing parameter s used in these models.

Understanding the Warning:

  1. Background: In smoothing techniques like splines used in GAMs and other regression models, the s parameter controls the smoothness of the spline fit. It essentially governs the trade-off between the smoothness of the fit and fidelity to the data points—higher values lead to smoother curves that may underfit the data, while lower values can lead to a wiggly curve that overfits the data.

  2. Cause of the Warning: The warning message indicates that the smoothing parameter s you specified (or was automatically chosen by the model) was adjusted internally by the algorithm to ensure the resulting spline is a continuous function. This adjustment is typically made to avoid numerical problems or impractical fits, such as attempting to fit a spline that is too wiggly (overfitting) or too smooth (underfitting) beyond the adaptive capacity of the model framework.

  3. Implication: The model's fitting process has modified the smoothing parameter to avoid an overfitting or underfitting problem, ensuring that the resulting model is stable and meaningful.

Dealing with the Warning:

Here are some approaches to handle or respond to this warning:

  • Understanding Model Output: First, check if the model's output is reasonable despite the warning. If the model performance and diagnostics (like residuals, fitted values) look good, the warning may not be critical.

  • Adjust Smoothing Parameter: If you have direct control over the smoothing parameter s (like in gam() or loess()), try adjusting its value. If you set it too high or too low, consider finding a more balanced value based on model diagnostics or using cross-validation techniques.

  • Use Automatic Selection: If available, use methods or options in the function that allow for automatic selection of the smoothing parameter. For example, method = "REML" or method = "GCV.Cp" in the gam() function from the mgcv package, which use restricted maximum likelihood or generalized cross-validation to estimate an optimal s.

  • Increase Flexibility: If the model is overly adjusting s because of limited flexibility (due to few knots in spline models, for example), increase the number of knots or the basis dimension to give the model more flexibility to fit the data without needing to over-correct s.

  • Consult Documentation and Vignettes: Different functions and packages have their own nuances in handling smoothing parameters. It’s often beneficial to look at the specific documentation for guidelines on setting or controlling these parameters effectively.

By exploring these options, you can better understand and control how the smoothing parameter influences your model's fit and adjust accordingly to mitigate warnings and improve model performance.

We could think of adding some new user inputs for controlling the model. Currently, the app offers following inputs: image

I can discuss this issue with @isomemo next time, and we can decide if I should check the code for possible new parameters.

isomemo commented 2 months ago

@arunge yes, best approach here is to add the new options

mgross commented 2 months ago

@arunge @CarloCocozza :

This should fix the warning, it was a too lazy implementation by myself

https://github.com/Pandora-IsoMemo/iso-app/pull/217

arunge commented 2 months ago

@mgross thanks for your help here! I will check and test your changes and add them, if all works as expected.

arunge commented 2 months ago

The fix was merged and is available with version 24.05.4 on DSSM beta. I am closing here.