I want to solve a dynamic set of equations that from a algebraic perspective a = bX, where a is a vector of 1's, b is a vector of discount factors and X is a lower triangular matrix of cash flows. I want to solve for X; however, as far as my understanding goes I can't solve for X since b is does not have an inverse. Therefore, I am trying to write a system of equations by a fuction as the following:
Aux2 = as.data.frame(matrix("X", nrow = nrow(Tasas), ncol = 1))
colnames(Aux2) = "Cash Flow"
for (j in 1:nrow(Tasas)){
Func = function(X){
Aux2 %*% Tasas$`Discount Factor`[1:j] + 1 * Tasas$`Discount Factor`[j] - 1
}
uniroot(Func, c(0,1))$root * 360/28
}
where
Tasas$'Discount Factor' = c(0.991, 0.982, 0.973, 0.965, 0.957, 0.951)
As the mathematical equation must be:
1 = X* DF1 + X* DF2 + ... + (1+X)* DFn
being DF the discount factor at time n and X the coupon payment of the instrument.
I that regard I get this output:
Error in Aux2 %*% Tasas$`Discount Factor`[1:j] :
requires numeric/complex matrix/vector arguments