Displaying 1 result from an estimated 1 matches for "localfun1".
2011 Apr 07
2
Two functions as parametrs of a function.
...know how to put each set of parameters for
each function.
What am I missing?
I try this code:
f2<-function(n=2,nsim=100,fun1=rnorm,par1=list(),fun2=rnorm,par2=list()){
force(fun1)
force(fun2)
force(n)
p1<-unlist(par1)
p2<-unlist(par2)
force(p1)
force(p2)
localfun1 <- function() fun1(n, p1)
localfun2 <- function() fun2(n, p2)
vp<-replicate(nsim,t.test(localfun1(), localfun2())$p.value)
return(vp)
}
f2(fun1=rbeta,par1=list(shape1=2,shape2=2),fun2=rbeta,par2=list(shape1=1,shape2=2))
Thank you for your help.
Kenneth