diff --git a/CompPack/CompPack.Rproj b/CompPack/CompPack.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/CompPack/CompPack.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/CompPack/debug.log b/CompPack/debug.log new file mode 100644 index 0000000..e69de29 diff --git a/DESCRIPTION b/DESCRIPTION index 7d36cb0..494f53c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -28,3 +28,4 @@ Collate: 'nearest.R' 'around.R' 'nearest.loc.R' + 'Bootstrap.R' diff --git a/NAMESPACE b/NAMESPACE index 173e11e..da11b0a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,3 +1,4 @@ +export(Bootstrap) export(around) export(em.mixnorm) export(grid.sect) diff --git a/R/Bootstrap.R b/R/Bootstrap.R new file mode 100644 index 0000000..9c599b7 --- /dev/null +++ b/R/Bootstrap.R @@ -0,0 +1,20 @@ +#' Bootstrap +#' +#' @description +#' This function is used for estimating standard errors when the distribution is not know. +#' +#' @param x a vector. +#' @param Boots The number of bootstraps. +#' @param fn the function you want to bootstrap. +#' +#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} +#' +#' @export + + +Bootstrap<-function(x, Boots=100, fn){ + n=length(x) + lings<-replicate(Boots, fn(sample(x,n, replace=TRUE))) + + list(se=sd(lings), lings=lings) +} diff --git a/R/around.R b/R/around.R index e19578e..cb63ed8 100644 --- a/R/around.R +++ b/R/around.R @@ -2,7 +2,7 @@ #' #' @description Find the location of values around a specified value #' -#' @param x a vector, matrix, or data frame. +#' @param x a vector. #' @param value specified value #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} diff --git a/R/maxbound.R b/R/maxbound.R index 35e1031..fd6481e 100644 --- a/R/maxbound.R +++ b/R/maxbound.R @@ -1,8 +1,8 @@ #' Maxbound Optimization #' #' @param f the function to be optimized -#' @param lo the lower bound -#' @param hi the upper bound +#' @param lo the lower bound. +#' @param hi the upper bound. #' #' @export diff --git a/R/pois.proc.R b/R/pois.proc.R index b946f40..9b84070 100644 --- a/R/pois.proc.R +++ b/R/pois.proc.R @@ -1,6 +1,6 @@ #' Generate a Poisson Process #' -#' @param end the end time. +#' @param end the end time desired. #' @param rate the rate of occurrence. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} diff --git a/R/rand.norm.R b/R/rand.norm.R index 46920c1..0d5b4f7 100644 --- a/R/rand.norm.R +++ b/R/rand.norm.R @@ -1,13 +1,27 @@ -#' Generate Random Normal Variables +#' Generate A Random Normal Variable #' -#' @param n Number of observations -#' @param mean vector of means -#' @param sd vector of standard deviations +#' @description A method for generating a random normal variable based upon the polar method. +#' @param mu mean of a normal distribution +#' @param sigma variance of a normal distribution #' -#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} +#' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} #' #' @export -rand.norm<-function(n, mean, sd){ - qnorm( replicate( n, wich.hill() ) )*sd + mean +function(mu,sig) +{ + + u<-(2*wichmannhill()-1) + v<-(2*wichmannhill()-1) + + s<-u^2+v^2 + + while(s==0||s>=1) + { + u<-(2*wichmannhill()-1) + v<-(2*wichmannhill()-1) + + s<-u^2+v^2 + } + sig*sqrt(-2*log(s)/s)*u + mu } diff --git a/R/rand.unif.R b/R/rand.unif.R index 5fc1b88..11ccfa7 100644 --- a/R/rand.unif.R +++ b/R/rand.unif.R @@ -1,8 +1,8 @@ #' Generate Random Uniform Variables #' -#' @param n Number of observations -#' @param min lower limit of the distribution -#' @param max upper limit of the distribution +#' @param n Number of observations. +#' @param min lower limit of the distribution. +#' @param max upper limit of the distribution. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' diff --git a/debug.log b/debug.log new file mode 100644 index 0000000..e69de29 diff --git a/man/Bootstrap.Rd b/man/Bootstrap.Rd new file mode 100644 index 0000000..5b773d8 --- /dev/null +++ b/man/Bootstrap.Rd @@ -0,0 +1,21 @@ +\name{Bootstrap} +\alias{Bootstrap} +\title{Bootstrap} +\usage{ + Bootstrap(x, Boots = 100, fn) +} +\arguments{ + \item{x}{a vector.} + + \item{Boots}{The number of bootstraps.} + + \item{fn}{the function you want to bootstrap.} +} +\description{ + This function is used for estimating standard errors when + the distribution is not know. +} +\author{ + Tyler Hunt \email{tyler@psychoanalytix.com} +} + diff --git a/man/around.Rd b/man/around.Rd index 91c440c..8a4df79 100644 --- a/man/around.Rd +++ b/man/around.Rd @@ -5,7 +5,7 @@ around(x, value) } \arguments{ - \item{x}{a vector, matrix, or data frame.} + \item{x}{a vector.} \item{value}{specified value} }