r - Find a parameter value based on weight of a portfolio -


I am trying to find the value of a parameter where the portfolio with a smaller parameter than this value is 25% of the entire portfolio < / P>

Of course, use of R.

For example, I have a portfolio of 100 index equity securities market index, 25% of this portfolio means 25% of the total market value. I want to find the value of a parameter, let's say P / E ratio, all the securities with a low P / E ratio less than such value contribute 25% of the market value of the portfolio.

I know that I can use the 'quantile' function to find 25% value for the P / E ratio,

  Bottom_quartile & lt; - Data [[data $ PE & lt; Quantity (data $ PE, 0.25),]   

But this value does not necessarily match 25% market value, and the above results do not give the total market value generated from above = 25% The original total market value has been

I am thinking that there is a function that can help us find the value of a specific parameter (in this case P / E ratio) based on the amount given by another parameter. Case 25% market value).

Thanks in advance for your help !!!

Okay, here's an update. I've tried some method to do it worked fine, though, it is very inefficient.

  # compute% market weight First Data $ MarketValuePct & lt; - Data $ MarketValue / sum (Data $ MarketValue) P / E sort_data & lt; - Data [Order ($ $ PE), # Quantity of cumulative amount for market value sort_da = $ cumsum_Market ValuePTT & lt; - cumsum (sort_data $ MarketValuePct) # Move down the edge of quartile Bottom_quartile & lt; - sort_data [sort_data $ cumsum_MarketValuePct & lt; 0.25,] The price below # PE is what I was looking for 4th_Qartile_PE <- Bottom_quartile [now (Bottom_quartile), (pe #)]   

I still have one Seeing is a more spectacular and more accurate way to do this. Please help if you have any ideas.

Thank you!

You do not want the quantity of market value, but 25% of the total market value. You can use the order to sort the stocks to calculate the total market value of the stock under a certain PE, PE and cumsum .

  I & lt; - Order (PE) tail (which (Qumoom (MCAP [I]) and .25 * Yoga (MCAP)), 1)    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -