Hi.

On Wed, 9 Sep 2015 10:15:56 +0200, Thom Brown wrote:
Hi,

So, if you have N observations (indexed by the time variable), you'll have
3 * N measurements. And the "target" will be for example:

[S(t0), b(t0), I(t0), S(t1), b(t1), I(t1), ..., S(tN), b(tN), I(tN)]


That means I have to specify a vector for each t? Like in the example, but instead of x,y coordinates of a point I need to use S, b, I? What I haven't realized by the time I asked the question is that the fourth equation for the prediction is also essential. I do not need a forecast per se, but by calculating F(t) = (S(t) + b(t)) * I(t-L) I get the new value of X(t). So, the vector would contain (S(t), b(t), I(t), F(t) and what about X(t), which
is the real observation?

The target contains the observations. Thus X(t) for t in {t0, ..., tN}.

IIUC, the model is "F(t)". That is what must be defined in the first part
of the "MultivariateJacobianFunction".
[Since the model "F(t)" refers to earlier times, I guess that you'll have to create a specific class in order to look up the correct "S", "b" and "I".]

Basically I need only an approximation for alpha, beta and gamma, so I thought I would use the first two periods, i.e., [S(L), b(L), I(L), F(L), ..., S(L+L), b(L+L), I(L+L), F(L+L)]. What still confuses me is that I'm
not sure if I can simple process the parameters this way. In order to
calculate the parameters for t = L I need the initial parameters (I can provide them). But do I then have to use a set of [S(L-1), b(L-1), I(L-1), F(L-1), S(L), b(L), ..., I(L+L)]? And how can I make sure that S(L-1), ...,
will not be part of the optimization?

I don't quite understand. But I suppose that this should be rephrased in
light of the previous answer.

Basically the minimum I'm searching for is SUM((F(i) - X(i))^2) / 2L (just the MSE). Do I have to put that in the jacobian matrix via setEntry()?

No.
The classes in the "leastsquares" package implicitly solve this problem. [You only need to provide the "target", "model", and some initial values
of the parameters to be optimized.]

You must provide the Jacobian (in the "model" function), i.e. a matrix where each line corresponds to a measurement, and the columns must be the partial
derivatives wrt the parameters (i.e. "alpha", "beta" and "gamma").


Which makes me want to answer my previous question with no, however, where
else do I specify the MSE calculation?

Nowhere indeed. ;-)

And then again, I'm wondering: does
my matrix consist of 5 columns? {X(i), S(i), b(i), I(i), F(i)}?

No. (IIUC) the Jacobian will contain the partial derivative of the model wrt
each of the parameters (thus: 3 columns).

Or do I
have to create one equation where I put all my parameters in (I'm not sure
I'm able to do such a thing :P).

My main problem is that I obviously fail to understand on how to use such a optimizer. I have four equations and so far I have only seen on how to use it on a rather simple example. That leaves me with the question on how to
specify four different equations in the same Jacobian?

jacobian.setEntry(i, 0, -equation for S(t)-);
jacobian.setEntry(i, 1, -equation for b(t)-);
jacobian.setEntry(i, 2, -equation for I(t)-);
jacobian.setEntry(i, 3, -equation for F(t)-);

Rather:
jacobian.setEntry(i, 0, dF/d(alpha))
jacobian.setEntry(i, 1, dF/d(beta))
jacobian.setEntry(i, 2, dF/d(gamma))


Just like that? Ohh.. I think I understand ... so that's where I have to put the derivatives for each equation? And via jacobian.setEntry(i, ((F(i)
- X(i))^2) I provide the minimization I'm looking for?

No (cf above).

Why would you, since the derivatives are relatively easy to provide?


The derivative for S(t)/d(alpha) would be -b(t-1) - S(t-1) - I(t-L) * X
then? Am I correct in that?

I'm a bit confused because in the link you referred to, there is no "X":
  http://www.itl.nist.gov/div898/handbook/pmc/section4/pmc435.htm

If "X" here is "y" there, then
  dS/d(alpha) = X(t) / I(t-L) - b(t-1) - S(t-1)

I'm sorry for that math question instead of
focusing on the apache commons framework, but it would help me to
understand the task better. :)

You could perhaps get more insight by downloading the source code of
the unit tests.  I'd suggest to look at "testBevington()".

Best regards,
Gilles




Thank for very much for your help so far. At least I'm beginning to
understand. :D


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org

Reply via email to