diff --git a/DESCRIPTION b/DESCRIPTION index 494f53c..33a67a5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,3 +29,5 @@ Collate: 'around.R' 'nearest.loc.R' 'Bootstrap.R' + 'polar.norm.R' + 'jackknife.R' diff --git a/NAMESPACE b/NAMESPACE index da11b0a..7fc3467 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ export(Bootstrap) export(around) export(em.mixnorm) export(grid.sect) +export(jackknife) export(maxbound) export(mc) export(mixnorm) @@ -10,6 +11,7 @@ export(nearest.loc) export(newton.raph) export(plot.mc) export(pois.proc) +export(polar.norm) export(rand.exp) export(rand.mvnorm) export(rand.norm) diff --git a/R/.gitignore b/R/.gitignore new file mode 100644 index 0000000..62b29a2 --- /dev/null +++ b/R/.gitignore @@ -0,0 +1 @@ +rand.norm.R diff --git a/R/jackknife.R b/R/jackknife.R index 9c2a209..c38bd98 100644 --- a/R/jackknife.R +++ b/R/jackknife.R @@ -14,7 +14,7 @@ #' #' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} #' -#' @example x = runif(10, 0, 1) +#' @examples x = runif(10, 0, 1) #' mean(x) #' jackknife(x,mean) #' diff --git a/R/polar.norm.R b/R/polar.norm.R new file mode 100644 index 0000000..6150983 --- /dev/null +++ b/R/polar.norm.R @@ -0,0 +1,27 @@ +#' Generate A Random Normal Variable +#' +#' @description A method for generating a random normal variable based upon the polar method. +#' @param mu mean of a normal distribution +#' @param sig variance of a normal distribution +#' +#' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} +#' +#' @export + +polar.norm<-function(mu, sig) +{ + + u<-(2*wich.hill()-1) + v<-(2*wich.hill()-1) + + s<-u^2+v^2 + + while(s==0||s>=1) + { + u<-(2*wich.hill()-1) + v<-(2*wich.hill()-1) + + s<-u^2+v^2 + } + sig*sqrt(-2*log(s)/s)*u + mu +} diff --git a/R/rand.norm.R b/R/rand.norm.R index 21a40c0..46920c1 100644 --- a/R/rand.norm.R +++ b/R/rand.norm.R @@ -1,27 +1,13 @@ -#' Generate A Random Normal Variable +#' Generate Random Normal Variables #' -#' @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 +#' @param n Number of observations +#' @param mean vector of means +#' @param sd vector of standard deviations #' -#' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} +#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' #' @export -function(mu,sig) -{ - - u<-(2*wich.hill()-1) - v<-(2*wich.hill()-1) - - s<-u^2+v^2 - - while(s==0||s>=1) - { - u<-(2*wich.hill()-1) - v<-(2*wich.hill()-1) - - s<-u^2+v^2 - } - sig*sqrt(-2*log(s)/s)*u + mu +rand.norm<-function(n, mean, sd){ + qnorm( replicate( n, wich.hill() ) )*sd + mean } diff --git a/man/jackknife.Rd b/man/jackknife.Rd new file mode 100644 index 0000000..6ffcac4 --- /dev/null +++ b/man/jackknife.Rd @@ -0,0 +1,36 @@ +\name{jackknife} +\alias{jackknife} +\title{Resamples Data using the Jackknife Method} +\usage{ + jackknife(x, t) +} +\arguments{ + \item{x}{a vector} + + \item{t}{estimation of parameter} +} +\value{ + est orignial estimation of parameter + + jkest jackknife estimation of parameter + + jkvar jackknife estimation of variance + + jkbias jackknife estimate of biasness of parameter + + jkbiascorr bias corrected parameter estimate +} +\description{ + This function is used for estimating standard errors when + the distribution is not know. +} +\examples{ +x = runif(10, 0, 1) +mean(x) +jackknife(x,mean) +} +\author{ + Damon McCafferty + \email{damon.mccafferty@economics.utah.edu} +} + diff --git a/man/maxbound.Rd b/man/maxbound.Rd index fc0b8cf..3de3870 100644 --- a/man/maxbound.Rd +++ b/man/maxbound.Rd @@ -7,9 +7,9 @@ \arguments{ \item{f}{the function to be optimized} - \item{lo}{the lower bound} + \item{lo}{the lower bound.} - \item{hi}{the upper bound} + \item{hi}{the upper bound.} } \description{ Maxbound Optimization diff --git a/man/pois.proc.Rd b/man/pois.proc.Rd index 8399e2b..2abf9db 100644 --- a/man/pois.proc.Rd +++ b/man/pois.proc.Rd @@ -5,7 +5,7 @@ pois.proc(end = 200, rate = 1) } \arguments{ - \item{end}{the end time.} + \item{end}{the end time desired.} \item{rate}{the rate of occurrence.} } diff --git a/man/polar.norm.Rd b/man/polar.norm.Rd new file mode 100644 index 0000000..994bb73 --- /dev/null +++ b/man/polar.norm.Rd @@ -0,0 +1,20 @@ +\name{polar.norm} +\alias{polar.norm} +\title{Generate A Random Normal Variable} +\usage{ + polar.norm(mu, sig) +} +\arguments{ + \item{mu}{mean of a normal distribution} + + \item{sig}{variance of a normal distribution} +} +\description{ + A method for generating a random normal variable based + upon the polar method. +} +\author{ + Damon McCafferty + \email{damon.mccafferty@economics.utah.edu} +} + diff --git a/man/rand.unif.Rd b/man/rand.unif.Rd index 9f10463..0ce8d3d 100644 --- a/man/rand.unif.Rd +++ b/man/rand.unif.Rd @@ -5,11 +5,11 @@ rand.unif(n, min = 0, max = 1) } \arguments{ - \item{n}{Number of observations} + \item{n}{Number of observations.} - \item{min}{lower limit of the distribution} + \item{min}{lower limit of the distribution.} - \item{max}{upper limit of the distribution} + \item{max}{upper limit of the distribution.} } \description{ Generate Random Uniform Variables