-1

The equation is quite simple, but how to solve it in R is my question:

Return_of_A = 0.001431
Return_of_B = 0.000703
Return_of_C = 0.000716

the question is to create a portfolio that gives a return equal to the expected return of A (0.001431)

Return of a portfolio = Weight(A) * Return_of_A + 
                        Weight(B) * Return_of_B + 
                        Weight(C) * Return_of_C

How could I find the weight for each in R?

user438383
  • 5,716
  • 8
  • 28
  • 43
kris
  • 27
  • 6
  • 2
    You have three unkown numbers, but you only have one restriction here. – Peace Wang Jan 27 '22 at 02:24
  • yes only one is Weight(A) + Weight(B) + Weight(C) = 1 – kris Jan 27 '22 at 02:32
  • Refer to https://stackoverflow.com/questions/25265491/solving-under-overdetermined-systems-in-r – Peace Wang Jan 27 '22 at 02:36
  • Sorry but I thought that didn't really solve my question – kris Jan 27 '22 at 03:16
  • 1
    You have two restrictions, plus the constraint that x, y, and z are positive and less than or equal to 1. But that is not enough to guarantee a unique solution. For example `x <- .0008; y <- .4992; z <- .5` gives `(A-1)*x + B*y + C*z = -8.99176e-05` which is pretty close to zero. – dcarlson Jan 27 '22 at 06:05
  • 3
    As far as I can tell, you are asking what combination of weights of A, B, and C you should use to ensure that the sum is equal to the return of A. Surely this is just Weight(A) = 1, and the other two weights are zero? The return of A on its own is...the return of A. Or am I misunderstanding you? – Allan Cameron Jan 27 '22 at 09:30
  • Thanks for your answer. There is no unique solution. I am just asking a potential one and the point is how did you find that in R. use what function? – kris Jan 27 '22 at 14:22

1 Answers1

1

You can implement Allan's trivial logic from comments using the lm function:

Return_of_A = 0.001431
Return_of_B = 0.000703
Return_of_C = 0.000716
Goal = Return_of_A
lm(Goal ~ Return_of_A + Return_of_B + Return_of_C + 0)
# Call:
# lm(formula = Goal ~ Return_of_A + Return_of_B + Return_of_C + 
#     0)
# 
# Coefficients:
# Return_of_A  Return_of_B  Return_of_C  
#           1           NA           NA  

Simply treat the NA coefficients as 0s.

In this way, R can confirm for you that your goal (Return_of_A) is indeed equal to itself, even if there are other values.

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294