Closed ZekeMarshall closed 2 years ago
Hi Zeke,
Please could you explain what you mean? I understand the general idea of applying the itp() function to a fitted model object, but please could you explain more precisely what you would want this function to do?
Best wishes, Paul
Hi Paul,
Thanks for getting back to me.
For my purposes I am fitting a polynomial model to dose-response values, see below for an example where x = the dose and y = the response.
params <- data.frame(x = c(20, 60, 90, 120, 140, 160, 180, 230, 260, 290), y = c(1, 1, 1, 1, 0.9, 0.8, 0.7, 0.4, 0.2, 0.1))
model <- lm(data = params, y ~ poly(x, 3, raw = T))
Say I establish the category 0.75 < y <= 0.85, which is equal to "Very high response". I need the x (dose) values which correspond to the y range (response) (0.75 < y <= 0.85), and so need to find the root of the model above for y = 0.75 and y = 0.85.
The model above is equivalent to the following equation: y = 0.8849113353 + 0.0053553739x - 4.79279e-05x^2 + 6.83e-08*x^3
Which I could create a function for manually, for itp::itp() to evaluate. However, i'm looking to automate the fitting of a model, then calculation of the roots of said model in order to determine categories such as the "Very high response" category detailed above.
Apologies if {itp} is not designed for this sort of task!
Many thanks,
Zeke
You could use itp() to solve y = 0.75 and to solve y = 0.85, provided that you can set the argument interval to bracket the root. With a cubic equation you might have more than one root: two or perhaps even three. Then itp() would only find one root and you may need to think carefully about what is happening. I recall that there is a function uniroot.all() in the rootSolve package that tries to find multiple roots. Even then, I expect that you may benefit from using the information that your function is cubic. Indeed, there are specific methods for finding the roots of cubic equations That is, in this particular example, you may obtain more reliable results with code tailored to solving a cubic equation than code designed for more general cases.
Whether you use itp() or something else, I think that this case where you would write code that calls a root-finding function, rather than building this kind of feature into the root-finding function itself.
Thanks for your reply and advice @paulnorthrop - much appreciated!
Hi Paul,
Thanks for putting together this package, it's great!
I was wondering whether there was a way, or whether support was planned for calling the itp::itp() function on a model object, e.g. a model produced by stats::lm()?
Cheers,
Zeke