insight icon indicating copy to clipboard operation
insight copied to clipboard

Non-linear models

Open strengejacke opened this issue 6 years ago • 16 comments

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.

strengejacke avatar Mar 24 '19 22:03 strengejacke

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 😕

DominiqueMakowski avatar Mar 25 '19 00:03 DominiqueMakowski

@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?

strengejacke avatar Jun 05 '19 12:06 strengejacke

None, sorry...

mattansb avatar Jun 05 '19 12:06 mattansb

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

pdwaggoner avatar Jun 05 '19 13:06 pdwaggoner

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

IndrajeetPatil avatar Jun 05 '19 15:06 IndrajeetPatil

DominiqueMakowski avatar Jun 05 '19 15:06 DominiqueMakowski

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

humanfactors avatar Jun 06 '19 01:06 humanfactors

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.

fmmattioni avatar Apr 18 '20 11:04 fmmattioni

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...

strengejacke avatar Apr 18 '20 11:04 strengejacke

That would be really cool! Thank you!

fmmattioni avatar Apr 18 '20 11:04 fmmattioni

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

strengejacke avatar May 27 '20 15:05 strengejacke

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.

femiguez avatar Apr 16 '21 12:04 femiguez

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

bwiernik avatar Apr 16 '21 14:04 bwiernik

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?

femiguez avatar Apr 16 '21 14:04 femiguez

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.

bwiernik avatar Apr 16 '21 14:04 bwiernik

@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.

femiguez avatar Apr 16 '21 15:04 femiguez