Economic simulation in R -
i'm trying create program simulates economic model. have parameters, have able change. should this. question how create program can decide time period, , parameters. let's capital period 1 given capital_1=(1-s)*output_0+capital_0. labour given labour_1=(1+n)*labour_0. output_1=capital_1*labour_1*k s,n , k parameters
time | output | capital | labour | ------ | ------ | ------- | ------ | 0 | 10 | 2.5 | 2 | 1 | ... | ... | ... | 2 | ... | ... | ... | 3 | ... | ... | ... |
the following should more enough give hint on how tackle this. not clear, whether homework or not, there might 1 or 2 problems code force you, @ in close detail , maybe make 1 or 2 corrections. principle of how works should 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!
Comments
Post a Comment