easystats / insight

:crystal_ball: Easy access to model information for various model objects
https://easystats.github.io/insight/
GNU General Public License v3.0
392 stars 39 forks source link

Non-linear models #66

Open strengejacke opened 5 years ago

strengejacke commented 5 years ago

It would be nice to have support for non-linear models like nls, nlrob or nlmer, but I have no experience with such models and no idea what might be important to extract.

See the first example here: https://stat.ethz.ch/R-manual/R-patched/library/stats/html/nls.html

The data used two fit the model has three variables, the formula however has further parameters in the "non-linear" part, which don't appear in the data. However, in the summary, these parameters are the only ones that are shown.

I don't know how to deal with this models, but maybe in the future we have an idea how to implement this.

DominiqueMakowski commented 5 years ago

Let's wait for the input of a user of these models. Maybe for get_parameters, we could stick to what coef() gives, but the problem arises for find_variables 😕

strengejacke commented 5 years ago

@mattansb @humanfactors @pdwaggoner @IndrajeetPatil

Since you "joined" later than 25 March (if I recall right), may I point you to this issue? Anyone of you who has more experiences with non-linear models?

mattansb commented 5 years ago

None, sorry...

pdwaggoner commented 5 years ago

I don't have experience with these either, practically. But I get the idea of nonlinear models reasonably well and would be open to thinking about this, if we decide its something worth pushing forward on. Let me know

IndrajeetPatil commented 5 years ago

Unfortunately, I don't have much experience working with non-linear models as well.

DominiqueMakowski commented 5 years ago

humanfactors commented 5 years ago

Yeah sorry team, I also have virutally no experience with non-linear models!

fmmattioni commented 4 years ago

Hi guys! While developing my new package {whippr}, I found myself in the need to create some things on my own, since the base function predict.nls not even supports the extraction of confidence bands and prediction bands.

I was greatly inspired by this post and by this paper from the {nlstools} package.

Regarding residuals, I created these two functions. The function model_diagnostics() was inspired by the {see} package.

Regarding the extraction of prediction and confidence bands, I created this function. However, this function is not generalized. It is very specific to the non-linear model I am using. By the way, if you guys have any ideas on how I could generalize this, that would be greatly appreciated!

In this vignette I explain the important information that I extract from the non-linear model used in this specific analysis. Let me know if I could help some how for {insight} or {see} to support nls models.

strengejacke commented 4 years ago

Thanks Felipe for these "insights" (haha...) I'll look into this the next days, and it's good to see this discussion developing. Maybe we can indeed implement nls-support in the (near) future in our easystats-eco-system...

fmmattioni commented 4 years ago

That would be really cool! Thank you!

strengejacke commented 4 years ago

https://www.granvillematheson.com/post/nonlinear-modelling-using-nls-nlme-and-brms/

femiguez commented 3 years ago

I am willing to contribute support for nonlinear models (nls and nlme), but it will take me a few weeks, since I'm busy with other projects at the moment.

bwiernik commented 3 years ago

The propagate::predictNLS() in propagate also has another approach to generating uncertainty bands on NLS predictions.

femiguez commented 3 years ago

I just tried installing propagate and I get an error related to the gmm package.

> library(gmm) Error: package or namespace load failed for ‘gmm’ in get(Info[i, 1], envir = env): lazy-load database '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmm/R/gmm.rdb' is corrupt In addition: Warning message: In get(Info[i, 1], envir = env) : internal error -3 in R_decompress1

That function only works for nls objects, correct?

bwiernik commented 3 years ago

You can find the source here: https://github.com/cran/propagate. It uses an adaptive Delta Method to propagate uncertainty through Monte Carlo simulations.

There have been many issues with gmm on macs recently, especially M1 hardware which doesn't have a Fortran compiler. You could try to reinstall gmm and see if the issue resolves for you. Otherwise just perhaps compare the approach to the others cited.

femiguez commented 3 years ago

@bwiernik Yes, the problem is on my Mac. On Windows gmm installed fine. It would be interesting to compare propagate::predictNLS with nlraa::predict_nls, but this is a bit outside of what I'm willing to do in the short term. Right now, nlraa works with objects of class 'lme', 'gls', 'gnls', 'nlme' and 'nls', which is what I could reasonably contribute.