[R] Fit NLE - was: computer algebra in R
Leo Mada
|eo@m@d@ @end|ng |rom @yon|c@eu
Mon Dec 4 23:10:49 CET 2023
Fit NLE - was: [R] computer algebra in R
Original post:
https://stat.ethz.ch/pipermail/r-help/2023-November/478619.html
Dear Kornad,
I think I have started to understand what you try to achieve. The problem is to fit a NLE and compute the parameters of the NL-Eq. I have included the R Help-list back in the loop, as I am not an expert in optimization.
Goal:
y ~ I0 + IHD * hd + ID * d;
where:
y = given vector of measurements;
x = given vector of values;
I0, IHD, ID, kd = parameters to optimize;
hd = satisfies a polynomial of order 3;
As d = d0 - hd, the previous formula can be written:
y ~ I0 + ID * d0 + (IHD - ID) * hd;
f(x, hd, kd) = 0,
where f = a polynomial of order 3 in hd and order 2 in kd;
d0 (and other components of the polynomial) = given constants;
1) First Approach
I would back-substitute hd into the polynomial:
hd = (y - I0 - ID*d0) / (IHD - ID);
f(x, hd, kd) becomes then f(x, y, kd, I0, ID, IHD) = 0;
- f is order 3 in y;
You could fit:
(y^3) ~ f(x, y, kd, I0, ID, IHD) - y^3,
where you subtract the y^3 term from the function f, and add the (y^3) values as a new columng to the data.frame:
data.frame(y3 = y^3, y=y, x=x)
If the values of y are versy small (abs(y) << 1), then it may be wiser to fit:
y ~ f(x, y^2, y^3, kd, I0, ID, IHD) - (y-term);
But I am not an expert in these problems. Other R-users may be more helpful.
2.) Approach 2: Math
I feel that the problem can be solved quasy-exactly as well. It is much harder with 4 parameters to optimize:
- one needs to compute the 4 partial derivatives;
- solve the resulting system of 4 polynomial equations;
The system is polynomial; although it looks ugly and I am not inclined to do such calculations myself.
I hope that you can get more useful answers from the R help-list.
Sincerely,
Leonard
[[alternative HTML version deleted]]
More information about the R-help
mailing list