insight
insight copied to clipboard
Support for nonlinear models
I'm adding this as an issue so that it can be discussed before I propose more changes. I would be happy to contribute changes to support (or enhance) objects of class: nls, gls, gnls, lme and nlme.
One of the issues is how 'find_terms', 'find_parameters' should behave. I understand the distinction between terms and variables in linear mixed models, but it is not clear to me that this distinction is meaningful for nonlinear (mixed) models. I think I need to make changes to find_predictors and make find_terms return the same as find_predictors. Then users can clearly separate parameters vs. predictors (variables). (I don't think there is a distinction between 'predictors' and ' independent variables' in nonlinear models - of the types in the nlme library).
These are a couple of examples of what find_terms and find_predictors return at the moment.
DNase1 <- subset(DNase, Run == 1)
## using a selfStart model
fm1DNase1 <- nls(density ~ SSlogis(log(conc), Asym, xmid, scal), DNase1)
find_terms(fm1DNase1) ## Not what we want
find_predictors(fm1DNase1) ## I think this should just return 'conc'
find_variables(fm1DNase1) ## This is better IMO, although 'conc' is a variable and Asym, xmid and scal are parameters
Perhaps find_terms should just return 'conc' instead. In this case it might seem obvious that it should be log(conc), but in the next example is not.
fm2DNase1 <- nls(density ~ 1/(1 + exp((xmid - log(conc))/scal)),
data = DNase1,
start = list(xmid = 0, scal = 1),
algorithm = "plinear")
find_terms(fm2DNase1) ## again not what we would want
find_predictors(fm2DNase1) ## returns predictors AND parameters
find_variables(fm2DNase1) ## conc is a variable and xmid and scal are parameters
Let me know what you think.
I agree that find_terms is less consistently clear with nonlinear models. I think that we can make find_terms and find_predictors return the same for nonlinear models. This would also apply to brms models in nonlinear mode i think