We simulate normally distributed data as follows:
require(weco); set.seed(10000); n.sim <- 50000; sdx <- 2; simu.data <- rnorm(n.sim, sd = sdx); quants <- c(0.25, 0.5, 0.75); xmax <- 3000; ymax <- 0.015;
1 point $>L$ standard deviations from center line
l <- 3; rst.1 <- weco.rule(rule=1, x=simu.data, l=l, sdx=sdx, mux=0); simu.arl <- weco.rl(rst.1); hist(simu.arl, breaks = 100, freq = F, xlim=c(0, xmax), ylim=c(0,ymax), xlab="Running Length", ylab="Probability", main="Rule 1");
$K$ points in a row on the same side of the center line
k <- 9; rst.2 <- weco.rule(rule=2, x=simu.data, k=k, sdx=sdx, mux=0); simu.arl <- weco.rl(rst.2); hist(simu.arl, breaks = 100, freq = F, xlim=c(0, xmax), ylim=c(0,ymax), xlab="Running Length", ylab="Probability", main="Rule 2");
$K$ points in a row, all increasing or decreasing
k <- 6; rst.3 <- weco.rule(rule=3, x=simu.data, k=k, sdx=sdx, mux=0); simu.arl <- weco.rl(rst.3); hist(simu.arl, breaks = 100, freq = F, xlim=c(0, xmax), ylim=c(0,ymax), xlab="Running Length", ylab="Probability", main="Rule 3");
$K$ points in a row, alternating up and down
k <- 14; rst.4 <- weco.rule(rule=4, x=simu.data, k=k, sdx=sdx, mux=0); simu.arl <- weco.rl(rst.4); hist(simu.arl, breaks = 100, freq = F, xlim=c(0, xmax), ylim=c(0,ymax), xlab="Running Length", ylab="Probability", main="Rule 3");
$K$ out $K+1$ points out of 2 standard deviations from center line
k <- 2; rst.5 <- weco.rule(rule=5, x=simu.data, k=k, l=2, sdx=sdx, mux=0); simu.arl <- weco.rl(rst.5); hist(simu.arl, breaks = 100, freq = F, xlim=c(0, xmax), ylim=c(0,ymax), xlab="Running Length", ylab="Probability", main="Rule 5");
$K$ out $K+1$ points out of 1 standard deviations from center line
k <- 4; rst.6 <- weco.rule(rule=6, x=simu.data, k=k, l=1, sdx=sdx, mux=0); simu.arl <- weco.rl(rst.6); hist(simu.arl, breaks = 100, freq = F, xlim=c(0, xmax), ylim=c(0,ymax), xlab="Running Length", ylab="Probability", main="Rule 6");
$K$ points in a row within 1 standard deviations from center line (either side)
k <- 15; rst.7 <- weco.rule(rule=7, x=simu.data, k=k, l=1, sdx=sdx, mux=0); simu.arl <- weco.rl(rst.7); hist(simu.arl, breaks = 100, freq = F, xlim=c(0, xmax), ylim=c(0,ymax), xlab="Running Length", ylab="Probability", main="Rule 7");
$K$ points in a row > 1 standard deviations from center line (either side)
k <- 8; rst.8 <- weco.rule(rule=8, x=simu.data, k=k, l=1, sdx=sdx, mux=0); simu.arl <- weco.rl(rst.8); hist(simu.arl, breaks = 100, freq = F, xlim=c(0, xmax), ylim=c(0,ymax), xlab="Running Length", ylab="Probability", main="Rule 8");
Multiple rules can be combined as a list.
##rules 1 and 2 lst.rules <- list(list(1, l=3), list(2, k=9)); rst.m <- weco.combine(simu.data, lst.rules=lst.rules); simu.arl <- weco.rl(rst.m); hist(simu.arl, breaks = 100, freq = F, xlim=c(0, xmax), ylim=c(0,ymax), xlab="Running Length", ylab="Probability", main="Multiple Rules");
A trace plot may be plotted as follows
plot(rst.m, start=1000, end=1500);
The package provides a graphical user interface based on Shiny, which can be brought up by
run.weco();
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.