In R, if I have a function
myfun<-function(ys, T, N, beta, gamma, sigma) {...}
where beta and gamma are scalars.
If I have fixe
Look at the mapply and Vectorize functions along with expand.grid for the all combinations part.
Let's use a handy multi-argument function like dt() as an example. We will ("mult")-supply 2 arguments in "parallel" and ("const")-supply fixed values for the other two. Build a dataframe with expand.grid for the multi-argument lists and then pass it to mapply with appropriate names and use MoreArgs for the remaining arguments;
gamma <- 1:3
beta <- 1:4
gb.df <-expand.grid(gamma=gamma, beta=beta)
mfun <- dt
mapply ("mfun", x=gb.df$gamma, df=gb.df$beta, MoreArgs=list(ncp=1, log=FALSE) )
[1] 0.26355595 0.14379745 0.07896827 0.31785177 0.17910975 0.08636815
[7] 0.34118167 0.19555939 0.08572842 0.35411486 0.20513016 0.08355531