Description Usage Arguments Author(s) See Also Examples
View source: R/evalFunctionOnParameterDef.r
several set of parameters is generated from parameterDef. Function fun
is evaulated under the index
-th set of parameters and returns its value.
1 | evalFunctionOnParameterDef(x, fun, index = 1, ...)
|
x |
A parameterDef object |
fun |
A function to be evaluated. |
index |
Which set of parameters to use. |
... |
unused |
TszKin Julian Chan ctszkin@gmail.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | par_def<-createParDef()
par_def<-setSelection(par_def,mean=1,sd=2,n=seq(10,50,10))
evalFunctionOnParameterDef(par_def, function() rnorm(n,mean,sd) ) # 10 random number
evalFunctionOnParameterDef(par_def, function() rnorm(n,mean,sd), index=3) # 30 random number
## Example 2
par_def <-createParDef()
par_def <- setBanker(par_def,xs=1,b=1)
par_def <- setSelection(par_def,n=seq(20,100,20),es=c(1,10))
dgp<-function(){
x<-rnorm(n,0,xs)
e<-rnorm(n,0,es)
y<-b * x + e
data.frame(y,x)
}
estimator<-function(d){
r<-summary(lm(y~x-1,data=d))
c(b=r$coef[,1],t=(r$coef[,1]-1)/r$coef[,2] )
}
true<-function(){
c(b,(b-1)/(es/sqrt(n)/xs))
}
evalFunctionOnParameterDef(par_def,dgp)
estimator(evalFunctionOnParameterDef(par_def,dgp))
evalFunctionOnParameterDef(par_def,true)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.