MakeFrame: Conversion of MonteCarlo outputs to data.frame.

Description Usage Arguments Details Value Examples

View source: R/MakeDataFrame.R

Description

MakeFrame takes the output of MonteCarlo as its argument and returns a data.frame that contains the simulation results.

Usage

1
MakeFrame(output)

Arguments

output

A MonteCarlo object returned by the MonteCarlo() function.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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)))

FunWithR/MonteCarlo documentation built on May 6, 2019, 5:07 p.m.