MakeFrame {MonteCarlo} | R Documentation |
Conversion of MonteCarlo outputs to data.frame.
Description
MakeFrame
takes the output of MonteCarlo
as its argument and returns a
data.frame that contains the simulation results.
Usage
MakeFrame(output)
Arguments
output |
A |
Details
Each row of the data.frame contains the values returned by func
for one repetition of the simulation
and the respective values of the parameters.
Value
A data.frame that contains the simulation results.
Examples
test_func<-function(n,loc,scale){
sample<-rnorm(n, loc, scale)
stat<-sqrt(n)*mean(sample)/sd(sample)
decision<-abs(stat)>1.96
return(list("decision"=decision, "stat"=stat))
}
n_grid<-c(50,100,250,500)
loc_grid<-c(0,1)
scale_grid<-c(1,2)
param_list=list("n"=n_grid, "loc"=loc_grid, "scale"=scale_grid)
erg<-MonteCarlo(func=test_func, nrep=250, param_list=param_list, ncpus=1)
df<-MakeFrame(erg)
head(df)
library(dplyr)
library(ggplot2)
tbl <- tbl_df(df)
ggplot(filter(tbl, loc==0)) + geom_density(aes(x=stat, col=factor(n)))
[Package MonteCarlo version 1.0.6 Index]