R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("CircStats-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('CircStats') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "A1inv" > > ### * A1inv > > flush(stderr()); flush(stdout()) > > ### Name: A1inv > ### Title: Inverse of A1 > ### Aliases: A1inv > ### Keywords: math > > ### ** Examples > > #Generate data from a von Mises distribution > data <- rvm(50, pi, 4) > #Estimate the concentration parameter > s <- sum(sin(data)) > c <- sum(cos(data)) > mean.dir <- atan(s, c) > kappa <- A1inv(mean(cos(data - mean.dir))) > > > > cleanEx(); ..nameEx <- "circ.cor" > > ### * circ.cor > > flush(stderr()); flush(stdout()) > > ### Name: circ.cor > ### Title: Correlation Coefficient for Angular Variables > ### Aliases: circ.cor > ### Keywords: univar > > ### ** Examples > > # Generate two circular data sets, and compute their correlation. > data1 <- rvm(50, 0, 3) > data2 <- data1 + pi + rvm(50, 0, 10) > circ.cor(data1, data2, test=TRUE) r test.stat p.value 1 0.9197672 4.764692 1.891424e-06 > > > > cleanEx(); ..nameEx <- "circ.mean" > > ### * circ.mean > > flush(stderr()); flush(stdout()) > > ### Name: circ.mean > ### Title: Mean Direction > ### Aliases: circ.mean > ### Keywords: univar > > ### ** Examples > > # Compute the mean direction of a random sample of observations. > data <- runif(50, 0, pi) > mean.dir <- circ.mean(data) > > > > cleanEx(); ..nameEx <- "circ.plot" > > ### * circ.plot > > flush(stderr()); flush(stdout()) > > ### Name: circ.plot > ### Title: Circular Data Plot > ### Aliases: circ.plot > ### Keywords: hplot > > ### ** Examples > > # Generate 100 observations from a von Mises distribution. > # with mean direction 0 and concentration 3. > data.vm <- rvm(100, 0, 3) > # Plot data set. All points do not fit on plot. > circ.plot(data.vm, stack=TRUE, bins=150) Loading required package: MASS > # Shrink the plot so that all points fit. > circ.plot(data.vm, stack=TRUE, bins=150, shrink=1.5) > > > > cleanEx(); ..nameEx <- "circ.range" > > ### * circ.range > > flush(stderr()); flush(stdout()) > > ### Name: circ.range > ### Title: Circular Range > ### Aliases: circ.range nCk > ### Keywords: univar htest > > ### ** Examples > > data <- rvm(50, 0, 2) > circ.range(data, test=TRUE) range p.value 1 4.231505 1.933770e-07 > data <- runif(50, 0, 2*pi) > circ.range(data, test=TRUE) range p.value 1 5.411513 0.03302356 > > > > cleanEx(); ..nameEx <- "circ.reg" > > ### * circ.reg > > flush(stderr()); flush(stdout()) > > ### Name: circ.reg > ### Title: Circular-Circular Regression > ### Aliases: circ.reg > ### Keywords: models > > ### ** Examples > > # Generate a data set of dependent circular variables. > data1 <- runif(50, 0, 2*pi) > data2 <- atan(0.15*cos(data1) + 0.25*sin(data1), 0.35*sin(data1)) + rvm(50, 0, 5) > > # Fit a circular regression model. > circ.lm <- circ.reg(data1, data2, order=1) > # Obtain a crude plot a data and fitted regression line. > plot(data1, data2) > circ.lm$fitted[circ.lm$fitted>pi] <- circ.lm$fitted[circ.lm$fitted>pi] - 2*pi > > points(data1[order(data1)], circ.lm$fitted[order(data1)], type='l') > > > > cleanEx(); ..nameEx <- "circ.summary" > > ### * circ.summary > > flush(stderr()); flush(stdout()) > > ### Name: circ.summary > ### Title: Circular Summary Statistics > ### Aliases: circ.summary > ### Keywords: misc > > ### ** Examples > > # Compute summary statistics of a random sample of observations. > data <- runif(50, 0, pi) > circ.summary(data) n mean.dir rho 1 50 1.703981 0.6815599 > > > > cleanEx(); ..nameEx <- "dwrpnorm" > > ### * dwrpnorm > > flush(stderr()); flush(stdout()) > > ### Name: dwrpnorm > ### Title: Wrapped Normal Density Function > ### Aliases: dwrpnorm > ### Keywords: distribution > > ### ** Examples > > # Values for which to evaluate density > theta <- c(1:500)*2*pi/500 > #Compute wrapped normal density function > density <- c(1:500) > for(i in 1:500) density[i] <- dwrpnorm(theta[i], pi, .75) > plot(theta, density) > #Approximate area under density curve > sum(density*2*pi/500) [1] 1 > > > > cleanEx(); ..nameEx <- "est.kappa" > > ### * est.kappa > > flush(stderr()); flush(stdout()) > > ### Name: est.kappa > ### Title: Estimate Kappa > ### Aliases: est.kappa > ### Keywords: htest > > ### ** Examples > > data <- rvm(15, 0, 3) > est.kappa(data) [1] 3.672059 > est.kappa(data, bias=TRUE) [1] 2.972310 > > > > cleanEx(); ..nameEx <- "est.rho" > > ### * est.rho > > flush(stderr()); flush(stdout()) > > ### Name: est.rho > ### Title: Mean Resultant Length > ### Aliases: est.rho > ### Keywords: htest > > ### ** Examples > > # Compute the mean resultant length of a random sample of observations. > data <- runif(100, 0, 2*pi) > est.rho(data) [1] 0.09539008 > > > > cleanEx(); ..nameEx <- "plot.edf" > > ### * plot.edf > > flush(stderr()); flush(stdout()) > > ### Name: plot.edf > ### Title: Plot Empirical Distribution Function > ### Aliases: plot.edf > ### Keywords: hplot > > ### ** Examples > > # Compare the edf's of two simulated sets of data. > data1 <- rvm(10, 0, 3) > data2 <- rvm(10, 0, 1) > plot.edf(data1, xlab="Data", ylab="EDF", main="Plots of Two EDF's") > par(new=TRUE) > plot.edf(data2, axes=FALSE, xlab="", ylab="", lty=2) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "pp.plot" > > ### * pp.plot > > flush(stderr()); flush(stdout()) > > ### Name: pp.plot > ### Title: von Mises Probability-Probability Plot > ### Aliases: pp.plot > ### Keywords: hplot > > ### ** Examples > > data <- rvm(25, 0, 3) > pp.plot(data) mu kappa 1 0.5 13.41532 > data <- c(rvm(20, 0, 7), rvm(20, pi, 7)) > pp.plot(data) mu kappa 1 0.5 13.03138 > > > > cleanEx(); ..nameEx <- "r.test" > > ### * r.test > > flush(stderr()); flush(stdout()) > > ### Name: r.test > ### Title: Rayleigh Test of Uniformity: General Unimodal Alternative > ### Aliases: r.test > ### Keywords: htest > > ### ** Examples > > data <- rvm(25, pi, 2) > r.test(data) $r.bar [1] 0.6967402 $p.value [1] 1.105626e-06 > > > > cleanEx(); ..nameEx <- "rose.diag" > > ### * rose.diag > > flush(stderr()); flush(stdout()) > > ### Name: rose.diag > ### Title: Rose Diagram > ### Aliases: rose.diag > ### Keywords: hplot > > ### ** Examples > > # Generate uniform data and create several rose diagrams. > # Some optional parameters may be needed to optimize plots. > data <- runif(50, 0, 2*pi) > rose.diag(data, bins = 18, main = 'Uniform Data') Loading required package: MASS > rose.diag(data, bins = 18, main = 'Stacked Points', pts=TRUE) > # Generate von Mises data and create several rose diagrams. > data <- rvm(25, 0, 5) > rose.diag(data, bins=18, pts=TRUE) # Points fall out of bounds. > rose.diag(data, bins=36, prop=1.5, pts=TRUE, shrink=1.5) > # Adjust optional parameters to fit all points on plot. > > > > cleanEx(); ..nameEx <- "rstable" > > ### * rstable > > flush(stderr()); flush(stdout()) > > ### Name: rstable > ### Title: Random Generator for Stable Family of Distributions > ### Aliases: rstable > ### Keywords: distribution > > ### ** Examples > > hist(rstable(200, 1.5, .5)) #fairly long tails, skewed right > > > > cleanEx(); ..nameEx <- "v0.test" > > ### * v0.test > > flush(stderr()); flush(stdout()) > > ### Name: v0.test > ### Title: Rayleigh Test of Uniformity: Alternative with Specified Mean > ### Direction > ### Aliases: v0.test > ### Keywords: htest > > ### ** Examples > > data <- rvm(25, pi, 2) > v0.test(data, mu0=pi) $r0.bar [1] 0.696599 $p.value [1] 8.67713e-08 > > > > cleanEx(); ..nameEx <- "vm.bootstrap.ci" > > ### * vm.bootstrap.ci > > flush(stderr()); flush(stdout()) > > ### Name: vm.bootstrap.ci > ### Title: Bootstrap Confidence Intervals > ### Aliases: vm.bootstrap.ci > ### Keywords: htest > > ### ** Examples > > x <- rvm(25, 0, 3) > x.bs <- vm.bootstrap.ci(x, alpha=.10) Loading required package: boot Bootstrap Confidence Intervals for Mean Direction and Concentration Confidence Level: 90 % Mean Direction: Low = -0.26 High = 0.09 Concentration Parameter: Low = 2.93 High = 7.21 > hist(x.bs$kappa.reps) > > > > cleanEx(); ..nameEx <- "watson" > > ### * watson > > flush(stderr()); flush(stdout()) > > ### Name: watson > ### Title: Watson's Test > ### Aliases: watson > ### Keywords: htest > > ### ** Examples > > # Generate data from the uniform distribution on the circle. > data <- runif(100, 0, 2*pi) > watson(data) Watson's Test for Circular Uniformity Test Statistic: 0.0903 P-value > 0.10 > # Generate data from a von Mises distribution. > data <- rvm(50, 0, 4) > watson(data, 0.05, dist='vm') Watson's Test for the von Mises Distribution Test Statistic: 0.0476 Level 0.05 Critical Value: 0.117 Do Not Reject Null Hypothesis > > > > cleanEx(); ..nameEx <- "watson.two" > > ### * watson.two > > flush(stderr()); flush(stdout()) > > ### Name: watson.two > ### Title: Watson's Two-Sample Test of Homogeneity > ### Aliases: watson.two > ### Keywords: htest > > ### ** Examples > > # Perform a two-sample test of homogeneity on two > # simulated data sets. > data1 <- rvm(20, 0, 3) > data2 <- rvm(20, pi, 2) > watson.two(data1, data2, alpha=0.05, plot=TRUE) Watson's Two-Sample Test of Homogeneity Test Statistic: 0.8149 Level 0.05 Critical Value: 0.187 Reject Null Hypothesis > watson.two(data1, data2) Watson's Two-Sample Test of Homogeneity Test Statistic: 0.8149 P-value < 0.001 > > > > cleanEx(); ..nameEx <- "wrpcauchy.ml" > > ### * wrpcauchy.ml > > flush(stderr()); flush(stdout()) > > ### Name: wrpcauchy.ml > ### Title: Wrapped Cauchy Maximum Likelihood Estimates > ### Aliases: wrpcauchy.ml > ### Keywords: htest > > ### ** Examples > > # Generate data from a wrapped Cauchy distribution. > data <- rwrpcauchy(50, 0, 0.75) > # Compute the sample mean direction and resultant length. > mu0 <- circ.mean(data) > rho0 <- est.rho(data) > # Estimate the MLE's of the Cauchy distribution parameters. > wrpcauchy.ml(data, mu0, rho0) mu rho 1 6.192822 0.7232508 > > > > ### *