+ Reply to Thread
Results 1 to 4 of 4

Inverting non-square matrix for bootstrapping

  1. #1
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    Germany
    MS-Off Ver
    365
    Posts
    490

    Inverting non-square matrix for bootstrapping

    Hi, attached is an example of a topic I am currently looking into, some basic application of linear algebra in something called yield curve construction.
    Any mathematicians may excuse my inexact language here.
    I acknowledge this may chiefly be more of a math question than a (pure) Excel one.

    My example is simplified for the purpose of illustrating how this works and what my problem is.

    I am given 4 bonds with a certain cash flow profile, i.e. mathematically speaking basically 4 polynoms of degrees one to four which are not dependant upon each other in any way.
    In rows 27 to 43, instead of iteratively as shown in the previous rows in the spreadsheet, I solved the equations with inverting the coefficient matrix and multiplying it with the constants matrix.

    So far, so good.
    The numbers and the technique employed makes sense to me (first block coloured in gray and which reconciles to the previous manual solutions).

    To my problem:
    Now I was trying to construct the same result vector but with a slightly reduced set of equations to work with.
    I was taking equations 1, 2 and 4 of the previous example, so left out Bonds #3 which gives me a non-square matrix.
    Whether or not there's still a solution to this matrix, I guess depends among others on its determinant.
    In order to be able to invert the matrix, I multiplied both sides with the transposed matrix of A and solved in the same way as before.

    I am now a bit puzzled at the results of this, the second gray vector.
    Especially, given that the first two equations are the same as before these two equations alone should be sufficient to solve x1 and x2 of the variable matrix X,
    how can the solutions be different than before?


    Maybe someone can shed some light on whether my matrix transformations are incorrect technically or mathematically or what I am missing about the interpretation of the results.

    Thank and Regards
    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: Inverting non-square matrix for bootstrapping

    I'm not sure if it answers the question, but what I see is that, in the case of the square 4x4 matrix, it is like you are solving a system of 4 equations with 4 unkowns. When you remove one of the "equations", you now have a system of 3 equations in 4 unknowns which is not solvable. Adding the transpose of A (B=AT*A*X --> X=B*(AT*A)-1) seems a different problem -- maybe something more like a "least squares regression" type of problem, but I usually visualize that as more of a "more than 4 equations with 4 unknowns".

    I don't know how bootstrapping is supposed to be expressed in terms of linear algebra and matrix operations, but that's what I see so far.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    Germany
    MS-Off Ver
    365
    Posts
    490

    Re: Inverting non-square matrix for bootstrapping

    Yea, not sure how to explain in words that make sense to maths people.

    You are correct, the first part is 4 equations with 4 variables. So, solvable unless determ(A) = 0 which is not the case here.
    The matrix technique used is I guess more or less a standard text book example how to use Excel/linear algebra to solve linear equations.

    Reducing the entire system of equations by one may indeed mean there's no unambiguous solution anymore.

    My rationale was more driven by the goal of creating a square matrix again which is why I mulitplied the coefficients and constants matrix with the transpose of A.
    Whether or not this is a sensible thing to do, I guess is part of my questions/problem.
    A little different than what you wrote, I multiplied the transpose of A to both sides, i.e.:
    A * X = B
    A_T * A * X = A_T * B
    (A_T * A)^-1 * (A_T * B) = X (not sure this is valid still?)
    So unless some of this is wrong mathematically, applying the same calculations to both sides, shouldn't create a new equation system, right?
    Just as if I would multiply e.g. E (unity matrix) on both sides.

    A_T * A here does have a determ unequal to zero, so I thought there should be a solution possible.
    But at the same time determ((A_T * A)^-1) <> determ(A_T * A)^-1, so something seems wrong.
    But I am getting a bit lost in the relevant math here I guess.

    Cheers

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

    Re: Inverting non-square matrix for bootstrapping

    I can see what you are doing and, as near as I can tell, the functions are calculating "correctly" -- whatever that means for this problem. But the math and statistics are above my pay grade, so I really don't understand what is going on here.

    As mentioned, what you are doing looks an awful lot like "least squares linear regression" (Y=B*X+error where Y is the vector of known y values and X is the matrix of known x values and B is the vector of coefficients), I tried approaching it that way. Select K3:O3 and array enter =LINEST(B3:B6,C3:F6,FALSE) and I get the same results as you get in H39:H42.

    I then select put =LINEST(H47:H49,C47:G49,FALSE) into K47:O47, and I get something different. Two of the parameters are the same, one has become 0, and the fourth is changed a little.

    Of course, the ultimate test for a "solve a system of equations" problem is to put the resulting x's back into the original equations, and calculate the y's and see if they match. To check the original 4x4 problem, I put =MMULT(C3:D6,H39:H42) into P39:P42 and got all 100s. Then I put =MMULT(C47:F49,H58:H61) into M58:M61 and got three different, non-100 but kind of close to 100 values, and MMULT(C47:F49,TRANSPOSE(K47:O47)) into N58:N61 and got three 100s.

    It looks like the LINEST() function does something above and beyond the basic matrix inversion algorithm that is not the same as the MINVERSE() function. Since the math/stats/etc. of the problem are above my pay grade, I don't know if this is a suitable way to treat the problem. One would need to understand the math/statistics behind the problem to really understand if adding the AT multiplication to the problem and treating it like a least squares linear regression is appropriate. If it is, then maybe you can use the LINEST() function to do the "regression" more reliably than the MINVERSE() function.

+ 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] How to get a value in a square matrix with two conditions
    By alexlutz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-09-2019, 08:11 PM
  2. square matrix determinant
    By handa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-05-2018, 09:02 PM
  3. Create a r-square matrix on simple strings of values
    By guillm in forum Excel General
    Replies: 5
    Last Post: 11-15-2016, 05:25 AM
  4. Bootstrapping with Excel and VBA
    By stpyrg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-28-2014, 08:50 PM
  5. Bootstrapping of stock price (Data based simulation)
    By Ajohs in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-02-2013, 11:25 AM
  6. Replies: 3
    Last Post: 08-19-2009, 08:53 AM
  7. maximum range inverting matrix
    By _Anna_ in forum Excel General
    Replies: 3
    Last Post: 03-23-2009, 11:47 AM

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