I have some trouble writing out a monte carlo simulation properly.
I assign variables for the process before the steps.
The first step is assigning variable j = j + 1
Second step i draw three random numbers from a U(0,1) dist. u1, u2 and u3.
Third step is a long if formula. It...
I need to reshape below matrix with or without do loop:
Below is my question:
X1 X2 X3 X4 X5 X6
18.25766 123.9019 151.4487 34.1252 196.6713 231.2289
16.89285 121.7344 146.5685 60.4828 299.1966 346.6185...
Hello, please assist me in answering the following question involving R code and statistics.
to simulate for each column, 50 coin tosses where a
toss has a probability of heads, from 0.05
to 1 probability in each column respectively. Coin...
I have created a loop to generate a counter variable values that will then be entered into an OUTPUT matrix. Everything except for 1 line seems to be working. The line is here:
matrix OUTPUT[`i', `j']=counter
*STATA writes: counter not found. But then I write:
I have written the following which takes a bit of time to run (which is to be expected) but I am just wondering if I could speed up the time it takes if I make my code more efficient. Any help with this would be much appreciated!
S <- c(y=.1, b=.2, o=.7)
I have a small problem which is holding me back and I cannot figure it out.
In a dataset I need to calculate the sum of variable "value" and put the result in a new variable "result".
The problem is, that the calculation needs to be done by id and date. Every id can have multiple...