I'm trying to create a program which simulates an economic model. I have some parameters, which I have to be able to change. I should look something like this. So my question is how will I create a program where I can decide the time period, and parameters. Let's say that Capital i period 1 is given by Capital_1=(1-s)*Output_0+Capital_0. Labour is given by Labour_1=(1+n)*labour_0. Output_1=Capital_1*Labour_1*k Where s,n and k is parameters
Time | Output | Capital | Labour |
------ | ------ | ------- | ------ |
0 | 10 | 2.5 | 2 |
1 | ... | ... | ... |
2 | ... | ... | ... |
3 | ... | ... | ... |
The following should be more than enough to give you a hint on how to tackle this. As it is not clear, whether this is homework or not, there might be one or two problems about the code that force you, to look at it in close detail and maybe make one or two corrections. The principle of how it works should be obvious, though
Output <- 10
Capital <- 2.5
Labour <- 2
generator <- function(steps,s, n, k){
for(i in 2:(steps)){
Capital[i] <- (1-s)*Output[i-1]+Capital[i-1]
Labour[i] <- n*Labour[i-1]
Output[i] <- Capital[i]*Labour[i]*k
}
return(data.frame(Output = Output, Capital = Capital, Labour = Labour))
}
print(generator(steps=10, s=.01, n=1.002, k=1.01))
Good Luck!