# provides skew(), kurtosi() require(psych) multiplot <- function(row,col) { # Lays out the current graphics device in a grid # no-frills, described in Vasishth & Broe (2010) # # ARGS: row, number of rows in the grid # col, number of cols in the grid # # RETURN: none # square plotting regions, layed out row-by-row par(mfrow = c(row,col), pty="s") # sets the plotting margin, bottom-left-top-right par(mar=c(3,3,3,2)) } simulateExperiment<-function(my.population, n.obs = 40, n.sim = 100000){ # Simulate any number of 'experiments', of any sample size # With any vector data # # ARGS: n.obs - number of observations per experiment/sample # n.sim - number of experiments/samples # # RETURN: vector of means for the series of sample mean.sample <- vector("numeric", length=n.sim) for(i in 1:n.sim){ sample(my.population, size=n.obs, replace=TRUE) -> rt.sample mean(rt.sample) -> mean.sample[i] } return(mean.sample) } se<-function(x) { y <- x[!is.na(x)] sqrt(var(as.vector(y))/length(y)) } ### ### 95% CONFIDENCE INTERVAL ### ci<-function(x, size=0.95) { # # ARGS: # # RETURNS: m<-mean(x,na.rm=TRUE) standard.error<-se(x) len<-length(x) upper<-m+qt(size+(1-size)/2,df=len-1)*standard.error lower<-m+qt((1-size)/2,df=len-1)*standard.error return(data.frame(lower=lower,upper=upper)) }