I'm following an Econometrics course in which we use R. I'm a bit confused about the use of the while-loop for an exercise. The situation is as follows: I have a variable 'profit_loss' with a length of 10,000. The variable gives an overview of the financial performance of a company with its profits (positive values) and losses (negative values). From this I have to create another variable for which I have to create a minimum benchmark such that the mean of this variable becomes 20% higher than the mean of the original variable. In other words, I have to cut the losses to a certain point, which will increase the mean to a level where it's 20% higher than the original mean. I was thinking of using a while-loop but while I can run some easy loops with this, I can't seem to figure out this one. Any suggestions? Thank you so much!
Asked
Active
Viewed 19 times
0
-
1Can you provide some sample data to [make your problem reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)? – markus Aug 27 '18 at 18:38
-
set.seed(384); V1 = runif(10000,min=2,max=10); V2= rnorm(10000,mean=0,sd=2.04); V3= -0.5*rchisq(10000,3); profit_loss = V1+V2+V3; – Veteransson Aug 27 '18 at 18:45