I am trying to figure out how to perform an elasticity analysis to a model I have developed. To do so, I intend to apply a 10% on each parameter of the model and measure the change in the output. I have written a simple function including all the parameter as arguments.
My challenge is that I don't know how to automatize this process to all the arguments with an apply function or a loop.
Let's take a dummy function as an example:
model <- function(a=1, b=1, c=1){
result <- a+(10*b)+(100*c)
return(result)
}
I would like to apply the same change to each parameter (+10% of its value) and produce a run for each iteration. For example, if I had to do it manually it would like this:
output_a <- model(a=1.1)
> 111.1
output_b <- model(b=1.1)
> 111
output_c <- model(c=1.1)
> 121
Ideally, all of the outputs would be in the same dataframe to easily process them in the future. Any thoughts on this? Perhaps an existing post I couldn't find?