close Warning: Can't synchronize with repository "(default)" (/var/svn/tolp does not appear to be a Subversion repository.). Look in the Trac log for more information.

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#707 closed defect (fixed)

InterpolaL (StdLib) works wrong for a Series with negative changes only

Reported by: Alfredo Torre Owned by: Víctor de Buen Remiro
Priority: highest Milestone:
Component: Various Version: 1.1.7
Severity: blocker Keywords: InterpolaL, negative changes
Cc:

Description (last modified by Víctor de Buen Remiro)

InterpolaL (from StdLib) works wrong when the original Series only has negative changes and, at least, one no change. Please, see the next example:

Serie Ser.Qua = SubSer(
100*Pulse(y2009m01d01, Quarterly) +
 90*Pulse(y2009m04d01, Quarterly) +
 90*Pulse(y2009m07d01, Quarterly) +
 80*Pulse(y2009m10d01, Quarterly),
y2009m01d01, y2010m01d01);
Serie Ser.Mon = InterpolaL(Ser.Qua, Monthly);


The problem is in InvChEx function. I suggest this new code for InterpolaL:

Serie InterpolaL(Serie ser, TimeSet dtn)
{
  Serie dser   = ((F-1):ser)>>CalInd(W,Dating(ser));
  Serie iper   = SubSer(CalVar(dtn,Dating(ser)),First(ser),Last(ser));
  Serie inc    = dser/iper;
  Serie dNser1 = InvCh(inc, Log(CalInd(W, dtn2)));
  Serie dNser2 = ExpandOmit(dNser1);
  Serie dNser  = (B):dNser2;
  Date  ini    = Succ(First(dNser),dtn,-1);
  Serie sIniP  = FirstS(ser)*CalInd(C,dtn);
  Serie sIni   = SubSer(sIniP,ini,ini);
  SubSer(DifEq(1/(1-B),dNser,sIni),ini,Last(ser))
};

Attachments (1)

interpolate.tol (4.5 KB) - added by Víctor de Buen Remiro 16 years ago.
Interpolation functions

Download all attachments as: .zip

Change History (9)

comment:1 Changed 16 years ago by Víctor de Buen Remiro

Description: modified (diff)

Changed 16 years ago by Víctor de Buen Remiro

Attachment: interpolate.tol added

Interpolation functions

comment:2 Changed 16 years ago by Víctor de Buen Remiro

Status: newassigned

I dont't know who's the author of this function nor what is its target nor nothing about it.

I'm using my own interpolation attached functions.

Serie Ser.Qua = SubSer(
100*Pulse(y2009m01d01, Quarterly) +
 90*Pulse(y2009m04d01, Quarterly) +
 90*Pulse(y2009m07d01, Quarterly) +
 80*Pulse(y2009m10d01, Quarterly),
y2009m01d01, y2010m01d01);
Serie Ser.Mon = InterpolaL(Ser.Qua, Monthly);

//Linear interpolation
Serie Ser.Mon_1 = InvChInterp(Ser.Qua, Monthly, "LinearSpline", 1);
//Akima (smooth cubic) interpolation
Serie Ser.Mon_3 = InvChInterp(Ser.Qua, Monthly, "AkimaSpline", 3);

If you want to test them I can to add them to StdLib.

comment:3 Changed 16 years ago by Alfredo Torre

That's great!

Just two more things to check if I've understood:

.- You suggest to create those functions in StdLib so they can be available in TOL. My doubt now is: aren't available now? Did you built them for this ticket?

.- Should InterpolaL be changed as

Serie InterpolaL(Serie ser, TimeSet dtn)
{ InvChInterp(ser, dtn, "LinearSpline", 1) };

?

comment:4 Changed 16 years ago by Víctor de Buen Remiro

It will be changed in next release (tomorrow)

comment:5 Changed 16 years ago by Alfredo Torre

Ok, thank you very much.

Looking forward to use it!

comment:6 Changed 16 years ago by Víctor de Buen Remiro

Resolution: fixed
Status: assignedclosed

(In [1141]) New interpolation methods in NameBlock StdLib::interpolate
Fixes #707

comment:7 Changed 16 years ago by Víctor de Buen Remiro

Finally I've created a NameBlock StdLib::Interpolate for all interpolation related methods.

Serie Ser.Qua = SubSer(
100*Pulse(y2009m01d01, Quarterly) +
 90*Pulse(y2009m04d01, Quarterly) +
 90*Pulse(y2009m07d01, Quarterly) +
 80*Pulse(y2009m10d01, Quarterly),
y2009m01d01, y2010m01d01);
Serie Ser.Mon = InterpolaL(Ser.Qua, Monthly);

//Inverse dating change by means of linear interpolation
Serie Ser.Mon_1 = Interpolate::Scalar::invCh(Ser.Qua, Monthly, "LinearSpline", 1);
//Inverse dating change by means of Akima interpolation (smooth polynomial spline)
Serie Ser.Mon_3 = Interpolate::Scalar::invCh(Ser.Qua, Monthly, "AkimaSpline", 3);

comment:8 Changed 16 years ago by Víctor de Buen Remiro

(In [1146]) New interpolation methods in NameBlock StdLib::interpolate
Fixes #707

Note: See TracTickets for help on using tickets.