I am writing a function that allows many starting parameter combinations to be tried to fit nonlinear regression as nlsList()
only allows one set of starting parameters.
I have managed this fine but want to add a predictions data frame into the function for easy plotting that returns the best fit curve at smaller increments of x than the data supplies. For example having 100 points instead of 10 to achieve a nice smooth predicted curve.
In my function arguments I specify the formula as an argument and treat is a formula within the function. Some of the formulas include a function that I make to encompass the non-linear relationship. I then use do.call(function, new.starting params)
to pass on the predicted parameters onto a predictions data frame.
I have not found a way of isolating and passing any defined and fixed variables from the function to the do.call()
function.
Is there a way to get the values that are defined in the formula? So Tc = 25 in this example...
model = y ~ schoolfield.high(ln.c, Ea, Eh, Th, temp = x, Tc = 25)
formula <- as.formula(model)
vars <- all.vars(formula[[3]])
This returns :
"ln.c" "Ea" "Eh" "Th" "x"
I am wondering if there is a way to isolate defined variables from a formula object, or if there is any other way I could do this?