+ Reply to Thread
Results 1 to 3 of 3

FORECAST function to interpolate using index match given blank cells

  1. #1
    Registered User
    Join Date
    02-17-2020
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    2

    Lightbulb FORECAST function to interpolate using index match given blank cells

    I have a matrix data set for the returns on treasury bonds where the column (column A) sets the observation date and the row (row 1) sets the expiration date of the bond.

    I wish to output a return given both an observation and expiration date. While the observation date must match a date in the dataset, the expiration date can be any date you wish.

    Given my chosen expiration date will likely fall between two dates in the dataset, i must therefore interpolate between two expiration dates. This must be done with the return closest in expiration date either side of the chosen date.

    The issue is that there will often be times where there is no data available (cell is blank) for the expiration date closest to either side of the chosen date. Can a formula be written that allows me to be dynamic in choice of observation date and expiration date and output the interpolated return?

    Please see the attached worksheet as a reference with an example calculation
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: FORECAST function to interpolate using index match given blank cells

    After half a day, I will venture a response.

    1) Are you required to use Excel for this? Gnumeric has a built in INTERPOLATION() function that is usually easier to use for interpolation problems than anything in Excel. I checked the helpfile, and it claims that INTERPOLATION() knows how to ignore blanks. If I assume the behavior that it will use when it ignores blanks, I would expect Gnumeric's INTERPOLATION() function to work quite easily for this. A lookup function to return the values from the desired "observation date" row [INDEX(...MATCH(),0)], and then put that into the main INTERPOLATION() function. I don't have immediate access to Gnumeric for testing, but I would expect something like =INTERPOLATION('raw data'!B1:M1,INDEX(B2:M254,MATCH(C3,'raw data'!A2:A254,0),0),C5) would work.

    2) I have noted before that the hardest part of interpolation in Excel is the lookup part (if you must use Excel or other spreadsheet that does not include a built in interpolation function). In this case, the difficulty is further complicated by the irregular "shape" of the source data caused by the blanks. My thought here would be to do something to get rid of the blanks for each observation date so I have lookup vectors for each row that can be used to find the desired expiration date. Are you required to do all of the interpolation in a single cell, or are you open to a solution that uses multiple helper columns (I'm always inclined towards helper columns and doubt I could come up with a single cell mega formula for this). The approach I used:
    2a) I used a SMALL(IF(...)) array function to identify which dates had values for each row in "Raw Data" and create a horizontal lookup vector for dates. =SMALL(IF($B2:$M2="","",$B$1:$M$1),O$1) [copy/paste/fill into columns O:Z] where O1:Z1 contain the numbers 1 to 12.
    2b) A lookup function to get values =INDEX($B2:$M2,MATCH(O2,$B$1:$M$1,0)) into AB2 and copied into columns AB:AM.
    2c) I like to get slope and intercept for each pair of points rather than use the FORECAST() function, so I add two more sets of helper columns to calculate slope and intercept. =SLOPE(AB2:AC2,O2:P2) into column AO:AZ. =INTERCEPT(AB2:AC2,O2:P2) into columns BB:BM
    2d) With the lookup stuff set up, I can go to output and use a MATCH() function to find the desired row number based on observation date, another MATCH() function to get the column number based on expiration date, then two INDEX() functions to return the corresponding slope and intercept. Plug slope and intercept into y=m*expiration date+b to complete the interpolation.

    Obviously, something using a built in interpolation function that knows how to ignore blanks is a lot easier. If you are opposed to all of the helper cells in the Excel solution, perhaps someone else will come along with a solution that can fit into a single cell.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: FORECAST function to interpolate using index match given blank cells

    After testing in Gnumeric, it doesn't work exactly as I expected. I'm not sure why, but it doesn't do very well with the blanks. This worked, though (and is still a lot easier than what I did in Excel):

    1) For some reason, it handled blanks just fine when on the same tab, so I added a helper column to interpolate across each row at the expiration date in Raw Data. =INTERPOLATION($B$1:$M$1,B2:M2,Output!$C$5) in column O
    2) Then a simple lookup function in Output to return the value at the specified observation date. =VLOOKUP(C3,'Raw Data'!$B$2:$M$254,15,TRUE).

    Hopefully something in all of that helps.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Trying to display blank cells as blank, rather than 0% with INDEX and MATCH
    By davo3286 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-30-2020, 07:11 AM
  2. [SOLVED] Help using MATCH INDEX with VLOOKUP and FORECAST
    By ricky-84 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 06-13-2019, 04:22 PM
  3. [SOLVED] Multiple criteria Index and Match - with a Min function and blank cells
    By mike_vr in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 02-05-2018, 12:13 PM
  4. Index and Match where cells are blank
    By bigroo1958 in forum Excel General
    Replies: 10
    Last Post: 07-01-2015, 03:55 PM
  5. using forecast offset and match function for data that has blank values
    By larchonka in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-11-2013, 08:08 AM
  6. [SOLVED] Index & Match on Blank Cells
    By itselflearn in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-11-2013, 02:28 PM
  7. Forecast by using Index/Match formulas
    By paddyfeldi in forum Excel General
    Replies: 3
    Last Post: 03-14-2012, 10:42 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1