#' @title Plotting the observed test statistic on the distribution of the test statistic calculated on simulated data
#'
#' @description This function is used by other functions and will generally not be used directly by users. Can be used to plot
#' test statistics on simulated data generated by other functions (e.g. \code{\link{slope.test.stasis}},
#' \code{\link{auto.corr.test.trend}}, \code{\link{runs.test.RW}}).
#'
#' @param sim.data vector containing test statistics calculated from the simulated data
#'
#' @param obs the test statistic calculated from the observed data
#'
#' @param test the test that has been applied (runs.test, slope.test, auto.corr, net.change.test)
#'
#' @param xlab label for x-axis
#'
#' @param main plot label
#'
#' @details This function is used by other functions and will generally not be used directly by users. Can be used to plot
#' test statistics on simulated data generated by other functions (e.g. \code{\link{slope.test.stasis}},
#' \code{\link{auto.corr.test.trend}}, \code{\link{runs.test.RW}}).
#'
#' @return Histogram of test statistics calculated from simulated data. The test statistic calculated from
#' the observed data is indicated by a vertical broken line.
#'
#'@author Kjetil L. Voje
#'
#'@seealso \code{\link{fit3adequacy.trend}}, \code{\link{auto.corr.test.RW}}, \code{\link{auto.corr.test.stasis}}
#'@export
#'@examples
#'## generate a paleoTS objects by simulating a directional trend
#'x <- sim.GRW(ns=40, ms=0.5, vs=0.1)
#'
#'## run the test
#'for.plotting<-auto.corr.test.trend(x,mstep,vstep)
#'
#'## plot
#'plotting.distributions(for.plotting$replicates, for.plotting$summary[1], test="auto.corr")
#'
plotting.distributions<-function(sim.data, obs, test, xlab, main){
if(test=="auto.corr") {
low<--1;
high<-1;
}
if(test=="runs.test" || test=="slope.test"){
low<-min(sim.data,obs)
if(low<0) low<-low*1.25 else low<-low*0.75
high<-max(sim.data,obs)
if(high<0) high<-high*0.75 else high<-high*1.25
}
if(test=="net.change.test"){
low<-min(sim.data,obs)
high<-max(sim.data,obs)
}
hist(sim.data, xlim=c(low,high), xlab=xlab, main=main)
abline(v=obs, col="red", lty=2, lwd=2)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.