From 452e5d12a27be0753161e6cc996cbb4597ae96ab Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Mon, 22 Apr 2013 16:30:08 -0600 Subject: [PATCH 001/112] Updated Documentation --- R/around.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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} From ece7a9f2a4cd4bf5d1048a3988d855fc73015531 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 23 Apr 2013 11:20:55 -0600 Subject: [PATCH 002/112] Updated documentation --- man/around.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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} } From d0741854644563ec349b770d421766e53c7d5e06 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 23 Apr 2013 11:21:24 -0600 Subject: [PATCH 003/112] Added Bootstrap Function --- DESCRIPTION | 1 + NAMESPACE | 1 + R/Bootstrap.R | 17 +++++++++++++++++ man/Bootstrap.Rd | 20 ++++++++++++++++++++ 4 files changed, 39 insertions(+) create mode 100644 R/Bootstrap.R create mode 100644 man/Bootstrap.Rd 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..792a28b --- /dev/null +++ b/R/Bootstrap.R @@ -0,0 +1,17 @@ +#' Bootstrap +#' +#' @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/man/Bootstrap.Rd b/man/Bootstrap.Rd new file mode 100644 index 0000000..e170683 --- /dev/null +++ b/man/Bootstrap.Rd @@ -0,0 +1,20 @@ +\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{ + Bootstrap +} +\author{ + Tyler Hunt \email{tyler@psychoanalytix.com} +} + From 997e2caefe3d5ac2e632b13f1cca9c7d46733026 Mon Sep 17 00:00:00 2001 From: JackStat Date: Tue, 23 Apr 2013 11:24:09 -0600 Subject: [PATCH 004/112] test --- R/Bootstrap.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/Bootstrap.R b/R/Bootstrap.R index 792a28b..20cac0d 100644 --- a/R/Bootstrap.R +++ b/R/Bootstrap.R @@ -1,8 +1,8 @@ #' Bootstrap #' #' @param x a vector. -#' @param Boots The number of bootstraps -#' @param fn the function you want to bootstrap +#' @param Boots The number of bootstraps. +#' @param fn the function you want to bootstrap. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' From eaa17585dccde65b1cfbfecf00b0d42e566ef7ec Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 23 Apr 2013 11:25:40 -0600 Subject: [PATCH 005/112] Updated Bootstrap documentation --- R/Bootstrap.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/Bootstrap.R b/R/Bootstrap.R index 20cac0d..9c599b7 100644 --- a/R/Bootstrap.R +++ b/R/Bootstrap.R @@ -1,5 +1,8 @@ #' 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. From b03538e261c6bcc05b0f2b770a6ec0646ff767dd Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 23 Apr 2013 11:27:14 -0600 Subject: [PATCH 006/112] Updated Bootstrap documentation 2 --- man/Bootstrap.Rd | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/man/Bootstrap.Rd b/man/Bootstrap.Rd index e170683..5b773d8 100644 --- a/man/Bootstrap.Rd +++ b/man/Bootstrap.Rd @@ -7,12 +7,13 @@ \arguments{ \item{x}{a vector.} - \item{Boots}{The number of bootstraps} + \item{Boots}{The number of bootstraps.} - \item{fn}{the function you want to bootstrap} + \item{fn}{the function you want to bootstrap.} } \description{ - Bootstrap + This function is used for estimating standard errors when + the distribution is not know. } \author{ Tyler Hunt \email{tyler@psychoanalytix.com} From 95c2fdf28fdbe67e92c26ab907048b5151927d89 Mon Sep 17 00:00:00 2001 From: dcaff Date: Tue, 23 Apr 2013 20:24:14 -0600 Subject: [PATCH 007/112] test, added periods --- CompPack/CompPack.Rproj | 13 +++++++++++++ CompPack/debug.log | 0 R/pois.proc.R | 2 +- R/rand.unif.R | 6 +++--- debug.log | 0 5 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 CompPack/CompPack.Rproj create mode 100644 CompPack/debug.log create mode 100644 debug.log 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/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.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 From e19b89239dc79985728f3aa0978715cbe6365b0e Mon Sep 17 00:00:00 2001 From: dcaff Date: Wed, 24 Apr 2013 12:52:24 -0600 Subject: [PATCH 008/112] Polar random normal --- R/rand.norm.R | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) 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 } From 0ed074a4111f16a4a1525ef035343e7f3fc81d82 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Thu, 25 Apr 2013 11:00:59 -0600 Subject: [PATCH 009/112] added descritpion --- R/rand.norm.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/rand.norm.R b/R/rand.norm.R index 46920c1..7c6e18b 100644 --- a/R/rand.norm.R +++ b/R/rand.norm.R @@ -1,5 +1,6 @@ #' Generate Random Normal Variables #' +#' @description #' @param n Number of observations #' @param mean vector of means #' @param sd vector of standard deviations From 22c1108887942f92464b0bdd3c02d3dccd21bbbe Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Thu, 25 Apr 2013 11:19:48 -0600 Subject: [PATCH 010/112] Changed to polar norm --- R/.gitignore | 1 + R/polar.norm.R | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 R/.gitignore create mode 100644 R/polar.norm.R 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/polar.norm.R b/R/polar.norm.R new file mode 100644 index 0000000..fcfdf48 --- /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 sigma 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 +} From 81bb40ddadfcb6ade63388f0abb753b05e5d046f Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Thu, 25 Apr 2013 11:48:10 -0600 Subject: [PATCH 011/112] Added polar norm and tweaks --- DESCRIPTION | 1 + NAMESPACE | 1 + R/polar.norm.R | 2 +- R/rand.norm.R | 2 +- man/maxbound.Rd | 4 ++-- man/pois.proc.Rd | 2 +- man/polar.norm.Rd | 20 ++++++++++++++++++++ man/rand.unif.Rd | 6 +++--- 8 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 man/polar.norm.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 494f53c..5ac1886 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,3 +29,4 @@ Collate: 'around.R' 'nearest.loc.R' 'Bootstrap.R' + 'polar.norm.R' diff --git a/NAMESPACE b/NAMESPACE index da11b0a..a8225af 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,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/polar.norm.R b/R/polar.norm.R index fcfdf48..6150983 100644 --- a/R/polar.norm.R +++ b/R/polar.norm.R @@ -2,7 +2,7 @@ #' #' @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 sig variance of a normal distribution #' #' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} #' diff --git a/R/rand.norm.R b/R/rand.norm.R index 4437a53..46920c1 100644 --- a/R/rand.norm.R +++ b/R/rand.norm.R @@ -10,4 +10,4 @@ rand.norm<-function(n, mean, sd){ qnorm( replicate( n, wich.hill() ) )*sd + mean -} \ No newline at end of file +} 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 From a3189281ab15464e43d8a5c210e000b1b32125ae Mon Sep 17 00:00:00 2001 From: dcaff Date: Thu, 25 Apr 2013 11:52:15 -0600 Subject: [PATCH 012/112] updated description --- R/jackknife.R | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 R/jackknife.R diff --git a/R/jackknife.R b/R/jackknife.R new file mode 100644 index 0000000..9c2a209 --- /dev/null +++ b/R/jackknife.R @@ -0,0 +1,37 @@ +#' Resamples Data using the Jackknife Method +#' +#' @description +#' This function is used for estimating standard errors when the distribution is not know. +#' +#' @param x a vector +#' @param t estimation of parameter +#' +#' @return est orignial estimation of parameter +#' @return jkest jackknife estimation of parameter +#' @return jkvar jackknife estimation of variance +#' @return jkbias jackknife estimate of biasness of parameter +#' @return jkbiascorr bias corrected parameter estimate +#' +#' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} +#' +#' @example x = runif(10, 0, 1) +#' mean(x) +#' jackknife(x,mean) +#' +#' @export + +jackknife<-function (x,t) +{ + n=length(x) + jk=rep(NA,n) + + for (i in 1:n) + { + jk[i]=t(x[-i]) + jkest=mean(jk) + jkvar=(n-1)/n*sum((jk-jkest)^2) + jkbias=(n-1)*(jkest-t(x)) + jkbiascorr=n*t(x)-(n-1)*jkest + } + list(est=t(x), jkest=jkest, jkvar=jkvar, jkbias=jkbias, jkbiascorr=jkbiascorr) +} From d56c5104fd853dcbac8c45209b4bb4ba9d53f874 Mon Sep 17 00:00:00 2001 From: dcaff Date: Thu, 25 Apr 2013 11:52:28 -0600 Subject: [PATCH 013/112] updated documentation --- R/em.mixnorm.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/em.mixnorm.R b/R/em.mixnorm.R index 98264e3..483cc03 100644 --- a/R/em.mixnorm.R +++ b/R/em.mixnorm.R @@ -5,6 +5,7 @@ #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' @export + em.mixnorm <- function (x,k){ p = rep(1/k,k) From 174c6c62aec2bd8b68005ff92faf4a5fa65c91a4 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Thu, 25 Apr 2013 11:56:45 -0600 Subject: [PATCH 014/112] Changed jackknife example to examples --- DESCRIPTION | 1 + NAMESPACE | 1 + R/jackknife.R | 2 +- man/jackknife.Rd | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 man/jackknife.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 5ac1886..33a67a5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -30,3 +30,4 @@ Collate: 'nearest.loc.R' 'Bootstrap.R' 'polar.norm.R' + 'jackknife.R' diff --git a/NAMESPACE b/NAMESPACE index a8225af..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) 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/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} +} + From a91ef3a088304e2bfdbac6588f71d5605a697a67 Mon Sep 17 00:00:00 2001 From: dcaff Date: Thu, 25 Apr 2013 12:00:47 -0600 Subject: [PATCH 015/112] unchecked Bootstrap --- R/Bootstrap.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/Bootstrap.R b/R/Bootstrap.R index 9c599b7..7fb7caf 100644 --- a/R/Bootstrap.R +++ b/R/Bootstrap.R @@ -5,10 +5,14 @@ #' #' @param x a vector. #' @param Boots The number of bootstraps. -#' @param fn the function you want to bootstrap. +#' @param fn the function you want to bootstrap, ie., mean, var, cov, etc. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' +#' @examples +#' x = runif(10, 0, 1) +#' Bootstrap(x,fn=mean) +#' #' @export From d076f5cdb69760e85997b6e70a74da144740e003 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Thu, 25 Apr 2013 15:04:53 -0600 Subject: [PATCH 016/112] checked bootstrap --- man/Bootstrap.Rd | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/man/Bootstrap.Rd b/man/Bootstrap.Rd index 5b773d8..c91ae7a 100644 --- a/man/Bootstrap.Rd +++ b/man/Bootstrap.Rd @@ -9,12 +9,17 @@ \item{Boots}{The number of bootstraps.} - \item{fn}{the function you want to bootstrap.} + \item{fn}{the function you want to bootstrap, ie., mean, + var, cov, etc.} } \description{ This function is used for estimating standard errors when the distribution is not know. } +\examples{ +x = runif(10, 0, 1) +Bootstrap(x,fn=mean) +} \author{ Tyler Hunt \email{tyler@psychoanalytix.com} } From ea6bd6f42bd958a9ae51e498bdb7845525510d07 Mon Sep 17 00:00:00 2001 From: dcaff Date: Thu, 25 Apr 2013 17:48:47 -0600 Subject: [PATCH 017/112] added @return values and example --- R/around.R | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/R/around.R b/R/around.R index cb63ed8..307a902 100644 --- a/R/around.R +++ b/R/around.R @@ -6,7 +6,15 @@ #' @param value specified value #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} -#' @export +#' +#' @return lo the maximum value of x that is less than or equal to the value parameter. +#' @return hi the minimum value of x that is greater than or equal to the value parameter. +#' +#' @examples +#' x = rnorm(50, 3, 7) +#' value = 15 +#' +#' @export around<-function(x, value){ x<-sort(x) From 801e9510883f1c438d6cf34c19a96ed902e4bc2b Mon Sep 17 00:00:00 2001 From: dcaff Date: Thu, 25 Apr 2013 18:24:40 -0600 Subject: [PATCH 018/112] added an example --- R/mixnorm.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/R/mixnorm.R b/R/mixnorm.R index 13e5ef5..3101519 100644 --- a/R/mixnorm.R +++ b/R/mixnorm.R @@ -6,6 +6,11 @@ #' @param sd vector of standard deviations #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} +#' +#' @examples +#' x = mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)) +#' hist(x) +#' #' @export mixnorm <- From 58a840ef2c59b1b857b977280a47f4f9836c330d Mon Sep 17 00:00:00 2001 From: dcaff Date: Thu, 25 Apr 2013 18:27:25 -0600 Subject: [PATCH 019/112] added return values and an example --- R/em.mixnorm.R | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/R/em.mixnorm.R b/R/em.mixnorm.R index 483cc03..79f680b 100644 --- a/R/em.mixnorm.R +++ b/R/em.mixnorm.R @@ -3,7 +3,17 @@ #' @param x the data. #' @param k estimate of the number of mixtures. #' +#' @return itterations number of cycles the program used to calculate the estimated means, standard devaitions and probabilities. +#' @return means estimated mean of each mixture. +#' @return stddevs estimated standard deviation of each mixture. +#' @return probs estimated probabilities of each mixture. +#' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} +#' +#' @examples +#' x=mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)) +#' em.mixnorm(x,3) +#' #' @export em.mixnorm <- From d0fd8edbaf93d796eb7ecec85f1a4818872087ba Mon Sep 17 00:00:00 2001 From: dcaff Date: Thu, 25 Apr 2013 18:59:24 -0600 Subject: [PATCH 020/112] added tyler as the author, return values and an example --- R/gold.sect.R | 7 +++++++ R/maxbound.R | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/R/gold.sect.R b/R/gold.sect.R index bddce10..bd61c06 100644 --- a/R/gold.sect.R +++ b/R/gold.sect.R @@ -4,7 +4,14 @@ #' @param lo Lower estimate #' @param hi Upper estimate #' @param tol Level of tolerance desired for optimization +#' +#' @return a estimated optimal value of the function +#' @return f(a) function value at the optimal value #' +#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} +#' +#' @examples +#' gold.sect(sin, 1/2, pi/2) #' #" @export diff --git a/R/maxbound.R b/R/maxbound.R index fd6481e..ddf722f 100644 --- a/R/maxbound.R +++ b/R/maxbound.R @@ -4,6 +4,15 @@ #' @param lo the lower bound. #' @param hi the upper bound. #' +#' @return lo lower bound estimate of the function's optimum +#' @return hi upper bound estimate of the function's optimum +#' +#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} +#' +#' @examples +#' maxbound(sin, 1/2, pi/2) +#' +#' #' @export maxbound <- From 3ccc53b5f9f40fb4d764a77dd209b4f8fd5f3e00 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Thu, 25 Apr 2013 20:31:18 -0600 Subject: [PATCH 021/112] ran check on Damon's edits --- NAMESPACE | 1 + man/around.Rd | 11 +++++++++++ man/em.mixnorm.Rd | 15 +++++++++++++++ man/gold.sect.Rd | 11 +++++++++++ man/maxbound.Rd | 11 +++++++++++ man/mixnorm.Rd | 4 ++++ 6 files changed, 53 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 7fc3467..dc2be1c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,7 @@ export(Bootstrap) export(around) export(em.mixnorm) +export(gold.sect) export(grid.sect) export(jackknife) export(maxbound) diff --git a/man/around.Rd b/man/around.Rd index 8a4df79..b431c50 100644 --- a/man/around.Rd +++ b/man/around.Rd @@ -9,9 +9,20 @@ \item{value}{specified value} } +\value{ + lo the maximum value of x that is less than or equal to + the value parameter. + + hi the minimum value of x that is greater than or equal + to the value parameter. +} \description{ Find the location of values around a specified value } +\examples{ +x = rnorm(50, 3, 7) +value = 15 +} \author{ Tyler Hunt \email{tyler@psychoanalytix.com} } diff --git a/man/em.mixnorm.Rd b/man/em.mixnorm.Rd index f16059b..96d2c84 100644 --- a/man/em.mixnorm.Rd +++ b/man/em.mixnorm.Rd @@ -9,9 +9,24 @@ \item{k}{estimate of the number of mixtures.} } +\value{ + itterations number of cycles the program used to + calculate the estimated means, standard devaitions and + probabilities. + + means estimated mean of each mixture. + + stddevs estimated standard deviation of each mixture. + + probs estimated probabilities of each mixture. +} \description{ EM-Algorithm for Normal Distribution } +\examples{ +x=mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)) +em.mixnorm(x,3) +} \author{ Tyler Hunt \email{tyler@psychoanalytix.com} } diff --git a/man/gold.sect.Rd b/man/gold.sect.Rd index 6d4aeba..d7d9507 100644 --- a/man/gold.sect.Rd +++ b/man/gold.sect.Rd @@ -13,7 +13,18 @@ \item{tol}{Level of tolerance desired for optimization} } +\value{ + a estimated optimal value of the function + + f(a) function value at the optimal value +} \description{ Golden Section Search Optimization } +\examples{ +gold.sect(sin, 1/2, pi/2) +} +\author{ + Tyler Hunt \email{tyler@psychoanalytix.com} +} diff --git a/man/maxbound.Rd b/man/maxbound.Rd index 3de3870..fcbbcfc 100644 --- a/man/maxbound.Rd +++ b/man/maxbound.Rd @@ -11,7 +11,18 @@ \item{hi}{the upper bound.} } +\value{ + lo lower bound estimate of the function's optimum + + hi upper bound estimate of the function's optimum +} \description{ Maxbound Optimization } +\examples{ +maxbound(sin, 1/2, pi/2) +} +\author{ + Tyler Hunt \email{tyler@psychoanalytix.com} +} diff --git a/man/mixnorm.Rd b/man/mixnorm.Rd index 2b485d1..9050f10 100644 --- a/man/mixnorm.Rd +++ b/man/mixnorm.Rd @@ -17,6 +17,10 @@ \description{ Create a Mixture of Normal Distributions } +\examples{ +x = mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)) +hist(x) +} \author{ Tyler Hunt \email{tyler@psychoanalytix.com} } From 7665b80b17559c0ca8339babde085098bb0f6a5f Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Thu, 25 Apr 2013 20:31:44 -0600 Subject: [PATCH 022/112] took out wrong quote before export --- R/gold.sect.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/gold.sect.R b/R/gold.sect.R index bd61c06..8c8527d 100644 --- a/R/gold.sect.R +++ b/R/gold.sect.R @@ -13,8 +13,7 @@ #' @examples #' gold.sect(sin, 1/2, pi/2) #' -#" @export - +#' @export gold.sect <- function(f,lo,hi,tol=0.0000001){ g = 1-(sqrt(5)-1)/2 From 80bc57de5ce501837b519fb8fe528985103fe4fc Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 08:09:14 -0600 Subject: [PATCH 023/112] Update em.mixnorm.R added a description of the function --- R/em.mixnorm.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/em.mixnorm.R b/R/em.mixnorm.R index 79f680b..d7be018 100644 --- a/R/em.mixnorm.R +++ b/R/em.mixnorm.R @@ -1,4 +1,6 @@ #' EM-Algorithm for Normal Distribution +#' +#' @description the expectation–maximization (EM) algorithm is an iterative method for finding an estimate for the maximum a posteriori (MAP) of a normal distribution. The EM iteration alternates between performing an expectation (E) step, which creates a function for the expectation of the log-likelihood evaluated using the current estimate for the parameters, and a maximization (M) step, which computes parameters maximizing the expected log-likelihood found on the E step. These parameter-estimates are then used to determine the distribution of the latent variables in the next E step. #' #' @param x the data. #' @param k estimate of the number of mixtures. From f85aa81dfd13b0b77f61e90621bac77834dc7e14 Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 08:16:56 -0600 Subject: [PATCH 024/112] Update gold.sect.R added a description --- R/gold.sect.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/gold.sect.R b/R/gold.sect.R index 8c8527d..53cd2f3 100644 --- a/R/gold.sect.R +++ b/R/gold.sect.R @@ -1,4 +1,6 @@ #' Golden Section Search Optimization +#' +#' @description the golden section search is a technique for finding the extremum (minimum or maximum) of a strictly unimodal function by using the golden ratio to successively narrow the range of values inside which the extremum is known to exist. #' #' @param f The function to be optimized #' @param lo Lower estimate From 233c6828974abe797c507fb9303613f921f8508c Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 09:03:40 -0600 Subject: [PATCH 025/112] Update grid.sect.R Added description and return --- R/grid.sect.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/R/grid.sect.R b/R/grid.sect.R index 1e13541..bae37d5 100644 --- a/R/grid.sect.R +++ b/R/grid.sect.R @@ -1,9 +1,15 @@ #' Grid Section Search Optimization #' +#' @description method of numerical optimization which uses a simple learning algorythm that compares two points of a function. The lower of the two points is discarded, then adjusted and re-evaluated. The process is repeated until an optimum is located. +#' #' @param f the function to be optimized #' @param lo the lower bound #' @param hi the upper bound #' +#' @return X[i] estimated maximum of the function +#' +#' @author +#' #' @export grid.sect <- From 11ee99795414a033c1dba1f8eb2c75f379233d3e Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 09:18:51 -0600 Subject: [PATCH 026/112] Update grid.sect.R working directly on git-hub today. I tried to run this function to better understand the values and I receive an error on the while(h-l>.0000001 line. It states that we are missing a True/False statement. I am not sure what it is asking for, can you please review it Tyler? I also removed @ return and added tyler as author. --- R/grid.sect.R | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/R/grid.sect.R b/R/grid.sect.R index bae37d5..2ecc610 100644 --- a/R/grid.sect.R +++ b/R/grid.sect.R @@ -6,9 +6,7 @@ #' @param lo the lower bound #' @param hi the upper bound #' -#' @return X[i] estimated maximum of the function -#' -#' @author +#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' #' @export From 25e96c736058ecce5e7fbf060b053404e9c7af43 Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 09:37:35 -0600 Subject: [PATCH 027/112] Update grid.sect.R From ced03f303c007dd77591e790a7215514b8cf334a Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 09:45:39 -0600 Subject: [PATCH 028/112] Update jackknife.R updated description --- R/jackknife.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/jackknife.R b/R/jackknife.R index c38bd98..9a74f3c 100644 --- a/R/jackknife.R +++ b/R/jackknife.R @@ -1,7 +1,7 @@ #' Resamples Data using the Jackknife Method #' #' @description -#' This function is used for estimating standard errors when the distribution is not know. +#' a resampling method that can be used to estimate the bias and variance when a random sample of observations is used. #' #' @param x a vector #' @param t estimation of parameter From dc6041a42cd6669af9943c590a6196b32a2bc8b4 Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 09:48:40 -0600 Subject: [PATCH 029/112] Update maxbound.R added description... sorry for all the description updates Tyler. It occurred to me last night that I did not add these yesterday --- R/maxbound.R | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/R/maxbound.R b/R/maxbound.R index ddf722f..b79255b 100644 --- a/R/maxbound.R +++ b/R/maxbound.R @@ -1,11 +1,14 @@ #' Maxbound Optimization #' -#' @param f the function to be optimized +#' @description +#' Obtains estimations of the lower and upper bounds to a function's optimum point. +#' +#' @param f the function to be optimized. #' @param lo the lower bound. #' @param hi the upper bound. #' -#' @return lo lower bound estimate of the function's optimum -#' @return hi upper bound estimate of the function's optimum +#' @return lo lower bound estimate of the function's optimum. +#' @return hi upper bound estimate of the function's optimum. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' From 05c1d5119137907e90a68abca0dbbf4a7f30120b Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 09:50:24 -0600 Subject: [PATCH 030/112] Update mc.R added description --- R/mc.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/mc.R b/R/mc.R index 55c6b50..2e837e8 100644 --- a/R/mc.R +++ b/R/mc.R @@ -1,8 +1,10 @@ #' Generate Markov Chains #' +#' @description +#' generates a markov chain. #' -#' @param p Probability matrix -#' @param n Number of observations +#' @param p Probability matrix. +#' @param n Number of observations. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' From 0b1dc4c130ffbfa35668f8b1712fe42a96e1a649 Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 10:07:15 -0600 Subject: [PATCH 031/112] Update mixnorm.R Added description --- R/mixnorm.R | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/R/mixnorm.R b/R/mixnorm.R index 3101519..ebb7588 100644 --- a/R/mixnorm.R +++ b/R/mixnorm.R @@ -1,9 +1,12 @@ #' Create a Mixture of Normal Distributions #' -#' @param n number of observations. If \eqn{length(n) > 1}, the length is taken to be the number required -#' @param p vector of probabilities -#' @param mu vector of means -#' @param sd vector of standard deviations +#' @description +#' Creates a mixture of normal distributions. +#' +#' @param n number of observations. If \eqn{length(n) > 1}, the length is taken to be the number required. +#' @param p vector of probabilities. +#' @param mu vector of means. +#' @param sd vector of standard deviations. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' From 83aa7154e4a758e898915ddbecb17caa6cddf741 Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 10:12:11 -0600 Subject: [PATCH 032/112] Update nearest.R added return --- R/nearest.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/nearest.R b/R/nearest.R index ecb5b19..7c53d36 100644 --- a/R/nearest.R +++ b/R/nearest.R @@ -3,8 +3,9 @@ #' @description Find the the nearest value to a number that you specify. #' #' @param x a vector. -#' @param value the value that you want to find. +#' @param value the value that you would like to locate within the vector. #' +#' @return x the number wihtin the vecor with the closest numerical proximity to the value requested #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' @export From aa7a9a5602fa38f59f33de5ff05b33a080a3f21c Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 10:50:40 -0600 Subject: [PATCH 033/112] Update newton.raph.R added a description --- R/newton.raph.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/newton.raph.R b/R/newton.raph.R index c82150d..be57f7d 100644 --- a/R/newton.raph.R +++ b/R/newton.raph.R @@ -1,12 +1,14 @@ #' Newton Raphson Alogorithm #' +#' @description +#' A method for locating succesively better approximations for the optimal point of a function. The Newton Raphson method is named after Sir Issac Newton and Joseph Raphson +#' #' @param f The function that you want to optimize. #' @param df the 1st derivative of the function. #' @param d2f the 2nd derivative of the function. #' @param start The starting value for optimization. #' @param tol The level of tolerance desired for convergence. #' -#' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' @export From b5e9598f4a6252ec1b87f9ba13f962b497cdf508 Mon Sep 17 00:00:00 2001 From: dcaff Date: Fri, 26 Apr 2013 12:08:32 -0600 Subject: [PATCH 034/112] unchecked log liklihood function --- R/log.lik | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 R/log.lik diff --git a/R/log.lik b/R/log.lik new file mode 100644 index 0000000..a0dfb87 --- /dev/null +++ b/R/log.lik @@ -0,0 +1,25 @@ +#' Find the logliklihood of a normal distribution +#' +#' @description +#' Find the logliklihood of a normal distribution. +#' +#' @param x data +#' @param mu estimated mean +#' @param var estimated variance +#' +#' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} +#' +#' @return -ll logliklihood of the distribution +#' +#' @examples +#' x = rnorm(100, 3, 7) +#' log.lik(x,3,7) +#' +#' @export + +log.lik<-function(x=data, mu, var) +{ + ll = -n/2* log(2*pi*var) - .5/var*sum((mu-y)^2) + + -ll +} From 943d3aedcb73bea2814c2595bfdf1d58cf82e714 Mon Sep 17 00:00:00 2001 From: dcaff Date: Fri, 26 Apr 2013 12:16:04 -0600 Subject: [PATCH 035/112] no changes made to this, but it will not allow me to pull a merge request until I commit this. Please ignore. --- R/em.mixnorm.R | 3 +++ 1 file changed, 3 insertions(+) diff --git a/R/em.mixnorm.R b/R/em.mixnorm.R index 79f680b..8fcfa0f 100644 --- a/R/em.mixnorm.R +++ b/R/em.mixnorm.R @@ -1,4 +1,7 @@ #' EM-Algorithm for Normal Distribution +#' +#' @description +#' The Expectation-Maximization A #' #' @param x the data. #' @param k estimate of the number of mixtures. From 892e2b118448d6236b58ea5cc9e2a3c97ed45c59 Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 12:59:47 -0600 Subject: [PATCH 036/112] Update em.mixnorm.R I thought I had updated the description, but it was incomplete. --- R/em.mixnorm.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/em.mixnorm.R b/R/em.mixnorm.R index 8fcfa0f..81f0663 100644 --- a/R/em.mixnorm.R +++ b/R/em.mixnorm.R @@ -1,7 +1,7 @@ #' EM-Algorithm for Normal Distribution #' #' @description -#' The Expectation-Maximization A +#' The Expectation-Maximization (EM) algorithm is and itterative method for locating the maximum estimate for the parameters of a mixture of normal distributions. The EM iteration alternates between performing an expectation (E) step, which creates a function for the expectation of the log-likelihood evaluated using the current estimate for the parameters, and a maximization (M) step, which computes parameters maximizing the expected log-likelihood found on the E step. These parameter-estimates #' #' @param x the data. #' @param k estimate of the number of mixtures. From 9eed25ff5c5a816da9b6a0b9b264e3c23bd21b8a Mon Sep 17 00:00:00 2001 From: dcaff Date: Fri, 26 Apr 2013 13:25:58 -0600 Subject: [PATCH 037/112] updated description, and/or results and/or added periods --- R/gold.sect.R | 3 +++ R/grid.sect.R | 11 ++++++++--- R/log.lik | 25 ------------------------- R/log.lik.R | 6 +++--- R/maxbound.R | 9 ++++++--- R/mc.R | 9 +++++++-- R/mixnorm.R | 11 +++++++---- R/newton.raph.R | 6 ++++++ 8 files changed, 40 insertions(+), 40 deletions(-) delete mode 100644 R/log.lik diff --git a/R/gold.sect.R b/R/gold.sect.R index 8c8527d..c62fd6e 100644 --- a/R/gold.sect.R +++ b/R/gold.sect.R @@ -1,4 +1,7 @@ #' Golden Section Search Optimization +#' +#' @description +#' A method used for locating the optimum value of a function. The technique utilizes the golden ratio to successively narrow the range of values for which the optimum is found. #' #' @param f The function to be optimized #' @param lo Lower estimate diff --git a/R/grid.sect.R b/R/grid.sect.R index 1e13541..f393bde 100644 --- a/R/grid.sect.R +++ b/R/grid.sect.R @@ -1,8 +1,13 @@ #' Grid Section Search Optimization #' -#' @param f the function to be optimized -#' @param lo the lower bound -#' @param hi the upper bound +#' @description +#' A method used to locate the optimum value of a function. +#' +#' @param f the function to be optimized. +#' @param lo the lower bound. +#' @param hi the upper bound. +#' +#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' #' @export diff --git a/R/log.lik b/R/log.lik deleted file mode 100644 index a0dfb87..0000000 --- a/R/log.lik +++ /dev/null @@ -1,25 +0,0 @@ -#' Find the logliklihood of a normal distribution -#' -#' @description -#' Find the logliklihood of a normal distribution. -#' -#' @param x data -#' @param mu estimated mean -#' @param var estimated variance -#' -#' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} -#' -#' @return -ll logliklihood of the distribution -#' -#' @examples -#' x = rnorm(100, 3, 7) -#' log.lik(x,3,7) -#' -#' @export - -log.lik<-function(x=data, mu, var) -{ - ll = -n/2* log(2*pi*var) - .5/var*sum((mu-y)^2) - - -ll -} diff --git a/R/log.lik.R b/R/log.lik.R index a0dfb87..3040075 100644 --- a/R/log.lik.R +++ b/R/log.lik.R @@ -3,9 +3,9 @@ #' @description #' Find the logliklihood of a normal distribution. #' -#' @param x data -#' @param mu estimated mean -#' @param var estimated variance +#' @param x data. +#' @param mu estimated mean. +#' @param var estimated variance. #' #' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} #' diff --git a/R/maxbound.R b/R/maxbound.R index ddf722f..126d182 100644 --- a/R/maxbound.R +++ b/R/maxbound.R @@ -1,11 +1,14 @@ #' Maxbound Optimization #' -#' @param f the function to be optimized +#' @description +#' Used to estimate the bounds of a function, in which the optimum value will be located within. +#' +#' @param f the function to be optimized. #' @param lo the lower bound. #' @param hi the upper bound. #' -#' @return lo lower bound estimate of the function's optimum -#' @return hi upper bound estimate of the function's optimum +#' @return lo lower bound estimate of the function's optimum. +#' @return hi upper bound estimate of the function's optimum. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' diff --git a/R/mc.R b/R/mc.R index 55c6b50..b6b975b 100644 --- a/R/mc.R +++ b/R/mc.R @@ -1,8 +1,12 @@ #' Generate Markov Chains #' +#' @description +#' Generates a Markov Chain. #' -#' @param p Probability matrix -#' @param n Number of observations +#' @param p Probability matrix. +#' @param n Number of observations. +#' +#' @return x values of observations. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' @@ -15,6 +19,7 @@ #' mc(B, 10) #' mc(C, 10) #' mc(D, 10) +#' #' @export mc<-function(p, n){ diff --git a/R/mixnorm.R b/R/mixnorm.R index 3101519..097ab90 100644 --- a/R/mixnorm.R +++ b/R/mixnorm.R @@ -1,9 +1,12 @@ #' Create a Mixture of Normal Distributions +#' +#' @description +#' Creates a mixture of normal distributions. #' -#' @param n number of observations. If \eqn{length(n) > 1}, the length is taken to be the number required -#' @param p vector of probabilities -#' @param mu vector of means -#' @param sd vector of standard deviations +#' @param n number of observations. If \eqn{length(n) > 1}, the length is taken to be the number required. +#' @param p vector of probabilities. +#' @param mu vector of means. +#' @param sd vector of standard deviations. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' diff --git a/R/newton.raph.R b/R/newton.raph.R index c82150d..bc78f8a 100644 --- a/R/newton.raph.R +++ b/R/newton.raph.R @@ -1,11 +1,17 @@ #' Newton Raphson Alogorithm #' +#' @description +#' A method for obtaining successively better approximations for the optimal value of a function. Named after Sir Isaac Newton and Joseph Raphson. +#' #' @param f The function that you want to optimize. #' @param df the 1st derivative of the function. #' @param d2f the 2nd derivative of the function. #' @param start The starting value for optimization. #' @param tol The level of tolerance desired for convergence. #' +#' @return Estimate Initial estimate of the optimum value. +#' @return Iterations Number of cycles used to obtain the optimum value of the function. +#' @return Liklihood Optimum value #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' @export From aba9f841ae8ff0b3d6daf4c593c9634faae86107 Mon Sep 17 00:00:00 2001 From: dcaff Date: Fri, 26 Apr 2013 14:02:37 -0600 Subject: [PATCH 038/112] added a description and periods --- R/pois.proc.R | 5 +++++ R/rand.exp.R | 3 +++ R/rand.mvnorm.R | 8 ++++---- R/rand.norm.R | 9 ++++++--- R/rand.unif.R | 3 +++ 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/R/pois.proc.R b/R/pois.proc.R index 9b84070..9060945 100644 --- a/R/pois.proc.R +++ b/R/pois.proc.R @@ -1,10 +1,15 @@ #' Generate a Poisson Process #' +#' @description +#' Generates a Poisson Process. +#' #' @param end the end time desired. #' @param rate the rate of occurrence. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' +#' @results cumsum the cumulative sum of the vector of a poisson process. +#' #' @examples pois.proc(200, 1) #' @export diff --git a/R/rand.exp.R b/R/rand.exp.R index ba00cc2..0762de3 100644 --- a/R/rand.exp.R +++ b/R/rand.exp.R @@ -1,5 +1,8 @@ #' Generate Random Exponential Variables #' +#' @description +#' Generates a pseudo-random exponential variable using the Whichman-Hill pseudo-random number generator function +#' #' @param n Number of observations #' @param rate vector of rates #' diff --git a/R/rand.mvnorm.R b/R/rand.mvnorm.R index bdb117b..967279e 100644 --- a/R/rand.mvnorm.R +++ b/R/rand.mvnorm.R @@ -1,9 +1,9 @@ #' Generate Multivariate Normal Distribution #' -#' @description A method for generating random multivariate normal data that is based on a cholesky decomposition. -#' @param n the number of observations -#' @param mu a vector of means -#' @param sigma a variance-covariance matrix +#' @description A method for generating a pseudo-random multivariate normal data that is based on a cholesky decomposition. +#' @param n the number of observations. +#' @param mu a vector of means. +#' @param sigma a variance-covariance matrix. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' diff --git a/R/rand.norm.R b/R/rand.norm.R index 46920c1..0e5f1df 100644 --- a/R/rand.norm.R +++ b/R/rand.norm.R @@ -1,8 +1,11 @@ #' Generate Random Normal Variables #' -#' @param n Number of observations -#' @param mean vector of means -#' @param sd vector of standard deviations +#' @description +#' Generates pseudo random variables from a normal distribution using the Wichmannhill. +#' +#' @param n Number of observations. +#' @param mean vector of means. +#' @param sd vector of standard deviations. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' diff --git a/R/rand.unif.R b/R/rand.unif.R index 11ccfa7..8031e8d 100644 --- a/R/rand.unif.R +++ b/R/rand.unif.R @@ -1,5 +1,8 @@ #' Generate Random Uniform Variables #' +#' @description +#' Generates pseudo-random variables from a Uniform distribution, using the Wichmannhill. +#' #' @param n Number of observations. #' @param min lower limit of the distribution. #' @param max upper limit of the distribution. From e39908f28618f62c60ee3a36b4d1978b557081a8 Mon Sep 17 00:00:00 2001 From: dcaff Date: Fri, 26 Apr 2013 17:18:34 -0600 Subject: [PATCH 039/112] function for the first derivative --- R/df.R | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 R/df.R diff --git a/R/df.R b/R/df.R new file mode 100644 index 0000000..1601270 --- /dev/null +++ b/R/df.R @@ -0,0 +1,23 @@ +#' First Derivative +#' +#' @description +#' The first derivative of a function evaluated at point(s) x. +#' +#' Differentiation is a method to compute the rate at which the dependent output (f(x)) changes with respect to the change the independent input (x). The first derrivative can be used to obtain an exact value for the slope of the tangent line, at the point where the derivative was evaluated. +#' +#' @param f The function that you want to take the derivative of +#' @param x The point or vector of points where the derivative will be evaluated +#' +#' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} +#' +#' @examples +#' x = runif(10, pi/3, 3*pi/4) +#' df(tan, x) +#' +#' @export + +df <- function(f,x) +{ + d=0.0000001 + (f(x-d)-f(x))/d +} From e0fdff9fa71c52ebbd5304d3d723591c8393b533 Mon Sep 17 00:00:00 2001 From: dcaff Date: Fri, 26 Apr 2013 17:26:19 -0600 Subject: [PATCH 040/112] function of the second derivative --- R/d2f.R | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 R/d2f.R diff --git a/R/d2f.R b/R/d2f.R new file mode 100644 index 0000000..989e0cf --- /dev/null +++ b/R/d2f.R @@ -0,0 +1,23 @@ +#' Second Derivative +#' +#' @description +#' The Second derivative of a function evaluated at point(s) x. +#' +#' Roughly spoken, the seond derivative is the derivative of a derivative. This can be used to measure how the rate of change of a quantitty is itself changing. +#' +#' @param f The function that you want to take the derivative of +#' @param x The point or vector of points where the derivative will be evaluated +#' +#' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} +#' +#' @examples +#' x = runif(10, pi/3, 3*pi/4) +#' df(tan, x) +#' +#' @export + +df <- function(f,x) +{ + d=0.0000001 + (f(x-d)-2*f(x))/d/d +} From 409e98013f439b025d57b8c748eeae0cb976f62c Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 17:44:36 -0600 Subject: [PATCH 041/112] Update df.R already exists a df function in R, renaming it to d1f. Will also be updating functions that require the df function --- R/df.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/df.R b/R/df.R index 1601270..89b8df0 100644 --- a/R/df.R +++ b/R/df.R @@ -16,7 +16,7 @@ #' #' @export -df <- function(f,x) +d1f <- function(f,x) { d=0.0000001 (f(x-d)-f(x))/d From 7fd59b593ce18760ebbc62ac5e4c6aa267834a39 Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 17:45:06 -0600 Subject: [PATCH 042/112] Rename df.R to d1f.R --- R/{df.R => d1f.R} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename R/{df.R => d1f.R} (100%) diff --git a/R/df.R b/R/d1f.R similarity index 100% rename from R/df.R rename to R/d1f.R From c99a25cba14694a3eed8b17efde1fcb31a796f37 Mon Sep 17 00:00:00 2001 From: Damon Date: Fri, 26 Apr 2013 17:47:32 -0600 Subject: [PATCH 043/112] Update newton.raph.R updated df to d1f --- R/newton.raph.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/newton.raph.R b/R/newton.raph.R index bc78f8a..ec10b5b 100644 --- a/R/newton.raph.R +++ b/R/newton.raph.R @@ -17,14 +17,14 @@ #' @export -newton.raph <- function(f, df, d2f, start, tol=0.000001){ +newton.raph <- function(f, d1f, d2f, start, tol=0.000001){ new <- start + 10*tol iter <- 0 while(abs(start - new) > tol){ iter <- iter+1 new <- start - start <- start - df(start)/d2f(start) + start <- start - d1f(start)/d2f(start) } result<-c(Estimate=start, Iterations=iter, Likelihood=f(start)) return(result) From f2749b028b392dd49dd26e3ff2a2180357aede96 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Apr 2013 12:36:52 -0600 Subject: [PATCH 044/112] Uploaded a new 2dranduphill function that was use for hw4, for doing random uphill search on a matrix. Still need example if anyone can think of one. Thanks. --- DESCRIPTION | 4 ++++ NAMESPACE | 4 ++++ R/2dranduphill.R | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 R/2dranduphill.R diff --git a/DESCRIPTION b/DESCRIPTION index 33a67a5..f5ed9cf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,3 +31,7 @@ Collate: 'Bootstrap.R' 'polar.norm.R' 'jackknife.R' + '2dranduphill.R' + 'd1f.R' + 'd2f.R' + 'log.lik.R' diff --git a/NAMESPACE b/NAMESPACE index dc2be1c..0529c03 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,9 +1,12 @@ export(Bootstrap) export(around) +export(d1f) +export(df) export(em.mixnorm) export(gold.sect) export(grid.sect) export(jackknife) +export(log.lik) export(maxbound) export(mc) export(mixnorm) @@ -17,6 +20,7 @@ export(rand.exp) export(rand.mvnorm) export(rand.norm) export(rand.unif) +export(randuphill) export(tpower) export(update.CompPack) export(wich.hill) diff --git a/R/2dranduphill.R b/R/2dranduphill.R new file mode 100644 index 0000000..ab017cd --- /dev/null +++ b/R/2dranduphill.R @@ -0,0 +1,54 @@ +#' 2dranduphill +#' +#' @description +#' This function is use to do a random uphill search on any 2 demision data set +#' +#' @param f matrix of data set +#' @param y is the starting point for the search +#' @param x is the starting point for the search +#' @param n is the number of iteration for the search +#' @param s standard devation for each search jump, default at 1 +#' @param t is the tempearture, where its default at 100 +#' +#' @example +#' randuphill() +#' +#' @author Ernest Chan \email{faiernest418@gmail.com} +#' +#' @export + + +randuphill = function(f, x, y, s, n=100, t=100) +{ + + fm = f(x, y) + + resx = rep(0,n+1) + resy = rep(0,n+1) + resf = rep(0,n+1) + resx[1] = x + resy[1] = y + resf[1] = fm + + for( i in 1:n) + { + newx = x + rnorm(1, 0, s) + newy = y + rnorm(1, 0, s) + newfm = f(newx, newy) + + if(1 < (newfm/fm)^(1/t)) + { + x = newx + y = newy + fm = newfm + } + resx[i+1] = x + resy[i+1] = y + resf[i+1] = fm + + t = t * 0.999 + s = s * 0.9999 + } + list(x = resx, y = resy, z = resf) + +} \ No newline at end of file From 158904b1ebdf9657d0ad7f448e933d4c4ca3afed Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Apr 2013 12:46:42 -0600 Subject: [PATCH 045/112] Anneal function, haven't put anything in there description or comments, examples yet. --- DESCRIPTION | 1 + NAMESPACE | 1 + R/anneal.R | 42 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 R/anneal.R diff --git a/DESCRIPTION b/DESCRIPTION index f5ed9cf..a53afb8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -35,3 +35,4 @@ Collate: 'd1f.R' 'd2f.R' 'log.lik.R' + 'anneal.R' diff --git a/NAMESPACE b/NAMESPACE index 0529c03..c9c5deb 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,4 +1,5 @@ export(Bootstrap) +export(anneal) export(around) export(d1f) export(df) diff --git a/R/anneal.R b/R/anneal.R new file mode 100644 index 0000000..8794c2b --- /dev/null +++ b/R/anneal.R @@ -0,0 +1,42 @@ +#' anneal +#' @description +#' something for now +#' +#' @param f +#' @param mu +#' @param n +#' @param sig +#' @param tt +#' @param g +#' +#' @example +#' annel() +#' @author Ernest Chan \email{faiernest418@@gmail.com} +#' +#' @export + + +anneal=function(f,mu,n=1000,sig=1,tt=10,g=0.999) +{ + m = mu + fm = f(m) + x = rep(0,n) + fx = rep(0,n) + t = tt + for (i in 1:n) + { + dm = m+rnorm(1,0,sig) + fdm = f(dm) + + t = t*g + if (runif(1) < (fdm/fm)^(1/t)) + { + m = dm + fm = fdm + } + x[i] = m + fx[i] = fm + } + ii = ((1:n)[fx==max(fx)])[1] + list(x = x, fx = fx, best = x[ii], fbest = fx[ii], t=t) +} From 0e6165ddc01546f6c4aca6391a5c0feeb7492db8 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 27 Apr 2013 12:59:17 -0600 Subject: [PATCH 046/112] uphill.mixnorm function, basically is the same thing as the em one except with the uphill search method. param and example is not done yet cause i'm lazy, i'm just finding stuffs to put on atm --- DESCRIPTION | 1 + NAMESPACE | 1 + R/uphill.mixnorm.R | 60 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 R/uphill.mixnorm.R diff --git a/DESCRIPTION b/DESCRIPTION index a53afb8..147b7f5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,3 +36,4 @@ Collate: 'd2f.R' 'log.lik.R' 'anneal.R' + 'uphill.mixnorm.R' diff --git a/NAMESPACE b/NAMESPACE index c9c5deb..37f6e49 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,4 +24,5 @@ export(rand.unif) export(randuphill) export(tpower) export(update.CompPack) +export(uphill.mixnorm) export(wich.hill) diff --git a/R/uphill.mixnorm.R b/R/uphill.mixnorm.R new file mode 100644 index 0000000..b7e9c60 --- /dev/null +++ b/R/uphill.mixnorm.R @@ -0,0 +1,60 @@ +#' uphill.mixnorm +#' @description +#' This function is use for conducting a uphill search on the mixture of normal distribution +#' +#' @param x +#' @param k +#' @param n +#' @param t +#' +#' @example +#' something +#' +#' @author Ernest Chan \email{faiernest418@@gmail.com} +#' +#' @export + + +uphill.mixnorm = function(x, k, n = 10000, t = 100) +{ + p = rep(1/k, k) + mnx = min(x) + mxx = max(x) + m = (1:k) * (mxx-mnx)/(k+1) + mnx + s = rep(1, k) + + f = mixlike(x, p, m, s) + + for ( i in 1:n) + { + newm = m + for (j in 1:length(m)) + newm[j] = m[j] + rnorm(1, 0, 0.1) + + news = s + for (j in 1:length(s)) + { + t = log(s[j]) + rnorm(1, 0, 0.1) + news[j] = exp(t) + } + + newp = p + for (j in 1:length(p)) + { + t = log(p[j]) + rnorm(1, 0, 0.1) + newp[j] = exp(t) + } + newp = newp/sum(newp) + + newf = mixlike(x, newp, newm, news) + if (runif(1) < (newf/f)^(1/t)) + { + m = newm + s = news + p = newp + f = newf + } + t= t*.99 + } + list(prob = p, sd = s, mean = m, value = f) +} From 0f6fe4fd6ba0c75c97a482d1306cd673e4989497 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Apr 2013 10:25:09 -0600 Subject: [PATCH 047/112] added description/param on anneal, fixed a few errors on 2dranduphill when check(). --- R/2dranduphill.R | 4 ++-- R/anneal.R | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/R/2dranduphill.R b/R/2dranduphill.R index ab017cd..e9c9301 100644 --- a/R/2dranduphill.R +++ b/R/2dranduphill.R @@ -13,7 +13,7 @@ #' @example #' randuphill() #' -#' @author Ernest Chan \email{faiernest418@gmail.com} +#' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export @@ -51,4 +51,4 @@ randuphill = function(f, x, y, s, n=100, t=100) } list(x = resx, y = resy, z = resf) -} \ No newline at end of file +} diff --git a/R/anneal.R b/R/anneal.R index 8794c2b..dae646e 100644 --- a/R/anneal.R +++ b/R/anneal.R @@ -1,13 +1,13 @@ #' anneal #' @description -#' something for now +#' General anneal function, where we conduct a uphill search on the function to find maximum #' -#' @param f -#' @param mu -#' @param n -#' @param sig -#' @param tt -#' @param g +#' @param f function vector to find the maximum +#' @param mu starting point +#' @param n number of iterations +#' @param sig size of steps +#' @param tt temperature +#' @param g rate of temperature #' #' @example #' annel() From f23e54f3cf6d3577c5cb037b45e4369730dfdf05 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 28 Apr 2013 17:59:31 -0600 Subject: [PATCH 048/112] rda file for my economic data set, yes I think I figured out, maybe? someone test if it work please. --- data/econdata.rda | Bin 0 -> 3539 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 data/econdata.rda diff --git a/data/econdata.rda b/data/econdata.rda new file mode 100644 index 0000000000000000000000000000000000000000..feb2f0a656aa1520759a5529fed3bb4b5043d02a GIT binary patch literal 3539 zcmV;^4J`5>iwFP!000002JKmAR8`j!zM@e?^dXj55JgZ?RGJl(GYCjmx_C7T3J3_7 zDq@SMNK{n7h7BoF1(7KB0ygYP>>3lJ@u@K}#%MIw=iBFeb6t79KX2vNTPrzheRuB6 zo|)Zd@0ok9pL4K{Ua+1@rP5I~mOtf>COYDyk*bNRxuDGx!$OloBcfu$RjS5qgg{@Q zrGURm)oiiA5`j#Cr2@+YmJ4JFWDDd7tPof!uu5RHz#4&Efwcnb1l9{|5ZEY?C$LE% zU!XvsP@qU)vp}&xi9o49nLxQfg}@epN`WeYtpe2o+XQL^J{Q<7utT6$V5h(?f!zXo z1ojH-6WA|sK;WRjA%Qx9dV#|NM+A-v91}P$&>(O^;H1DQfztwK1kMVa6Zk^lOM$Nh z&I?=+xF~Q*;IhCKfvW=71g;BwEpS7uXDfM4X?faN@tmW~TPpdXC9T(qXFX+9Fr5$~ zKeXr^_{>J2%NIdETOaMq{{@;|hxQeNL01PrZ=I8^{7_y5`1}T@(dd7}E2jJ4XX6v_ z8_$Bz_W@sU6MhTRVPE8j_M!o3-<%G9^L_MJ><#^5W3-oKLtfeu_N5ykFMAEW3SG#z z%!ItEKlth{~D8fphb|^Z1Ga`KOdT==x;ZL{SGUp?RF@7J6gcL)&TakZ#yde z?lOnouCJLtjed7eVEzI0cRvB$TZw-5?T5ep<=_uw!tUU1$Pb;s`0B>NPn{daS>G3W z^+k{$9=%kNAFhM^NF@3>YWGyJKh}DzqIbMG(;wis!K_}nnYk;-I$u#!k;PgTK!&Uv7UX`VP7q@ zJnLDpd@#!;_T$RD+Ya#VTFUL7%zLpP57zg|03R>|egoNm5bFoBJh(6P)%u|0lF&Ym z`3dzHe+c^x4FNytBJ{#WqMtD4BNoGN)L77|g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5Z7Q4hkxRxZ zY5kBO&9`;aq`Z&%7ds?Rl{O7aef;Z$c2e%A4fR{XuSi+@(j#{B38lRM6Ys!MJDGUp+qmbX>ns zUbpm;eo@L)9SN`HBcwMy5bX zG;_6(e-Kdb6{!0y8&EG>J!&f#wq)5G@5?MBQBT?oL>+9q81I1wwnaT`#d_vBsDsUd z@&2;Qc)W*dhW?~`%4^hCb+?srw5y6AYWfWGH+uj-1B&rpc5oE>8FCuGcZN+->_7NZ z`6EqeYHkFn?+6>g>Z`o4LlNB)g=>Guu>rjY~|{a_+Hzcp-I{)X@z?7f9L%p62)x)>u>eA>HW2 Date: Mon, 29 Apr 2013 21:22:33 -0600 Subject: [PATCH 049/112] fix spelling error on anneal, added example and changed doc name on 2duphill to twoduphill --- DESCRIPTION | 2 +- NAMESPACE | 2 +- R/anneal.R | 6 +++--- R/{2dranduphill.R => twodranduphill.R} | 7 +++---- 4 files changed, 8 insertions(+), 9 deletions(-) rename R/{2dranduphill.R => twodranduphill.R} (85%) diff --git a/DESCRIPTION b/DESCRIPTION index 147b7f5..0384e24 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,9 +31,9 @@ Collate: 'Bootstrap.R' 'polar.norm.R' 'jackknife.R' - '2dranduphill.R' 'd1f.R' 'd2f.R' 'log.lik.R' 'anneal.R' 'uphill.mixnorm.R' + 'twodranduphill.R' diff --git a/NAMESPACE b/NAMESPACE index 37f6e49..a120d6a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -21,8 +21,8 @@ export(rand.exp) export(rand.mvnorm) export(rand.norm) export(rand.unif) -export(randuphill) export(tpower) +export(twodranduphill) export(update.CompPack) export(uphill.mixnorm) export(wich.hill) diff --git a/R/anneal.R b/R/anneal.R index dae646e..0f58fb8 100644 --- a/R/anneal.R +++ b/R/anneal.R @@ -1,4 +1,5 @@ #' anneal +#' #' @description #' General anneal function, where we conduct a uphill search on the function to find maximum #' @@ -10,13 +11,12 @@ #' @param g rate of temperature #' #' @example -#' annel() +#' anneal() #' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export - -anneal=function(f,mu,n=1000,sig=1,tt=10,g=0.999) +anneal = function(f,mu,n=1000,sig=1,tt=10,g=0.999) { m = mu fm = f(m) diff --git a/R/2dranduphill.R b/R/twodranduphill.R similarity index 85% rename from R/2dranduphill.R rename to R/twodranduphill.R index e9c9301..5e0638c 100644 --- a/R/2dranduphill.R +++ b/R/twodranduphill.R @@ -1,4 +1,4 @@ -#' 2dranduphill +#' twodranduphill #' #' @description #' This function is use to do a random uphill search on any 2 demision data set @@ -11,14 +11,13 @@ #' @param t is the tempearture, where its default at 100 #' #' @example -#' randuphill() +#' twodranduphill(matrix(c(1,2,3,4,5,6,7,8,9,10,.1,.2,5,3,7,6), ncol = 4), 1, .4, 1, 100, 10) #' #' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export - -randuphill = function(f, x, y, s, n=100, t=100) +twodranduphill = function(f, x, y, s, n=100, t=100) { fm = f(x, y) From 72ae3e5c0dc4c43e0c46577ad8f2a4f1363a0657 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 30 Apr 2013 11:05:02 -0600 Subject: [PATCH 050/112] add examples for anneal, uphill.mixnorm, add mixlike function which is necessary for uphill.mixnorm. --- DESCRIPTION | 1 + NAMESPACE | 1 + R/anneal.R | 2 +- R/mixlike.R | 36 ++++++++++++++++++++++++++++++++++++ R/uphill.mixnorm.R | 12 ++++++------ 5 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 R/mixlike.R diff --git a/DESCRIPTION b/DESCRIPTION index 0384e24..51aa61c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,3 +37,4 @@ Collate: 'anneal.R' 'uphill.mixnorm.R' 'twodranduphill.R' + 'mixlike.R' diff --git a/NAMESPACE b/NAMESPACE index a120d6a..7e31105 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,6 +10,7 @@ export(jackknife) export(log.lik) export(maxbound) export(mc) +export(mixlike) export(mixnorm) export(nearest) export(nearest.loc) diff --git a/R/anneal.R b/R/anneal.R index 0f58fb8..d69197e 100644 --- a/R/anneal.R +++ b/R/anneal.R @@ -11,7 +11,7 @@ #' @param g rate of temperature #' #' @example -#' anneal() +#' anneal(rnorm(1000,5,1), -20, 100, 1, 10, .99) #' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export diff --git a/R/mixlike.R b/R/mixlike.R new file mode 100644 index 0000000..e2cd6e8 --- /dev/null +++ b/R/mixlike.R @@ -0,0 +1,36 @@ +#' mixlike +#' +#' @description +#' A supplement fucntion for uphill.mixnorm, this use to compute the log likelihood funciotn for the mixture of normal distribution +#' +#' @param x is the mixture function to be evaluated +#' @param p is the vector of probabilities +#' @param m is the vector if means +#' @param s is the vector of standard deviation +#' +#' @example +#' mixlike(mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)), c(.5,.5), c(-5,5), c(1,1)) +#' +#' @author Ernest Chan \email(faiernest418@@gmail.com) +#' +#' @export + +mixlike = function(x, p, m, s) +{ + ll = 0 + + for (i in 1:length(p)) + { + fi = 0 + + for (j in 1:length(p)) + { + fi = fi + p[j] * dnorm(x[i], m[j], s[j]) + } + + ll = ll + log(fi) + } + + ll + +} diff --git a/R/uphill.mixnorm.R b/R/uphill.mixnorm.R index b7e9c60..56c7ffe 100644 --- a/R/uphill.mixnorm.R +++ b/R/uphill.mixnorm.R @@ -2,20 +2,20 @@ #' @description #' This function is use for conducting a uphill search on the mixture of normal distribution #' -#' @param x -#' @param k -#' @param n -#' @param t +#' @param x is the function of the mixture +#' @param k is the number of mixture +#' @param n is the number of iteration +#' @param t is the temperature #' #' @example -#' something +#' uphill.mixnorm(mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)), 4, 1000, 10) #' #' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export -uphill.mixnorm = function(x, k, n = 10000, t = 100) +uphill.mixnorm = function(x, k, n = 1000, t = 100) { p = rep(1/k, k) mnx = min(x) From dd660710b3af29162c9dc3982d004c7063ecd5d5 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 11:51:46 -0600 Subject: [PATCH 051/112] Added a random weibull function --- R/rand.weib.R | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 R/rand.weib.R diff --git a/R/rand.weib.R b/R/rand.weib.R new file mode 100644 index 0000000..94a5c68 --- /dev/null +++ b/R/rand.weib.R @@ -0,0 +1,14 @@ +#' Generate Random Weibull Variables +#' +#' @param n the number of observations +#' @param beta the specification of beta +#' @param theta the specification of theta +#' +#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} +#' +#' @export + +rand.weib<-function(n, beta, theta){ + x<-rand.unif(n, 0, 1) + theta*(log(1/x)^(1/beta)) +} \ No newline at end of file From 3de97860513eda1b312c4d9b8c3caae52b82a6b1 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 17:52:23 -0600 Subject: [PATCH 052/112] Uploading Katie's additions --- .DS_Store | Bin 6148 -> 12292 bytes DESCRIPTION | 3 +++ NAMESPACE | 3 +++ R/pois.int.R | 26 ++++++++++++++++++++++++++ R/pois.proc.R | 38 ++++++++++++++++++++++---------------- R/pois.rate.R | 27 +++++++++++++++++++++++++++ man/pois.int.Rd | 27 +++++++++++++++++++++++++++ man/pois.proc.Rd | 15 ++++++++------- man/pois.rate.Rd | 27 +++++++++++++++++++++++++++ 9 files changed, 143 insertions(+), 23 deletions(-) create mode 100644 R/pois.int.R create mode 100644 R/pois.rate.R create mode 100644 man/pois.int.Rd create mode 100644 man/pois.rate.Rd diff --git a/.DS_Store b/.DS_Store index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..39ee1b846ae891bc78e6687ebdcc34f9e4f3c7d5 100644 GIT binary patch literal 12292 zcmeHMU2GIZ9G~B{lwH}S+d{FWK#tZF2nSx#Qj0{cUqGQq(_Xz6iuLYxp)1?n=Ju{d zO0^m_YK)o~qrRx|JH~{V$b%a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P5w! nif{u7S0Gm1SoocJGQW%>BjaRK8EqaWh$$e088*lB%wYxq@cRyb diff --git a/DESCRIPTION b/DESCRIPTION index 33a67a5..af79d88 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,3 +31,6 @@ Collate: 'Bootstrap.R' 'polar.norm.R' 'jackknife.R' + 'pois.int.R' + 'pois.rate.R' + 'rand.weib.R' diff --git a/NAMESPACE b/NAMESPACE index dc2be1c..1387c26 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -11,12 +11,15 @@ export(nearest) export(nearest.loc) export(newton.raph) export(plot.mc) +export(pois.int) export(pois.proc) +export(pois.rate) export(polar.norm) export(rand.exp) export(rand.mvnorm) export(rand.norm) export(rand.unif) +export(rand.weib) export(tpower) export(update.CompPack) export(wich.hill) diff --git a/R/pois.int.R b/R/pois.int.R new file mode 100644 index 0000000..17c9385 --- /dev/null +++ b/R/pois.int.R @@ -0,0 +1,26 @@ +#' pois.int +#' +#' @description Averages the length of the interval containing a specified time +#' +#' @param time is the total time. +#' @param r is the average number of events per unit in time +#' @param n is the number of simulations required +#' @param a is the time the estimated interval contains +#' +#' @author Katie Dodds \email{k.dodds@@utah.edu} +#' +#' @examples +#' +#' pois.int(100,5,1000,100) +#' +#' @export +pois.int<- +function(time,r,n=1000,a){ + z=0 + for(i in 1:n){ + x=pois.proc(time,r) + y=min(x[x>a])-max(x[x Date: Tue, 30 Apr 2013 17:52:40 -0600 Subject: [PATCH 053/112] Added in random weibull --- R/rand.weib.R | 2 +- man/rand.weib.Rd | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 man/rand.weib.Rd diff --git a/R/rand.weib.R b/R/rand.weib.R index 94a5c68..1d34be1 100644 --- a/R/rand.weib.R +++ b/R/rand.weib.R @@ -11,4 +11,4 @@ rand.weib<-function(n, beta, theta){ x<-rand.unif(n, 0, 1) theta*(log(1/x)^(1/beta)) -} \ No newline at end of file +} diff --git a/man/rand.weib.Rd b/man/rand.weib.Rd new file mode 100644 index 0000000..ac1b998 --- /dev/null +++ b/man/rand.weib.Rd @@ -0,0 +1,20 @@ +\name{rand.weib} +\alias{rand.weib} +\title{Generate Random Weibull Variables} +\usage{ + rand.weib(n, beta, theta) +} +\arguments{ + \item{n}{the number of observations} + + \item{beta}{the specification of beta} + + \item{theta}{the specification of theta} +} +\description{ + Generate Random Weibull Variables +} +\author{ + Tyler Hunt \email{tyler@psychoanalytix.com} +} + From 70931c435c415743f16292e523b57b88d837d6e6 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 18:17:29 -0600 Subject: [PATCH 054/112] Fixed documentation issues --- .DS_Store | Bin 12292 -> 15364 bytes DESCRIPTION | 3 --- R/anneal.R | 4 ++-- R/log.lik.R | 7 ++++--- R/mixlike.R | 4 ++-- R/newton.raph.R | 2 +- R/pois.proc.R | 17 +---------------- R/twodranduphill.R | 4 ++-- R/uphill.mixnorm.R | 2 +- man/em.mixnorm.Rd | 11 ++++++++++- man/gold.sect.Rd | 5 ++++- man/grid.sect.Rd | 11 +++++++---- man/maxbound.Rd | 9 +++++---- man/mc.Rd | 9 ++++++--- man/mixnorm.Rd | 10 +++++----- man/newton.raph.Rd | 16 +++++++++++++--- man/rand.exp.Rd | 3 ++- man/rand.mvnorm.Rd | 10 +++++----- man/rand.norm.Rd | 9 +++++---- man/rand.unif.Rd | 3 ++- 20 files changed, 77 insertions(+), 62 deletions(-) diff --git a/.DS_Store b/.DS_Store index 39ee1b846ae891bc78e6687ebdcc34f9e4f3c7d5..779ea133d00cf0c92d37769b3a91116c69b5489b 100644 GIT binary patch literal 15364 zcmeHMU2GIp6u#%Szzm&%TP(`bZCP5B3Z=A#Qb2yT?Lzq}uyk9xrG+xPJJ6BoPP4OZ z(OPXVMt#7j4~91r<6rav|ItS!Dv3TAT``zwj1fsp3_eJJ2czfC%r-b%-b{mfZ!-7X zx#yg@_kMG}J2`g%huM0Z-lwnU!y3%zg;JOp=Mg}iK0cUjd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RIPTION +++ b/DESCRIPTION @@ -31,11 +31,9 @@ Collate: 'Bootstrap.R' 'polar.norm.R' 'jackknife.R' -<<<<<<< HEAD 'pois.int.R' 'pois.rate.R' 'rand.weib.R' -======= 'd1f.R' 'd2f.R' 'log.lik.R' @@ -43,4 +41,3 @@ Collate: 'uphill.mixnorm.R' 'twodranduphill.R' 'mixlike.R' ->>>>>>> 72ae3e5c0dc4c43e0c46577ad8f2a4f1363a0657 diff --git a/R/anneal.R b/R/anneal.R index d69197e..a726bbe 100644 --- a/R/anneal.R +++ b/R/anneal.R @@ -10,8 +10,8 @@ #' @param tt temperature #' @param g rate of temperature #' -#' @example -#' anneal(rnorm(1000,5,1), -20, 100, 1, 10, .99) +#' @examples +#' #anneal(, -20, 100, 1, 10, .99) #' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export diff --git a/R/log.lik.R b/R/log.lik.R index 3040075..009569a 100644 --- a/R/log.lik.R +++ b/R/log.lik.R @@ -1,7 +1,7 @@ -#' Find the logliklihood of a normal distribution +#' Find the log likelihood of a normal distribution #' #' @description -#' Find the logliklihood of a normal distribution. +#' Find the log likelihood of a normal distribution. #' #' @param x data. #' @param mu estimated mean. @@ -19,7 +19,8 @@ log.lik<-function(x=data, mu, var) { - ll = -n/2* log(2*pi*var) - .5/var*sum((mu-y)^2) + n=length(x) + ll = -n/2* log(2*pi*var) - .5/var*sum((mu-x)^2) -ll } diff --git a/R/mixlike.R b/R/mixlike.R index e2cd6e8..ecf6e31 100644 --- a/R/mixlike.R +++ b/R/mixlike.R @@ -8,10 +8,10 @@ #' @param m is the vector if means #' @param s is the vector of standard deviation #' -#' @example +#' @examples #' mixlike(mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)), c(.5,.5), c(-5,5), c(1,1)) #' -#' @author Ernest Chan \email(faiernest418@@gmail.com) +#' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export diff --git a/R/newton.raph.R b/R/newton.raph.R index ec10b5b..4af0407 100644 --- a/R/newton.raph.R +++ b/R/newton.raph.R @@ -4,7 +4,7 @@ #' A method for obtaining successively better approximations for the optimal value of a function. Named after Sir Isaac Newton and Joseph Raphson. #' #' @param f The function that you want to optimize. -#' @param df the 1st derivative of the function. +#' @param d1f the 1st derivative of the function. #' @param d2f the 2nd derivative of the function. #' @param start The starting value for optimization. #' @param tol The level of tolerance desired for convergence. diff --git a/R/pois.proc.R b/R/pois.proc.R index 9318b84..29cb9ab 100644 --- a/R/pois.proc.R +++ b/R/pois.proc.R @@ -1,4 +1,3 @@ -<<<<<<< HEAD #' pois.proc #' #' @description Simulates a Poisson process of specified length and rate. The output is the time at which each event occured. @@ -12,22 +11,8 @@ #' #' pois.proc(100,5) #' -======= -#' Generate a Poisson Process -#' -#' @description -#' Generates a Poisson Process. -#' -#' @param end the end time desired. -#' @param rate the rate of occurrence. -#' -#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} -#' -#' @results cumsum the cumulative sum of the vector of a poisson process. -#' -#' @examples pois.proc(200, 1) ->>>>>>> 72ae3e5c0dc4c43e0c46577ad8f2a4f1363a0657 #' @export + pois.proc= function(time,r){ t=0 diff --git a/R/twodranduphill.R b/R/twodranduphill.R index 5e0638c..5c96eac 100644 --- a/R/twodranduphill.R +++ b/R/twodranduphill.R @@ -10,8 +10,8 @@ #' @param s standard devation for each search jump, default at 1 #' @param t is the tempearture, where its default at 100 #' -#' @example -#' twodranduphill(matrix(c(1,2,3,4,5,6,7,8,9,10,.1,.2,5,3,7,6), ncol = 4), 1, .4, 1, 100, 10) +#' @examples +#' #twodranduphill(matrix(c(1,2,3,4,5,6,7,8,9,10,.1,.2,5,3,7,6), ncol = 4), 1, .4, 1, 100, 10) #' #' @author Ernest Chan \email{faiernest418@@gmail.com} #' diff --git a/R/uphill.mixnorm.R b/R/uphill.mixnorm.R index 56c7ffe..b93e972 100644 --- a/R/uphill.mixnorm.R +++ b/R/uphill.mixnorm.R @@ -7,7 +7,7 @@ #' @param n is the number of iteration #' @param t is the temperature #' -#' @example +#' @examples #' uphill.mixnorm(mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)), 4, 1000, 10) #' #' @author Ernest Chan \email{faiernest418@@gmail.com} diff --git a/man/em.mixnorm.Rd b/man/em.mixnorm.Rd index 96d2c84..8ce17c1 100644 --- a/man/em.mixnorm.Rd +++ b/man/em.mixnorm.Rd @@ -21,7 +21,16 @@ probs estimated probabilities of each mixture. } \description{ - EM-Algorithm for Normal Distribution + The Expectation-Maximization (EM) algorithm is and + itterative method for locating the maximum estimate for + the parameters of a mixture of normal distributions. The + EM iteration alternates between performing an expectation + (E) step, which creates a function for the expectation of + the log-likelihood evaluated using the current estimate + for the parameters, and a maximization (M) step, which + computes parameters maximizing the expected + log-likelihood found on the E step. These + parameter-estimates } \examples{ x=mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)) diff --git a/man/gold.sect.Rd b/man/gold.sect.Rd index d7d9507..d2335bd 100644 --- a/man/gold.sect.Rd +++ b/man/gold.sect.Rd @@ -19,7 +19,10 @@ f(a) function value at the optimal value } \description{ - Golden Section Search Optimization + A method used for locating the optimum value of a + function. The technique utilizes the golden ratio to + successively narrow the range of values for which the + optimum is found. } \examples{ gold.sect(sin, 1/2, pi/2) diff --git a/man/grid.sect.Rd b/man/grid.sect.Rd index 6eefb5b..4e6a2db 100644 --- a/man/grid.sect.Rd +++ b/man/grid.sect.Rd @@ -5,13 +5,16 @@ grid.sect(f, lo, hi) } \arguments{ - \item{f}{the function to be optimized} + \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{ - Grid Section Search Optimization + A method used to locate the optimum value of a function. +} +\author{ + Tyler Hunt \email{tyler@psychoanalytix.com} } diff --git a/man/maxbound.Rd b/man/maxbound.Rd index fcbbcfc..13be3d8 100644 --- a/man/maxbound.Rd +++ b/man/maxbound.Rd @@ -5,19 +5,20 @@ maxbound(f, lo, hi) } \arguments{ - \item{f}{the function to be optimized} + \item{f}{the function to be optimized.} \item{lo}{the lower bound.} \item{hi}{the upper bound.} } \value{ - lo lower bound estimate of the function's optimum + lo lower bound estimate of the function's optimum. - hi upper bound estimate of the function's optimum + hi upper bound estimate of the function's optimum. } \description{ - Maxbound Optimization + Used to estimate the bounds of a function, in which the + optimum value will be located within. } \examples{ maxbound(sin, 1/2, pi/2) diff --git a/man/mc.Rd b/man/mc.Rd index 1042f0e..b2a6582 100644 --- a/man/mc.Rd +++ b/man/mc.Rd @@ -5,12 +5,15 @@ mc(p, n) } \arguments{ - \item{p}{Probability matrix} + \item{p}{Probability matrix.} - \item{n}{Number of observations} + \item{n}{Number of observations.} +} +\value{ + x values of observations. } \description{ - Generate Markov Chains + Generates a Markov Chain. } \examples{ A<-matrix(c(.9,.8,0,0,.1,.2,0,0,0,0,.5,.6,0,0,.5,.4), nrow=4) diff --git a/man/mixnorm.Rd b/man/mixnorm.Rd index 9050f10..a2cdee4 100644 --- a/man/mixnorm.Rd +++ b/man/mixnorm.Rd @@ -6,16 +6,16 @@ } \arguments{ \item{n}{number of observations. If \eqn{length(n) > 1}, - the length is taken to be the number required} + the length is taken to be the number required.} - \item{p}{vector of probabilities} + \item{p}{vector of probabilities.} - \item{mu}{vector of means} + \item{mu}{vector of means.} - \item{sd}{vector of standard deviations} + \item{sd}{vector of standard deviations.} } \description{ - Create a Mixture of Normal Distributions + Creates a mixture of normal distributions. } \examples{ x = mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)) diff --git a/man/newton.raph.Rd b/man/newton.raph.Rd index 53667f8..2b9a564 100644 --- a/man/newton.raph.Rd +++ b/man/newton.raph.Rd @@ -2,12 +2,12 @@ \alias{newton.raph} \title{Newton Raphson Alogorithm} \usage{ - newton.raph(f, df, d2f, start, tol = 1e-06) + newton.raph(f, d1f, d2f, start, tol = 1e-06) } \arguments{ \item{f}{The function that you want to optimize.} - \item{df}{the 1st derivative of the function.} + \item{d1f}{the 1st derivative of the function.} \item{d2f}{the 2nd derivative of the function.} @@ -16,8 +16,18 @@ \item{tol}{The level of tolerance desired for convergence.} } +\value{ + Estimate Initial estimate of the optimum value. + + Iterations Number of cycles used to obtain the optimum + value of the function. + + Liklihood Optimum value +} \description{ - Newton Raphson Alogorithm + A method for obtaining successively better approximations + for the optimal value of a function. Named after Sir + Isaac Newton and Joseph Raphson. } \author{ Tyler Hunt \email{tyler@psychoanalytix.com} diff --git a/man/rand.exp.Rd b/man/rand.exp.Rd index f357d6e..fa5f2ad 100644 --- a/man/rand.exp.Rd +++ b/man/rand.exp.Rd @@ -10,7 +10,8 @@ \item{rate}{vector of rates} } \description{ - Generate Random Exponential Variables + Generates a pseudo-random exponential variable using the + Whichman-Hill pseudo-random number generator function } \author{ Tyler Hunt \email{tyler@psychoanalytix.com} diff --git a/man/rand.mvnorm.Rd b/man/rand.mvnorm.Rd index 3b970d0..b6af3fd 100644 --- a/man/rand.mvnorm.Rd +++ b/man/rand.mvnorm.Rd @@ -5,15 +5,15 @@ rand.mvnorm(n, mu, sigma) } \arguments{ - \item{n}{the number of observations} + \item{n}{the number of observations.} - \item{mu}{a vector of means} + \item{mu}{a vector of means.} - \item{sigma}{a variance-covariance matrix} + \item{sigma}{a variance-covariance matrix.} } \description{ - A method for generating random multivariate normal data - that is based on a cholesky decomposition. + A method for generating a pseudo-random multivariate + normal data that is based on a cholesky decomposition. } \examples{ sigma=matrix(rep(.5, 9), nrow=3) diff --git a/man/rand.norm.Rd b/man/rand.norm.Rd index 7f18957..e001b8c 100644 --- a/man/rand.norm.Rd +++ b/man/rand.norm.Rd @@ -5,14 +5,15 @@ rand.norm(n, mean, sd) } \arguments{ - \item{n}{Number of observations} + \item{n}{Number of observations.} - \item{mean}{vector of means} + \item{mean}{vector of means.} - \item{sd}{vector of standard deviations} + \item{sd}{vector of standard deviations.} } \description{ - Generate Random Normal Variables + Generates pseudo random variables from a normal + distribution using the Wichmannhill. } \author{ Tyler Hunt \email{tyler@psychoanalytix.com} diff --git a/man/rand.unif.Rd b/man/rand.unif.Rd index 0ce8d3d..f01d2d5 100644 --- a/man/rand.unif.Rd +++ b/man/rand.unif.Rd @@ -12,7 +12,8 @@ \item{max}{upper limit of the distribution.} } \description{ - Generate Random Uniform Variables + Generates pseudo-random variables from a Uniform + distribution, using the Wichmannhill. } \author{ Tyler Hunt \email{tyler@psychoanalytix.com} From 1a764ecceb354ce1338a0f06b4cd39a3de0f20fa Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 18:17:53 -0600 Subject: [PATCH 055/112] accepting Damon's additions --- man/anneal.Rd | 30 ++++++++++++++++++++++++++++++ man/d1f.Rd | 33 +++++++++++++++++++++++++++++++++ man/df.Rd | 30 ++++++++++++++++++++++++++++++ man/log.lik.Rd | 28 ++++++++++++++++++++++++++++ man/mixlike.Rd | 27 +++++++++++++++++++++++++++ man/twodranduphill.Rd | 31 +++++++++++++++++++++++++++++++ man/uphill.mixnorm.Rd | 26 ++++++++++++++++++++++++++ 7 files changed, 205 insertions(+) create mode 100644 man/anneal.Rd create mode 100644 man/d1f.Rd create mode 100644 man/df.Rd create mode 100644 man/log.lik.Rd create mode 100644 man/mixlike.Rd create mode 100644 man/twodranduphill.Rd create mode 100644 man/uphill.mixnorm.Rd diff --git a/man/anneal.Rd b/man/anneal.Rd new file mode 100644 index 0000000..0d54e1f --- /dev/null +++ b/man/anneal.Rd @@ -0,0 +1,30 @@ +\name{anneal} +\alias{anneal} +\title{anneal} +\usage{ + anneal(f, mu, n = 1000, sig = 1, tt = 10, g = 0.999) +} +\arguments{ + \item{f}{function vector to find the maximum} + + \item{mu}{starting point} + + \item{n}{number of iterations} + + \item{sig}{size of steps} + + \item{tt}{temperature} + + \item{g}{rate of temperature} +} +\description{ + General anneal function, where we conduct a uphill search + on the function to find maximum +} +\examples{ +#anneal(, -20, 100, 1, 10, .99) +} +\author{ + Ernest Chan \email{faiernest418@gmail.com} +} + diff --git a/man/d1f.Rd b/man/d1f.Rd new file mode 100644 index 0000000..2743309 --- /dev/null +++ b/man/d1f.Rd @@ -0,0 +1,33 @@ +\name{d1f} +\alias{d1f} +\title{First Derivative} +\usage{ + d1f(f, x) +} +\arguments{ + \item{f}{The function that you want to take the + derivative of} + + \item{x}{The point or vector of points where the + derivative will be evaluated} +} +\description{ + The first derivative of a function evaluated at point(s) + x. + + Differentiation is a method to compute the rate at which + the dependent output (f(x)) changes with respect to the + change the independent input (x). The first derrivative + can be used to obtain an exact value for the slope of the + tangent line, at the point where the derivative was + evaluated. +} +\examples{ +x = runif(10, pi/3, 3*pi/4) +df(tan, x) +} +\author{ + Damon McCafferty + \email{damon.mccafferty@economics.utah.edu} +} + diff --git a/man/df.Rd b/man/df.Rd new file mode 100644 index 0000000..a7dad7f --- /dev/null +++ b/man/df.Rd @@ -0,0 +1,30 @@ +\name{df} +\alias{df} +\title{Second Derivative} +\usage{ + df(f, x) +} +\arguments{ + \item{f}{The function that you want to take the + derivative of} + + \item{x}{The point or vector of points where the + derivative will be evaluated} +} +\description{ + The Second derivative of a function evaluated at point(s) + x. + + Roughly spoken, the seond derivative is the derivative of + a derivative. This can be used to measure how the rate of + change of a quantitty is itself changing. +} +\examples{ +x = runif(10, pi/3, 3*pi/4) +df(tan, x) +} +\author{ + Damon McCafferty + \email{damon.mccafferty@economics.utah.edu} +} + diff --git a/man/log.lik.Rd b/man/log.lik.Rd new file mode 100644 index 0000000..bb4d854 --- /dev/null +++ b/man/log.lik.Rd @@ -0,0 +1,28 @@ +\name{log.lik} +\alias{log.lik} +\title{Find the log likelihood of a normal distribution} +\usage{ + log.lik(x = data, mu, var) +} +\arguments{ + \item{x}{data.} + + \item{mu}{estimated mean.} + + \item{var}{estimated variance.} +} +\value{ + -ll logliklihood of the distribution +} +\description{ + Find the logliklihood of a normal distribution. +} +\examples{ +x = rnorm(100, 3, 7) +log.lik(x,3,7) +} +\author{ + Damon McCafferty + \email{damon.mccafferty@economics.utah.edu} +} + diff --git a/man/mixlike.Rd b/man/mixlike.Rd new file mode 100644 index 0000000..327eb53 --- /dev/null +++ b/man/mixlike.Rd @@ -0,0 +1,27 @@ +\name{mixlike} +\alias{mixlike} +\title{mixlike} +\usage{ + mixlike(x, p, m, s) +} +\arguments{ + \item{x}{is the mixture function to be evaluated} + + \item{p}{is the vector of probabilities} + + \item{m}{is the vector if means} + + \item{s}{is the vector of standard deviation} +} +\description{ + A supplement fucntion for uphill.mixnorm, this use to + compute the log likelihood funciotn for the mixture of + normal distribution +} +\examples{ +mixlike(mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)), c(.5,.5), c(-5,5), c(1,1)) +} +\author{ + Ernest Chan \email{faiernest418@gmail.com} +} + diff --git a/man/twodranduphill.Rd b/man/twodranduphill.Rd new file mode 100644 index 0000000..77766e4 --- /dev/null +++ b/man/twodranduphill.Rd @@ -0,0 +1,31 @@ +\name{twodranduphill} +\alias{twodranduphill} +\title{twodranduphill} +\usage{ + twodranduphill(f, x, y, s, n = 100, t = 100) +} +\arguments{ + \item{f}{matrix of data set} + + \item{y}{is the starting point for the search} + + \item{x}{is the starting point for the search} + + \item{n}{is the number of iteration for the search} + + \item{s}{standard devation for each search jump, default + at 1} + + \item{t}{is the tempearture, where its default at 100} +} +\description{ + This function is use to do a random uphill search on any + 2 demision data set +} +\examples{ +#twodranduphill(matrix(c(1,2,3,4,5,6,7,8,9,10,.1,.2,5,3,7,6), ncol = 4), 1, .4, 1, 100, 10) +} +\author{ + Ernest Chan \email{faiernest418@gmail.com} +} + diff --git a/man/uphill.mixnorm.Rd b/man/uphill.mixnorm.Rd new file mode 100644 index 0000000..4a077fa --- /dev/null +++ b/man/uphill.mixnorm.Rd @@ -0,0 +1,26 @@ +\name{uphill.mixnorm} +\alias{uphill.mixnorm} +\title{uphill.mixnorm} +\usage{ + uphill.mixnorm(x, k, n = 1000, t = 100) +} +\arguments{ + \item{x}{is the function of the mixture} + + \item{k}{is the number of mixture} + + \item{n}{is the number of iteration} + + \item{t}{is the temperature} +} +\description{ + This function is use for conducting a uphill search on + the mixture of normal distribution +} +\examples{ +uphill.mixnorm(mixnorm(100, c(.50, .15, .35), c(-3, 0, 3), c(3,3,3)), 4, 1000, 10) +} +\author{ + Ernest Chan \email{faiernest418@gmail.com} +} + From 45d47166ea7b877ea16fda851f44377b883c01cc Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 18:19:48 -0600 Subject: [PATCH 056/112] updated documentation --- R/log.lik.R | 2 +- man/log.lik.Rd | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/log.lik.R b/R/log.lik.R index 009569a..f9018f4 100644 --- a/R/log.lik.R +++ b/R/log.lik.R @@ -9,7 +9,7 @@ #' #' @author Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} #' -#' @return -ll logliklihood of the distribution +#' @return ll logliklihood of the distribution #' #' @examples #' x = rnorm(100, 3, 7) diff --git a/man/log.lik.Rd b/man/log.lik.Rd index bb4d854..26889ac 100644 --- a/man/log.lik.Rd +++ b/man/log.lik.Rd @@ -12,10 +12,10 @@ \item{var}{estimated variance.} } \value{ - -ll logliklihood of the distribution + ll logliklihood of the distribution } \description{ - Find the logliklihood of a normal distribution. + Find the log likelihood of a normal distribution. } \examples{ x = rnorm(100, 3, 7) From 07f2c7286ae8bcd5142ab6e28216f197b28044c7 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 18:23:33 -0600 Subject: [PATCH 057/112] added Katie's f.models function --- .DS_Store | Bin 15364 -> 15364 bytes DESCRIPTION | 1 + NAMESPACE | 1 + R/f.models.R | 41 +++++++++++++++++++++++++++++++++++++++++ man/f.models.Rd | 23 +++++++++++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 R/f.models.R create mode 100644 man/f.models.Rd diff --git a/.DS_Store b/.DS_Store index 779ea133d00cf0c92d37769b3a91116c69b5489b..5c903c67da4d458af80ad0f0550ed979b780fed8 100644 GIT binary patch delta 1208 zcmd^+O-K}B7{~oTYR=${ysMiz&S?1o>iU_VS-EPunIF~qm5L&)&Xkk7E6!pT#2%8O zLlA96x1cDxl`K*niz1H_Lx-p+iaJH72qLI=Pr=NsYnS)(|G&?}^ZTu>uB|?>JgE)! zt%()S5MoTpSG59J8a-v|(Yc9`HEV=*Gkjuf#k96hDyCAdqJfL>Q#*B19}OoC T=A~u*-wK-kNkQUQnc)2cdcIS{ delta 1221 zcmeH`OH30%9LDqg0o{dNGS!MKY>PY$2nZtb5JieS8lfN*h#-Wdva77X*07DDiRnR% zdeA6Mj5ibG>n7M3-&xvT4;12V2$Xe zW|#*AVKBxuP3nB)SYZ*9isjOHOk@F}*D{Xjwo+Ekqzb7rk+8(xF~j6*RE4XVTr1VZ zBLdUJzVX05ecV>I*E6|6YD`4h#XX1hNy`YDw$jwhT*kRAHP?9DzdOD zld+W!l!}6#mtUYrZYk}zZ_!qYHmJoViQO3Sw;FPgmEdwOjc{ zanFOLaA!PSze8>CNQvoWW{IM`S7~lhTfNJ~SFrY2yxpgEbS`tYm?S>!?@@b8mN^>) z@vn~Z$lThDa1qK-3lDZKitwTf{TRk53><`oqg=#EoWg0G!3-|p3a;WhZr~>7a2F5o z2#@guPqDydyv7^6#XG#mCw#_F0wqy0rBFIKxsr91NBLAh8>y0uX&?_ZQXBO|TQif> U|10_PLl%`({gaaDk3zxu3vTXMk^lez diff --git a/DESCRIPTION b/DESCRIPTION index 256a069..9dfd8a7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -41,3 +41,4 @@ Collate: 'uphill.mixnorm.R' 'twodranduphill.R' 'mixlike.R' + 'f.models.R' diff --git a/NAMESPACE b/NAMESPACE index 6c04909..a0d7785 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -4,6 +4,7 @@ export(around) export(d1f) export(df) export(em.mixnorm) +export(f.models) export(gold.sect) export(grid.sect) export(jackknife) diff --git a/R/f.models.R b/R/f.models.R new file mode 100644 index 0000000..ae3e6a6 --- /dev/null +++ b/R/f.models.R @@ -0,0 +1,41 @@ +#' f models +#' +#' @description Plots linear, quadratic, cubic and 4th degree models for a 2D dataset. +#' +#' @param x is the independent variable +#' @param y is the dependent variable +#' +#' @author Katie Dodds \email{k.dodds@@utah.edu} +#' +#' @examples +#' attach(mtcars) +#' f.models(wt,mpg) +#' +#' @export + +f.models<- +function (x,y) +{ + par(mfrow=c(2,2)) + plot(x,y) + abline(lsfit(x,y),col=2) + + plot(x,y) + z=x*x + xx=seq(min(x)-10,max(x)+10,.1) + param=glm(y~x+z)$coeff + yy=param[1]+xx*param[2]+xx^2*param[3] + lines(xx,yy,col=3) + + plot(x,y) + w=x*x*x + param=glm(y~x+z+w)$coeff + yy=param[1]+xx*param[2]+xx^2*param[3]+xx^3*param[4] + lines(xx,yy,col=4) + + plot(x,y) + q=x*x*x*x + param=glm(y~x+z+w+q)$coeff + yy=param[1]+xx*param[2]+xx^2*param[3]+xx^3*param[4]+xx^4*param[5] + lines(xx,yy,col=5) +} diff --git a/man/f.models.Rd b/man/f.models.Rd new file mode 100644 index 0000000..6587d57 --- /dev/null +++ b/man/f.models.Rd @@ -0,0 +1,23 @@ +\name{f.models} +\alias{f.models} +\title{f models} +\usage{ + f.models(x, y) +} +\arguments{ + \item{x}{is the independent variable} + + \item{y}{is the dependent variable} +} +\description{ + Plots linear, quadratic, cubic and 4th degree models for + a 2D dataset. +} +\examples{ +attach(mtcars) +f.models(wt,mpg) +} +\author{ + Katie Dodds \email{k.dodds@utah.edu} +} + From c52b328d245a4df5410936a92d75387bd6e9931b Mon Sep 17 00:00:00 2001 From: doddsie24 Date: Tue, 30 Apr 2013 18:25:09 -0600 Subject: [PATCH 058/112] Update pois.rate.R --- R/pois.rate.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/pois.rate.R b/R/pois.rate.R index 2a93fd9..565fd5c 100644 --- a/R/pois.rate.R +++ b/R/pois.rate.R @@ -1,4 +1,4 @@ -#' pois.rate +#' Average Time Between Events in a Poisson Process #' #' @description Averages the time between any two events in a Poisson procces #' From da18484ec248136943c9ee43265f8994eb4a616d Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 18:25:30 -0600 Subject: [PATCH 059/112] Added Katie's cross validation score function --- DESCRIPTION | 1 + NAMESPACE | 1 + R/cvscore.R | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++ man/cvscore.Rd | 26 ++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 R/cvscore.R create mode 100644 man/cvscore.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 9dfd8a7..f22a5fc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,3 +42,4 @@ Collate: 'twodranduphill.R' 'mixlike.R' 'f.models.R' + 'cvscore.R' diff --git a/NAMESPACE b/NAMESPACE index a0d7785..6083711 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,7 @@ export(Bootstrap) export(anneal) export(around) +export(cvscore) export(d1f) export(df) export(em.mixnorm) diff --git a/R/cvscore.R b/R/cvscore.R new file mode 100644 index 0000000..e0767fd --- /dev/null +++ b/R/cvscore.R @@ -0,0 +1,96 @@ +#' cvscore +#' +#' @description Uses cross-validation to score how accurately a a linear, quadratic, cubic, and 4th and 5th degree polynomial models will perform when used in prediction. +#' +#' @param x is the independent variable +#' @param y is the dependent variable +#' +#' @author Katie Dodds \email{k.dodds@@utah.edu} +#' +#' @examples +#' attach(mtcars) +#' x=wt +#' y=mpg +#' cvscore(x,y) +#' +#' @export +cvscore<- +function(x,y){ +{ + n=length(x) + yhat=rep(0,n) + + for (i in 1:n) + { + yi=y[-i] + xi=x[-i] + zi=xi*yi + param=glm(yi~xi)$coeff + yhat[i]=param[1]+x[i]*param[2] + } + linear=sum((yhat-y)^2) +} +{ + n=length(x) + yhat=rep(0,n) + + for (i in 1:n) + { + yi=y[-i] + xi=x[-i] + zi=xi*yi + param=glm(yi~xi+zi)$coeff + yhat[i]=param[1]+x[i]*param[2]+x[i]^2*param[3] + } + quadratic=sum((yhat-y)^2) +} +{ + n=length(x) + yhat=rep(0,n) + + for (i in 1:n) + { + yi=y[-i] + xi=x[-i] + zi=xi*xi + wi=xi*xi*xi + param=glm(yi~xi+zi+wi)$coeff + yhat[i]=param[1]+x[i]*param[2]+x[i]^2*param[3] +x[i]^3*param[4] + } + cubic=sum((yhat-y)^2) +} +{ + n=length(x) + yhat=rep(0,n) + + for (i in 1:n) + { + yi=y[-i] + xi=x[-i] + zi=xi*xi + wi=xi*xi*xi + vi=xi*xi*xi*xi + param=glm(yi~xi+zi+wi+vi)$coeff + yhat[i]=param[1]+x[i]*param[2]+x[i]^2*param[3] +x[i]^3*param[4] +x[i]^4*param[5] + } + fourth.degree=sum((yhat-y)^2) +} +{ + n=length(x) + yhat=rep(0,n) + + for (i in 1:n) + { + yi=y[-i] + xi=x[-i] + zi=xi*xi + wi=xi*xi*xi + vi=xi*xi*xi*xi + ui=xi^5 + param=glm(yi~xi+zi+wi+vi+ui)$coeff + yhat[i]=param[1]+x[i]*param[2]+x[i]^2*param[3] +x[i]^3*param[4] +x[i]^4*param[5]+x[i]^5*param[6] + } + fifth.degree=sum((yhat-y)^2) +} +list(linear=linear, quadratic=quadratic, cubic=cubic, fourth.degree, fifth.degree) +} diff --git a/man/cvscore.Rd b/man/cvscore.Rd new file mode 100644 index 0000000..70a4525 --- /dev/null +++ b/man/cvscore.Rd @@ -0,0 +1,26 @@ +\name{cvscore} +\alias{cvscore} +\title{cvscore} +\usage{ + cvscore(x, y) +} +\arguments{ + \item{x}{is the independent variable} + + \item{y}{is the dependent variable} +} +\description{ + Uses cross-validation to score how accurately a a linear, + quadratic, cubic, and 4th and 5th degree polynomial + models will perform when used in prediction. +} +\examples{ +attach(mtcars) +x=wt +y=mpg +cvscore(x,y) +} +\author{ + Katie Dodds \email{k.dodds@utah.edu} +} + From 78145193e38bac4d7cb7590a422381e6d8eb9970 Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 18:25:40 -0600 Subject: [PATCH 060/112] Update anneal.R --- R/anneal.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/anneal.R b/R/anneal.R index a726bbe..1be167f 100644 --- a/R/anneal.R +++ b/R/anneal.R @@ -3,7 +3,7 @@ #' @description #' General anneal function, where we conduct a uphill search on the function to find maximum #' -#' @param f function vector to find the maximum +#' @param f function to find the maximum #' @param mu starting point #' @param n number of iterations #' @param sig size of steps @@ -11,7 +11,7 @@ #' @param g rate of temperature #' #' @examples -#' #anneal(, -20, 100, 1, 10, .99) +#' anneal(sin, 0, 100, 1, 10, .99) #' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export From ec26c648698cd5208844718d37841a1309dd5dd5 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 18:43:55 -0600 Subject: [PATCH 061/112] renamed function --- R/polar.norm.R | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 R/polar.norm.R diff --git a/R/polar.norm.R b/R/polar.norm.R deleted file mode 100644 index 6150983..0000000 --- a/R/polar.norm.R +++ /dev/null @@ -1,27 +0,0 @@ -#' 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 -} From f7e8c4f0d96f951dfdb85bb257cf4dd841f0c0e5 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 18:44:40 -0600 Subject: [PATCH 062/112] added in katie's function --- .DS_Store | Bin 15364 -> 15364 bytes DESCRIPTION | 43 ++++++++++++++++++++++++------------------- NAMESPACE | 9 +++++++-- R/Bootstrap.R | 10 +++++----- R/anneal.R | 2 +- R/cvscore1.R | 34 ++++++++++++++++++++++++++++++++++ R/cvscore2.R | 33 +++++++++++++++++++++++++++++++++ R/cvscore3.R | 33 +++++++++++++++++++++++++++++++++ R/cvscore4.R | 35 +++++++++++++++++++++++++++++++++++ R/cvscore5.R | 36 ++++++++++++++++++++++++++++++++++++ R/polar.rnorm.R | 26 ++++++++++++++++++++++++++ man/Bootstrap.Rd | 12 ++++++------ man/anneal.Rd | 4 ++-- man/cvscore1.Rd | 26 ++++++++++++++++++++++++++ man/cvscore2.Rd | 26 ++++++++++++++++++++++++++ man/cvscore3.Rd | 26 ++++++++++++++++++++++++++ man/cvscore4.Rd | 27 +++++++++++++++++++++++++++ man/cvscore5.Rd | 27 +++++++++++++++++++++++++++ man/pois.rate.Rd | 2 +- man/polar.rnorm.Rd | 24 ++++++++++++++++++++++++ 20 files changed, 399 insertions(+), 36 deletions(-) create mode 100644 R/cvscore1.R create mode 100644 R/cvscore2.R create mode 100644 R/cvscore3.R create mode 100644 R/cvscore4.R create mode 100644 R/cvscore5.R create mode 100644 R/polar.rnorm.R create mode 100644 man/cvscore1.Rd create mode 100644 man/cvscore2.Rd create mode 100644 man/cvscore3.Rd create mode 100644 man/cvscore4.Rd create mode 100644 man/cvscore5.Rd create mode 100644 man/polar.rnorm.Rd diff --git a/.DS_Store b/.DS_Store index 5c903c67da4d458af80ad0f0550ed979b780fed8..1289488975da1a776e7a94ca38d02f0af4773a93 100644 GIT binary patch delta 1274 zcmeH{+e;K-7{+~GPcu4G-{xkH?s|?kHO(wF%XZDflE-yb(iCBHrrgxoaF?=g6MQtwnRh_R8(F{O+hyiQFbK;5tTRfZ3n_#FZu(Tiz2%d|2|*K^ON@;fiSfkfL749US%>D?D+o$@29vCERU#yDH_X+JYW&QxH8v&{$VHKu$UH))-+Ndy zl;RR5l}csNgkS6&^6LBWN#9gR$GmRlDwTf)KEw9p@p*6i^I+V*QYPsd#CirXs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TION b/DESCRIPTION index f22a5fc..bf71a4d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,37 +9,42 @@ Description: The functions in this package were developed in a computational statistics course taught at the University of Utah. License: MIT Collate: + 'anneal.R' + 'around.R' + 'bootstrap.R' + 'cvscore.R' + 'cvscore1.R' + 'cvscore2.R' + 'cvscore3.R' + 'cvscore4.R' + 'cvscore5.R' + 'd1f.R' + 'd2f.R' 'em.mixnorm.R' + 'f.models.R' 'gold.sect.R' 'grid.sect.R' + 'jackknife.R' + 'log.lik.R' 'maxbound.R' 'mc.R' + 'mixlike.R' 'mixnorm.R' + 'nearest.R' + 'nearest.loc.R' 'newton.raph.R' 'plot.mc.R' + 'pois.int.R' + 'pois.proc.R' + 'pois.rate.R' + 'polar.rnorm.R' 'rand.exp.R' 'rand.mvnorm.R' 'rand.norm.R' 'rand.unif.R' + 'rand.weib.R' 'tpower.R' + 'twodranduphill.R' 'update.CompPack.R' - 'wich.hill.R' - 'pois.proc.R' - 'nearest.R' - 'around.R' - 'nearest.loc.R' - 'Bootstrap.R' - 'polar.norm.R' - 'jackknife.R' - 'pois.int.R' - 'pois.rate.R' - 'rand.weib.R' - 'd1f.R' - 'd2f.R' - 'log.lik.R' - 'anneal.R' 'uphill.mixnorm.R' - 'twodranduphill.R' - 'mixlike.R' - 'f.models.R' - 'cvscore.R' + 'wich.hill.R' diff --git a/NAMESPACE b/NAMESPACE index 6083711..f0c9113 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,12 @@ -export(Bootstrap) export(anneal) export(around) +export(bootstrap) export(cvscore) +export(cvscore1) +export(cvscore2) +export(cvscore3) +export(cvscore4) +export(cvscore5) export(d1f) export(df) export(em.mixnorm) @@ -21,7 +26,7 @@ export(plot.mc) export(pois.int) export(pois.proc) export(pois.rate) -export(polar.norm) +export(polar.rnorm) export(rand.exp) export(rand.mvnorm) export(rand.norm) diff --git a/R/Bootstrap.R b/R/Bootstrap.R index 7fb7caf..555f2fb 100644 --- a/R/Bootstrap.R +++ b/R/Bootstrap.R @@ -1,24 +1,24 @@ -#' Bootstrap +#' 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 boots The number of bootstraps. #' @param fn the function you want to bootstrap, ie., mean, var, cov, etc. #' #' @author Tyler Hunt \email{tyler@@psychoanalytix.com} #' #' @examples #' x = runif(10, 0, 1) -#' Bootstrap(x,fn=mean) +#' bootstrap(x,fn=mean) #' #' @export -Bootstrap<-function(x, Boots=100, fn){ +bootstrap<-function(x, boots=100, fn){ n=length(x) - lings<-replicate(Boots, fn(sample(x,n, replace=TRUE))) + lings<-replicate(boots, fn(sample(x,n, replace=TRUE))) list(se=sd(lings), lings=lings) } diff --git a/R/anneal.R b/R/anneal.R index 1be167f..dcfe229 100644 --- a/R/anneal.R +++ b/R/anneal.R @@ -11,7 +11,7 @@ #' @param g rate of temperature #' #' @examples -#' anneal(sin, 0, 100, 1, 10, .99) +#' #anneal(sin, 0, 100, 1, 10, .99) #' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export diff --git a/R/cvscore1.R b/R/cvscore1.R new file mode 100644 index 0000000..99fc953 --- /dev/null +++ b/R/cvscore1.R @@ -0,0 +1,34 @@ +#' cvscore1 +#' +#' @description Uses cross-validation to score how accurately a linear model will perform when used in prediction. Score can be compared to that of cvscore2,...,cvscore5. +#' +#' @param x is the independent variable +#' @param y is the dependent variable +#' +#' @author Katie Dodds \email{k.dodds@@utah.edu} +#' +#' @examples +#' +#' attach(mtcars) +#' x=wt +#' y=mpg +#' cvscore1(x,y) +#' +#' @export + +cvscore1<- +function (x,y) +{ + n=length(x) + yhat=rep(0,n) + + for (i in 1:n) + { + yi=y[-i] + xi=x[-i] + zi=xi*yi + param=glm(yi~xi)$coeff + yhat[i]=param[1]+x[i]*param[2] + } + sum((yhat-y)^2) +} diff --git a/R/cvscore2.R b/R/cvscore2.R new file mode 100644 index 0000000..d949176 --- /dev/null +++ b/R/cvscore2.R @@ -0,0 +1,33 @@ +#' cvscore2 +#' +#' @description Uses cross-validation to score how accurately a quadratic model will perform when used in prediction. Score can be compared to that of cvscore1,...,cvscore5. +#' +#' @param x is the independent variable +#' @param y is the dependent variable +#' +#' @author Katie Dodds \email{k.dodds@@utah.edu} +#' +#' @examples +#' +#' attach(mtcars) +#' x=wt +#' y=mpg +#' cvscore2(x,y) +#' +#' @export +cvscore2<- +function (x,y) +{ + n=length(x) + yhat=rep(0,n) + + for (i in 1:n) + { + yi=y[-i] + xi=x[-i] + zi=xi*yi + param=glm(yi~xi+zi)$coeff + yhat[i]=param[1]+x[i]*param[2]+x[i]^2*param[3] + } + sum((yhat-y)^2) +} diff --git a/R/cvscore3.R b/R/cvscore3.R new file mode 100644 index 0000000..4c29ca8 --- /dev/null +++ b/R/cvscore3.R @@ -0,0 +1,33 @@ +#' cvscore3 +#' +#' @description Uses cross-validation to score how accurately a cubic model will perform when used in prediction. Score can be compared to that of cvscore1,...,cvscore5. +#' +#' @param x is the independent variable +#' @param y is the dependent variable +#' +#' @author Katie Dodds \email{k.dodds@@utah.edu} +#' +#' @examples +#' +#' attach(mtcars) +#' x=wt +#' y=mpg +#' cvscore3(x,y) +#' +#' @export +cvscore3<-function (x,y) +{ + n=length(x) + yhat=rep(0,n) + + for (i in 1:n) + { + yi=y[-i] + xi=x[-i] + zi=xi*xi + wi=xi*xi*xi + param=glm(yi~xi+zi+wi)$coeff + yhat[i]=param[1]+x[i]*param[2]+x[i]^2*param[3] +x[i]^3*param[4] + } + sum((yhat-y)^2) +} diff --git a/R/cvscore4.R b/R/cvscore4.R new file mode 100644 index 0000000..e321c28 --- /dev/null +++ b/R/cvscore4.R @@ -0,0 +1,35 @@ +#' cvscore4 +#' +#' @description Uses cross-validation to score how accurately a model using a 4th degree polynomial will perform when used in prediction. Score can be compared to that of cvscore1,...,cvscore5. +#' +#' @param x is the independent variable +#' @param y is the dependent variable +#' +#' @author Katie Dodds \email{k.dodds@@utah.edu} +#' +#' @examples +#' +#' attach(mtcars) +#' x=wt +#' y=mpg +#' cvscore4(x,y) +#' +#' @export +cvscore4<- +function (x,y) +{ + n=length(x) + yhat=rep(0,n) + + for (i in 1:n) + { + yi=y[-i] + xi=x[-i] + zi=xi*xi + wi=xi*xi*xi + vi=xi*xi*xi*xi + param=glm(yi~xi+zi+wi+vi)$coeff + yhat[i]=param[1]+x[i]*param[2]+x[i]^2*param[3] +x[i]^3*param[4] +x[i]^4*param[5] + } + sum((yhat-y)^2) +} \ No newline at end of file diff --git a/R/cvscore5.R b/R/cvscore5.R new file mode 100644 index 0000000..b46f6c8 --- /dev/null +++ b/R/cvscore5.R @@ -0,0 +1,36 @@ +#' cvscore5 +#' +#' @description Uses cross-validation to score how accurately a model using a 5th degree polynomial will perform when used in prediction. Score can be compared to that of cvscore1,...,cvscore4. +#' +#' @param x is the independent variable +#' @param y is the dependent variable +#' +#' @author Katie Dodds \email{k.dodds@@utah.edu} +#' +#' @examples +#' +#' attach(mtcars) +#' x=wt +#' y=mpg +#' cvscore5(x,y) +#' +#' @export +cvscore5<- +function (x,y) +{ + n=length(x) + yhat=rep(0,n) + + for (i in 1:n) + { + yi=y[-i] + xi=x[-i] + zi=xi*xi + wi=xi*xi*xi + vi=xi*xi*xi*xi + ui=xi^5 + param=glm(yi~xi+zi+wi+vi+ui)$coeff + yhat[i]=param[1]+x[i]*param[2]+x[i]^2*param[3] +x[i]^3*param[4] +x[i]^4*param[5]+x[i]^5*param[6] + } + sum((yhat-y)^2) +} diff --git a/R/polar.rnorm.R b/R/polar.rnorm.R new file mode 100644 index 0000000..cbcdb66 --- /dev/null +++ b/R/polar.rnorm.R @@ -0,0 +1,26 @@ +#' Polar Random Normal +#' +#' @description Generates a sample of standard normals +#' +#' @param n is the sample size +#' @param mu a vector of means +#' @param sd a vector of standard deviations +#' +#' @author +#' Katie Dodds \email{k.dodds@@utah.edu} +#' Damon McCafferty \email{damon.mccafferty@@economics.utah.edu} +#' +#' @examples +#' +#' polar.rnorm(1000) +#' +#' @export + +polar.rnorm<- +function (n=100, mu=0, sd=1) +{ + theta=2*pi*runif(n) + r=sqrt(-2*log(runif(n))) + + r*cos(theta)*sd+mu +} diff --git a/man/Bootstrap.Rd b/man/Bootstrap.Rd index c91ae7a..85d2796 100644 --- a/man/Bootstrap.Rd +++ b/man/Bootstrap.Rd @@ -1,13 +1,13 @@ -\name{Bootstrap} -\alias{Bootstrap} -\title{Bootstrap} +\name{bootstrap} +\alias{bootstrap} +\title{bootstrap} \usage{ - Bootstrap(x, Boots = 100, fn) + bootstrap(x, boots = 100, fn) } \arguments{ \item{x}{a vector.} - \item{Boots}{The number of bootstraps.} + \item{boots}{The number of bootstraps.} \item{fn}{the function you want to bootstrap, ie., mean, var, cov, etc.} @@ -18,7 +18,7 @@ } \examples{ x = runif(10, 0, 1) -Bootstrap(x,fn=mean) +bootstrap(x,fn=mean) } \author{ Tyler Hunt \email{tyler@psychoanalytix.com} diff --git a/man/anneal.Rd b/man/anneal.Rd index 0d54e1f..6b2c0da 100644 --- a/man/anneal.Rd +++ b/man/anneal.Rd @@ -5,7 +5,7 @@ anneal(f, mu, n = 1000, sig = 1, tt = 10, g = 0.999) } \arguments{ - \item{f}{function vector to find the maximum} + \item{f}{function to find the maximum} \item{mu}{starting point} @@ -22,7 +22,7 @@ on the function to find maximum } \examples{ -#anneal(, -20, 100, 1, 10, .99) +#anneal(sin, 0, 100, 1, 10, .99) } \author{ Ernest Chan \email{faiernest418@gmail.com} diff --git a/man/cvscore1.Rd b/man/cvscore1.Rd new file mode 100644 index 0000000..50ecbfd --- /dev/null +++ b/man/cvscore1.Rd @@ -0,0 +1,26 @@ +\name{cvscore1} +\alias{cvscore1} +\title{cvscore1} +\usage{ + cvscore1(x, y) +} +\arguments{ + \item{x}{is the independent variable} + + \item{y}{is the dependent variable} +} +\description{ + Uses cross-validation to score how accurately a linear + model will perform when used in prediction. Score can be + compared to that of cvscore2,...,cvscore5. +} +\examples{ +attach(mtcars) +x=wt +y=mpg +cvscore1(x,y) +} +\author{ + Katie Dodds \email{k.dodds@utah.edu} +} + diff --git a/man/cvscore2.Rd b/man/cvscore2.Rd new file mode 100644 index 0000000..9d5ac98 --- /dev/null +++ b/man/cvscore2.Rd @@ -0,0 +1,26 @@ +\name{cvscore2} +\alias{cvscore2} +\title{cvscore2} +\usage{ + cvscore2(x, y) +} +\arguments{ + \item{x}{is the independent variable} + + \item{y}{is the dependent variable} +} +\description{ + Uses cross-validation to score how accurately a quadratic + model will perform when used in prediction. Score can be + compared to that of cvscore1,...,cvscore5. +} +\examples{ +attach(mtcars) +x=wt +y=mpg +cvscore2(x,y) +} +\author{ + Katie Dodds \email{k.dodds@utah.edu} +} + diff --git a/man/cvscore3.Rd b/man/cvscore3.Rd new file mode 100644 index 0000000..ce2fb50 --- /dev/null +++ b/man/cvscore3.Rd @@ -0,0 +1,26 @@ +\name{cvscore3} +\alias{cvscore3} +\title{cvscore3} +\usage{ + cvscore3(x, y) +} +\arguments{ + \item{x}{is the independent variable} + + \item{y}{is the dependent variable} +} +\description{ + Uses cross-validation to score how accurately a cubic + model will perform when used in prediction. Score can be + compared to that of cvscore1,...,cvscore5. +} +\examples{ +attach(mtcars) +x=wt +y=mpg +cvscore3(x,y) +} +\author{ + Katie Dodds \email{k.dodds@utah.edu} +} + diff --git a/man/cvscore4.Rd b/man/cvscore4.Rd new file mode 100644 index 0000000..435706a --- /dev/null +++ b/man/cvscore4.Rd @@ -0,0 +1,27 @@ +\name{cvscore4} +\alias{cvscore4} +\title{cvscore4} +\usage{ + cvscore4(x, y) +} +\arguments{ + \item{x}{is the independent variable} + + \item{y}{is the dependent variable} +} +\description{ + Uses cross-validation to score how accurately a model + using a 4th degree polynomial will perform when used in + prediction. Score can be compared to that of + cvscore1,...,cvscore5. +} +\examples{ +attach(mtcars) +x=wt +y=mpg +cvscore4(x,y) +} +\author{ + Katie Dodds \email{k.dodds@utah.edu} +} + diff --git a/man/cvscore5.Rd b/man/cvscore5.Rd new file mode 100644 index 0000000..b181daf --- /dev/null +++ b/man/cvscore5.Rd @@ -0,0 +1,27 @@ +\name{cvscore5} +\alias{cvscore5} +\title{cvscore5} +\usage{ + cvscore5(x, y) +} +\arguments{ + \item{x}{is the independent variable} + + \item{y}{is the dependent variable} +} +\description{ + Uses cross-validation to score how accurately a model + using a 5th degree polynomial will perform when used in + prediction. Score can be compared to that of + cvscore1,...,cvscore4. +} +\examples{ +attach(mtcars) +x=wt +y=mpg +cvscore5(x,y) +} +\author{ + Katie Dodds \email{k.dodds@utah.edu} +} + diff --git a/man/pois.rate.Rd b/man/pois.rate.Rd index b39398a..ae54462 100644 --- a/man/pois.rate.Rd +++ b/man/pois.rate.Rd @@ -1,6 +1,6 @@ \name{pois.rate} \alias{pois.rate} -\title{pois.rate} +\title{Average Time Between Events in a Poisson Process} \usage{ pois.rate(time, r, n = 1000, a, b) } diff --git a/man/polar.rnorm.Rd b/man/polar.rnorm.Rd new file mode 100644 index 0000000..50f0428 --- /dev/null +++ b/man/polar.rnorm.Rd @@ -0,0 +1,24 @@ +\name{polar.rnorm} +\alias{polar.rnorm} +\title{Polar Random Normal} +\usage{ + polar.rnorm(n = 100, mu = 0, sd = 1) +} +\arguments{ + \item{n}{is the sample size} + + \item{mu}{a vector of means} + + \item{sd}{a vector of standard deviations} +} +\description{ + Generates a sample of standard normals +} +\examples{ +polar.rnorm(1000) +} +\author{ + Katie Dodds \email{k.dodds@utah.edu} Damon McCafferty + \email{damon.mccafferty@economics.utah.edu} +} + From 080b279a33425a1b3868687c85f8d471bad78857 Mon Sep 17 00:00:00 2001 From: dcaff Date: Tue, 30 Apr 2013 18:54:44 -0600 Subject: [PATCH 063/112] cispy's functions --- R/onedfunction.R | 20 ++++++++++++++++++++ R/twodfunction.R | 25 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 R/onedfunction.R create mode 100644 R/twodfunction.R diff --git a/R/onedfunction.R b/R/onedfunction.R new file mode 100644 index 0000000..d740591 --- /dev/null +++ b/R/onedfunction.R @@ -0,0 +1,20 @@ +#' onedfunction +#' +#' @description +#' function to generate x^4 + x^2 +#' +#' @param x vector of values +#' +#' @examples +#' onedfunction(1) +#' +#' @author Ernest Chan \email{faiernest418@@gmail.com} +#' +#' @export + +onedfunction = function(x) +{ + y = x^4 + x^2 + + y +} diff --git a/R/twodfunction.R b/R/twodfunction.R new file mode 100644 index 0000000..75a31a0 --- /dev/null +++ b/R/twodfunction.R @@ -0,0 +1,25 @@ +#' twodfunction +#' +#' @description +#' Generate cos(x) + cos(y) maxtrix +#' +#' @param x vector of value +#' @param y vector of value +#' +#' @examples +#' twodfunction(1,1) +#' +#' @author Ernest Chan \email{faiernest@@gmail.com} +#' +twodfunction = function(x,y) +{ + z = matrix(0, nrow=length(x), nocol=length(y)) + for(i in 1:length(y)) + { + for(j in 1: length(x)) + { + z[i,j] = cos(x[j]) + cos(y[i]) + } + } + z +} From 6ab6caa9b28344613a734fb2d06e8aa4c9063f86 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:07:08 -0600 Subject: [PATCH 064/112] Accepted Ernest's new functions/tweaked documentation --- .DS_Store | Bin 15364 -> 15364 bytes DESCRIPTION | 2 ++ NAMESPACE | 2 ++ R/twodfunction.R | 4 ++-- man/onedfunction.Rd | 19 +++++++++++++++++++ man/twodfunction.Rd | 21 +++++++++++++++++++++ 6 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 man/onedfunction.Rd create mode 100644 man/twodfunction.Rd diff --git a/.DS_Store b/.DS_Store index 1289488975da1a776e7a94ca38d02f0af4773a93..f455aa13710ed2c00c6184a4f24214e7284c1e7d 100644 GIT binary patch delta 218 zcmZpvXsMXs&&abeU^hP_&t@KhNlg6t>A}hQxdjYh(7bH(bfGjR5r?D)V7{`021G*H zL1D9?s0A}tnaP5p`jdMk_S@vZ1CS l7fI~jyjU`YZDK>jW_E>NECL{nX!<`hZ5Gt{EIhG+7XZb79KQen diff --git a/DESCRIPTION b/DESCRIPTION index bf71a4d..d7cc29c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -33,6 +33,7 @@ Collate: 'nearest.R' 'nearest.loc.R' 'newton.raph.R' + 'onedfunction.R' 'plot.mc.R' 'pois.int.R' 'pois.proc.R' @@ -44,6 +45,7 @@ Collate: 'rand.unif.R' 'rand.weib.R' 'tpower.R' + 'twodfunction.R' 'twodranduphill.R' 'update.CompPack.R' 'uphill.mixnorm.R' diff --git a/NAMESPACE b/NAMESPACE index f0c9113..4d2b219 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -22,6 +22,7 @@ export(mixnorm) export(nearest) export(nearest.loc) export(newton.raph) +export(onedfunction) export(plot.mc) export(pois.int) export(pois.proc) @@ -33,6 +34,7 @@ export(rand.norm) export(rand.unif) export(rand.weib) export(tpower) +export(twodfunction) export(twodranduphill) export(update.CompPack) export(uphill.mixnorm) diff --git a/R/twodfunction.R b/R/twodfunction.R index 75a31a0..f3991c3 100644 --- a/R/twodfunction.R +++ b/R/twodfunction.R @@ -10,10 +10,10 @@ #' twodfunction(1,1) #' #' @author Ernest Chan \email{faiernest@@gmail.com} -#' +#' @export twodfunction = function(x,y) { - z = matrix(0, nrow=length(x), nocol=length(y)) + z = matrix(0, nrow=length(x), ncol=length(y)) for(i in 1:length(y)) { for(j in 1: length(x)) diff --git a/man/onedfunction.Rd b/man/onedfunction.Rd new file mode 100644 index 0000000..9bf7fb1 --- /dev/null +++ b/man/onedfunction.Rd @@ -0,0 +1,19 @@ +\name{onedfunction} +\alias{onedfunction} +\title{onedfunction} +\usage{ + onedfunction(x) +} +\arguments{ + \item{x}{vector of values} +} +\description{ + function to generate x^4 + x^2 +} +\examples{ +onedfunction(1) +} +\author{ + Ernest Chan \email{faiernest418@gmail.com} +} + diff --git a/man/twodfunction.Rd b/man/twodfunction.Rd new file mode 100644 index 0000000..8bed791 --- /dev/null +++ b/man/twodfunction.Rd @@ -0,0 +1,21 @@ +\name{twodfunction} +\alias{twodfunction} +\title{twodfunction} +\usage{ + twodfunction(x, y) +} +\arguments{ + \item{x}{vector of value} + + \item{y}{vector of value} +} +\description{ + Generate cos(x) + cos(y) maxtrix +} +\examples{ +twodfunction(1,1) +} +\author{ + Ernest Chan \email{faiernest@gmail.com} +} + From f1c381e73372d2cedadfe73dd2897206510e1231 Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 19:07:58 -0600 Subject: [PATCH 065/112] Update twodranduphill.R --- R/twodranduphill.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/twodranduphill.R b/R/twodranduphill.R index 5c96eac..99cd540 100644 --- a/R/twodranduphill.R +++ b/R/twodranduphill.R @@ -11,7 +11,7 @@ #' @param t is the tempearture, where its default at 100 #' #' @examples -#' #twodranduphill(matrix(c(1,2,3,4,5,6,7,8,9,10,.1,.2,5,3,7,6), ncol = 4), 1, .4, 1, 100, 10) +#' twodranduphill(twodfunction, 1, .4, 1, 100, 10) #' #' @author Ernest Chan \email{faiernest418@@gmail.com} #' From 65caa411349e55ff29c5e9aa3e708090462afd63 Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 19:09:16 -0600 Subject: [PATCH 066/112] Update anneal.R --- R/anneal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/anneal.R b/R/anneal.R index dcfe229..8f4c313 100644 --- a/R/anneal.R +++ b/R/anneal.R @@ -11,7 +11,7 @@ #' @param g rate of temperature #' #' @examples -#' #anneal(sin, 0, 100, 1, 10, .99) +#' anneal(onedfunction, 0, 100, 1, 10, .99) #' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export From 7556c1c5c13913fc7650022d7c9c8e646edce3a6 Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 19:09:41 -0600 Subject: [PATCH 067/112] Update anneal.R --- R/anneal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/anneal.R b/R/anneal.R index 8f4c313..c1da307 100644 --- a/R/anneal.R +++ b/R/anneal.R @@ -11,7 +11,7 @@ #' @param g rate of temperature #' #' @examples -#' anneal(onedfunction, 0, 100, 1, 10, .99) +#' anneal(onedfunction, 2, 100, 1, 10, .99) #' @author Ernest Chan \email{faiernest418@@gmail.com} #' #' @export From 747268e687cb94a201931003c998d993790e7ca2 Mon Sep 17 00:00:00 2001 From: doddsie24 Date: Tue, 30 Apr 2013 19:13:45 -0600 Subject: [PATCH 068/112] Update cvscore.R --- R/cvscore.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/cvscore.R b/R/cvscore.R index e0767fd..a729789 100644 --- a/R/cvscore.R +++ b/R/cvscore.R @@ -1,4 +1,4 @@ -#' cvscore +#' Cross Validation #' #' @description Uses cross-validation to score how accurately a a linear, quadratic, cubic, and 4th and 5th degree polynomial models will perform when used in prediction. #' From 1993c5beedde31ea7d77cedc739402ff650538cf Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 19:14:01 -0600 Subject: [PATCH 069/112] Update twodfunction.R --- R/twodfunction.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/twodfunction.R b/R/twodfunction.R index f3991c3..88509a9 100644 --- a/R/twodfunction.R +++ b/R/twodfunction.R @@ -1,4 +1,4 @@ -#' twodfunction +#' cos(x) + cos(y) #' #' @description #' Generate cos(x) + cos(y) maxtrix From f82ba20e5976611fdd31be9369ef052e1bc20f1d Mon Sep 17 00:00:00 2001 From: doddsie24 Date: Tue, 30 Apr 2013 19:14:42 -0600 Subject: [PATCH 070/112] Update cvscore1.R --- R/cvscore1.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/cvscore1.R b/R/cvscore1.R index 99fc953..3a1fad3 100644 --- a/R/cvscore1.R +++ b/R/cvscore1.R @@ -1,4 +1,4 @@ -#' cvscore1 +#' Cross Validation-Linear Model #' #' @description Uses cross-validation to score how accurately a linear model will perform when used in prediction. Score can be compared to that of cvscore2,...,cvscore5. #' From 575a804fd74853a139a0441f400a0b7cd48d2c5c Mon Sep 17 00:00:00 2001 From: doddsie24 Date: Tue, 30 Apr 2013 19:15:06 -0600 Subject: [PATCH 071/112] Update cvscore2.R --- R/cvscore2.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/cvscore2.R b/R/cvscore2.R index d949176..bf91a56 100644 --- a/R/cvscore2.R +++ b/R/cvscore2.R @@ -1,4 +1,4 @@ -#' cvscore2 +#' Cross Validation-Quadratic Model #' #' @description Uses cross-validation to score how accurately a quadratic model will perform when used in prediction. Score can be compared to that of cvscore1,...,cvscore5. #' From 618b9c699f4fb5326cc404625a1dc904888cc22d Mon Sep 17 00:00:00 2001 From: doddsie24 Date: Tue, 30 Apr 2013 19:15:48 -0600 Subject: [PATCH 072/112] Update cvscore3.R --- R/cvscore3.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/cvscore3.R b/R/cvscore3.R index 4c29ca8..cecab16 100644 --- a/R/cvscore3.R +++ b/R/cvscore3.R @@ -1,4 +1,4 @@ -#' cvscore3 +#' Cross Validation-Cubic Model #' #' @description Uses cross-validation to score how accurately a cubic model will perform when used in prediction. Score can be compared to that of cvscore1,...,cvscore5. #' From 1abffdcccf363c1ffddae49fbb9cfa57cb764855 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:16:01 -0600 Subject: [PATCH 073/112] initialized econdata documentation --- man/econdata.Rd | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 man/econdata.Rd diff --git a/man/econdata.Rd b/man/econdata.Rd new file mode 100644 index 0000000..59fbc3b --- /dev/null +++ b/man/econdata.Rd @@ -0,0 +1,18 @@ +\name{tpower.data} +\alias{tpower.data} +\title{Matrix of p-values from the tpower function} +\description{ + This is a matrix of p-values from the tpower function. The columns have different mean differences (See diffs in the example for the differences). +} +\author{ + Tyler Hunt \email{tyler@psychoanalytix.com} +} +\examples{ +data(tpower.data) +diffs <- c(0, .05, .15, .2, .25, .3, .35, .4, .45) +#-compute the power at each difference +power<-colMeans(tpower.data<.05) +plot(diffs, power, "l") + +} + From 8335406d3b61eba0ec72d5e6aff91fecd0a1084b Mon Sep 17 00:00:00 2001 From: doddsie24 Date: Tue, 30 Apr 2013 19:16:26 -0600 Subject: [PATCH 074/112] Update cvscore4.R --- R/cvscore4.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/cvscore4.R b/R/cvscore4.R index e321c28..523890a 100644 --- a/R/cvscore4.R +++ b/R/cvscore4.R @@ -1,4 +1,4 @@ -#' cvscore4 +#' Cross Validation-4th Degree Polynomial #' #' @description Uses cross-validation to score how accurately a model using a 4th degree polynomial will perform when used in prediction. Score can be compared to that of cvscore1,...,cvscore5. #' @@ -32,4 +32,4 @@ function (x,y) yhat[i]=param[1]+x[i]*param[2]+x[i]^2*param[3] +x[i]^3*param[4] +x[i]^4*param[5] } sum((yhat-y)^2) -} \ No newline at end of file +} From 7c6d5872093403e9618c9b4bded67009fe661c99 Mon Sep 17 00:00:00 2001 From: doddsie24 Date: Tue, 30 Apr 2013 19:16:56 -0600 Subject: [PATCH 075/112] Update cvscore5.R --- R/cvscore5.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/cvscore5.R b/R/cvscore5.R index b46f6c8..9c7e4a8 100644 --- a/R/cvscore5.R +++ b/R/cvscore5.R @@ -1,4 +1,4 @@ -#' cvscore5 +#' Cross Validation-5th Degree Polynomial #' #' @description Uses cross-validation to score how accurately a model using a 5th degree polynomial will perform when used in prediction. Score can be compared to that of cvscore1,...,cvscore4. #' From 013666550e0675f2c73de55ee72565d68f6b1be7 Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 19:18:27 -0600 Subject: [PATCH 076/112] Update onedfunction.R --- R/onedfunction.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/onedfunction.R b/R/onedfunction.R index d740591..a3e2e03 100644 --- a/R/onedfunction.R +++ b/R/onedfunction.R @@ -1,4 +1,4 @@ -#' onedfunction +#' x^4 + x^2 #' #' @description #' function to generate x^4 + x^2 From 67d5a4fe842f36c6baf2e44d8e94f1feea5defed Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 19:18:50 -0600 Subject: [PATCH 077/112] Update anneal.R --- R/anneal.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/anneal.R b/R/anneal.R index c1da307..2103f99 100644 --- a/R/anneal.R +++ b/R/anneal.R @@ -1,4 +1,4 @@ -#' anneal +#' uphill search on fucntion #' #' @description #' General anneal function, where we conduct a uphill search on the function to find maximum From 9a1bfa4211bbe21f6c2a9e2e5bcb88ea7918e43e Mon Sep 17 00:00:00 2001 From: JackStat Date: Tue, 30 Apr 2013 19:19:04 -0600 Subject: [PATCH 078/112] lowered case From b82b9e5a79fddc08af9237e61d3851f6ef71374a Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 19:19:30 -0600 Subject: [PATCH 079/112] Update twodranduphill.R --- R/twodranduphill.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/twodranduphill.R b/R/twodranduphill.R index 99cd540..6e5e01b 100644 --- a/R/twodranduphill.R +++ b/R/twodranduphill.R @@ -1,4 +1,4 @@ -#' twodranduphill +#' uphill search on matrix function #' #' @description #' This function is use to do a random uphill search on any 2 demision data set From 9163aeb4d5b5c9032ce4a0e90284afb05449cfcb Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:21:43 -0600 Subject: [PATCH 080/112] Changed documentation for econdata --- .DS_Store | Bin 15364 -> 15364 bytes man/econdata.Rd | 12 ++++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.DS_Store b/.DS_Store index f455aa13710ed2c00c6184a4f24214e7284c1e7d..f671d7dd121776dbfae696f2165f616d143804a2 100644 GIT binary patch delta 1585 zcmeH_OKePG6vxlM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man/econdata.Rd @@ -1,5 +1,5 @@ -\name{tpower.data} -\alias{tpower.data} +\name{econdata.data} +\alias{econdata.data} \title{Matrix of p-values from the tpower function} \description{ This is a matrix of p-values from the tpower function. The columns have different mean differences (See diffs in the example for the differences). @@ -8,11 +8,11 @@ Tyler Hunt \email{tyler@psychoanalytix.com} } \examples{ -data(tpower.data) -diffs <- c(0, .05, .15, .2, .25, .3, .35, .4, .45) +#data(tpower.data) +#diffs <- c(0, .05, .15, .2, .25, .3, .35, .4, .45) #-compute the power at each difference -power<-colMeans(tpower.data<.05) -plot(diffs, power, "l") +#power<-colMeans(tpower.data<.05) +#plot(diffs, power, "l") } From 85274cff55b11d3cce246d56f8070ae9d9538f44 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:25:39 -0600 Subject: [PATCH 081/112] Accepted Documentation changes --- R/twodranduphill.R | 2 +- man/anneal.Rd | 4 ++-- man/cvscore.Rd | 2 +- man/cvscore1.Rd | 2 +- man/cvscore2.Rd | 2 +- man/cvscore3.Rd | 2 +- man/cvscore4.Rd | 2 +- man/cvscore5.Rd | 2 +- man/onedfunction.Rd | 2 +- man/twodfunction.Rd | 2 +- man/twodranduphill.Rd | 4 ++-- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/R/twodranduphill.R b/R/twodranduphill.R index 6e5e01b..38fe9d5 100644 --- a/R/twodranduphill.R +++ b/R/twodranduphill.R @@ -11,7 +11,7 @@ #' @param t is the tempearture, where its default at 100 #' #' @examples -#' twodranduphill(twodfunction, 1, .4, 1, 100, 10) +#' #twodranduphill(twodfunction, 1, .4, 1, 100, 10) #' #' @author Ernest Chan \email{faiernest418@@gmail.com} #' diff --git a/man/anneal.Rd b/man/anneal.Rd index 6b2c0da..865258d 100644 --- a/man/anneal.Rd +++ b/man/anneal.Rd @@ -1,6 +1,6 @@ \name{anneal} \alias{anneal} -\title{anneal} +\title{uphill search on fucntion} \usage{ anneal(f, mu, n = 1000, sig = 1, tt = 10, g = 0.999) } @@ -22,7 +22,7 @@ on the function to find maximum } \examples{ -#anneal(sin, 0, 100, 1, 10, .99) +anneal(onedfunction, 2, 100, 1, 10, .99) } \author{ Ernest Chan \email{faiernest418@gmail.com} diff --git a/man/cvscore.Rd b/man/cvscore.Rd index 70a4525..23c3eb8 100644 --- a/man/cvscore.Rd +++ b/man/cvscore.Rd @@ -1,6 +1,6 @@ \name{cvscore} \alias{cvscore} -\title{cvscore} +\title{Cross Validation} \usage{ cvscore(x, y) } diff --git a/man/cvscore1.Rd b/man/cvscore1.Rd index 50ecbfd..0757e85 100644 --- a/man/cvscore1.Rd +++ b/man/cvscore1.Rd @@ -1,6 +1,6 @@ \name{cvscore1} \alias{cvscore1} -\title{cvscore1} +\title{Cross Validation-Linear Model} \usage{ cvscore1(x, y) } diff --git a/man/cvscore2.Rd b/man/cvscore2.Rd index 9d5ac98..ab340e0 100644 --- a/man/cvscore2.Rd +++ b/man/cvscore2.Rd @@ -1,6 +1,6 @@ \name{cvscore2} \alias{cvscore2} -\title{cvscore2} +\title{Cross Validation-Quadratic Model} \usage{ cvscore2(x, y) } diff --git a/man/cvscore3.Rd b/man/cvscore3.Rd index ce2fb50..63da353 100644 --- a/man/cvscore3.Rd +++ b/man/cvscore3.Rd @@ -1,6 +1,6 @@ \name{cvscore3} \alias{cvscore3} -\title{cvscore3} +\title{Cross Validation-Cubic Model} \usage{ cvscore3(x, y) } diff --git a/man/cvscore4.Rd b/man/cvscore4.Rd index 435706a..7c55e0b 100644 --- a/man/cvscore4.Rd +++ b/man/cvscore4.Rd @@ -1,6 +1,6 @@ \name{cvscore4} \alias{cvscore4} -\title{cvscore4} +\title{Cross Validation-4th Degree Polynomial} \usage{ cvscore4(x, y) } diff --git a/man/cvscore5.Rd b/man/cvscore5.Rd index b181daf..3542f37 100644 --- a/man/cvscore5.Rd +++ b/man/cvscore5.Rd @@ -1,6 +1,6 @@ \name{cvscore5} \alias{cvscore5} -\title{cvscore5} +\title{Cross Validation-5th Degree Polynomial} \usage{ cvscore5(x, y) } diff --git a/man/onedfunction.Rd b/man/onedfunction.Rd index 9bf7fb1..e19c2e8 100644 --- a/man/onedfunction.Rd +++ b/man/onedfunction.Rd @@ -1,6 +1,6 @@ \name{onedfunction} \alias{onedfunction} -\title{onedfunction} +\title{x^4 + x^2} \usage{ onedfunction(x) } diff --git a/man/twodfunction.Rd b/man/twodfunction.Rd index 8bed791..66442da 100644 --- a/man/twodfunction.Rd +++ b/man/twodfunction.Rd @@ -1,6 +1,6 @@ \name{twodfunction} \alias{twodfunction} -\title{twodfunction} +\title{cos(x) + cos(y)} \usage{ twodfunction(x, y) } diff --git a/man/twodranduphill.Rd b/man/twodranduphill.Rd index 77766e4..d64fc81 100644 --- a/man/twodranduphill.Rd +++ b/man/twodranduphill.Rd @@ -1,6 +1,6 @@ \name{twodranduphill} \alias{twodranduphill} -\title{twodranduphill} +\title{uphill search on matrix function} \usage{ twodranduphill(f, x, y, s, n = 100, t = 100) } @@ -23,7 +23,7 @@ 2 demision data set } \examples{ -#twodranduphill(matrix(c(1,2,3,4,5,6,7,8,9,10,.1,.2,5,3,7,6), ncol = 4), 1, .4, 1, 100, 10) +#twodranduphill(twodfunction, 1, .4, 1, 100, 10) } \author{ Ernest Chan \email{faiernest418@gmail.com} From 8b0934f268beed169845288b8e969ca6b1f3c0e7 Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 19:27:34 -0600 Subject: [PATCH 082/112] Update twodfunction.R --- R/twodfunction.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/twodfunction.R b/R/twodfunction.R index 88509a9..09a8492 100644 --- a/R/twodfunction.R +++ b/R/twodfunction.R @@ -1,7 +1,7 @@ -#' cos(x) + cos(y) +#' exp(-(x+y)) #' #' @description -#' Generate cos(x) + cos(y) maxtrix +#' Generate exp(-(x+y) maxtrix #' #' @param x vector of value #' @param y vector of value @@ -18,7 +18,7 @@ twodfunction = function(x,y) { for(j in 1: length(x)) { - z[i,j] = cos(x[j]) + cos(y[i]) + z[i,j] = exp(-x[j] + -y[i]) } } z From a3d071dd36a361e29b0f31ad762dbc366b022932 Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 19:28:56 -0600 Subject: [PATCH 083/112] Update twodranduphill.R --- R/twodranduphill.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/twodranduphill.R b/R/twodranduphill.R index 38fe9d5..6e5e01b 100644 --- a/R/twodranduphill.R +++ b/R/twodranduphill.R @@ -11,7 +11,7 @@ #' @param t is the tempearture, where its default at 100 #' #' @examples -#' #twodranduphill(twodfunction, 1, .4, 1, 100, 10) +#' twodranduphill(twodfunction, 1, .4, 1, 100, 10) #' #' @author Ernest Chan \email{faiernest418@@gmail.com} #' From cc34fddddc60e6297b0fa7774402fc44a0b3b778 Mon Sep 17 00:00:00 2001 From: cispy Date: Tue, 30 Apr 2013 19:29:31 -0600 Subject: [PATCH 084/112] Update twodranduphill.R --- R/twodranduphill.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/twodranduphill.R b/R/twodranduphill.R index 6e5e01b..32d47b7 100644 --- a/R/twodranduphill.R +++ b/R/twodranduphill.R @@ -11,7 +11,7 @@ #' @param t is the tempearture, where its default at 100 #' #' @examples -#' twodranduphill(twodfunction, 1, .4, 1, 100, 10) +#' twodranduphill(twodfunction, 3, 2, 1, 10, 1) #' #' @author Ernest Chan \email{faiernest418@@gmail.com} #' From 497d2bbd39a3e70d1565769958cb7e32270be76f Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:30:42 -0600 Subject: [PATCH 085/112] shortened examples --- R/polar.rnorm.R | 2 +- man/polar.rnorm.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/polar.rnorm.R b/R/polar.rnorm.R index cbcdb66..f18d810 100644 --- a/R/polar.rnorm.R +++ b/R/polar.rnorm.R @@ -12,7 +12,7 @@ #' #' @examples #' -#' polar.rnorm(1000) +#' polar.rnorm(100) #' #' @export diff --git a/man/polar.rnorm.Rd b/man/polar.rnorm.Rd index 50f0428..11a06ea 100644 --- a/man/polar.rnorm.Rd +++ b/man/polar.rnorm.Rd @@ -15,7 +15,7 @@ Generates a sample of standard normals } \examples{ -polar.rnorm(1000) +polar.rnorm(100) } \author{ Katie Dodds \email{k.dodds@utah.edu} Damon McCafferty From 4788fcef07c0a9335f4e4cf457590ae4047a55cd Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:32:02 -0600 Subject: [PATCH 086/112] accepting Ernest's updated examples --- man/twodfunction.Rd | 4 ++-- man/twodranduphill.Rd | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/man/twodfunction.Rd b/man/twodfunction.Rd index 66442da..2001317 100644 --- a/man/twodfunction.Rd +++ b/man/twodfunction.Rd @@ -1,6 +1,6 @@ \name{twodfunction} \alias{twodfunction} -\title{cos(x) + cos(y)} +\title{exp(-(x+y))} \usage{ twodfunction(x, y) } @@ -10,7 +10,7 @@ \item{y}{vector of value} } \description{ - Generate cos(x) + cos(y) maxtrix + Generate exp(-(x+y) maxtrix } \examples{ twodfunction(1,1) diff --git a/man/twodranduphill.Rd b/man/twodranduphill.Rd index d64fc81..054bb12 100644 --- a/man/twodranduphill.Rd +++ b/man/twodranduphill.Rd @@ -23,7 +23,7 @@ 2 demision data set } \examples{ -#twodranduphill(twodfunction, 1, .4, 1, 100, 10) +twodranduphill(twodfunction, 3, 2, 1, 10, 1) } \author{ Ernest Chan \email{faiernest418@gmail.com} From f109bd442988fdc7d2cb6e7b07b844c461befded Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:34:08 -0600 Subject: [PATCH 087/112] removed econdata --- data/econdata.rda | Bin 3539 -> 0 bytes man/econdata.Rd | 18 ------------------ 2 files changed, 18 deletions(-) delete mode 100644 data/econdata.rda delete mode 100644 man/econdata.Rd diff --git a/data/econdata.rda b/data/econdata.rda deleted file mode 100644 index feb2f0a656aa1520759a5529fed3bb4b5043d02a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3539 zcmV;^4J`5>iwFP!000002JKmAR8`j!zM@e?^dXj55JgZ?RGJl(GYCjmx_C7T3J3_7 zDq@SMNK{n7h7BoF1(7KB0ygYP>>3lJ@u@K}#%MIw=iBFeb6t79KX2vNTPrzheRuB6 zo|)Zd@0ok9pL4K{Ua+1@rP5I~mOtf>COYDyk*bNRxuDGx!$OloBcfu$RjS5qgg{@Q zrGURm)oiiA5`j#Cr2@+YmJ4JFWDDd7tPof!uu5RHz#4&Efwcnb1l9{|5ZEY?C$LE% zU!XvsP@qU)vp}&xi9o49nLxQfg}@epN`WeYtpe2o+XQL^J{Q<7utT6$V5h(?f!zXo z1ojH-6WA|sK;WRjA%Qx9dV#|NM+A-v91}P$&>(O^;H1DQfztwK1kMVa6Zk^lOM$Nh z&I?=+xF~Q*;IhCKfvW=71g;BwEpS7uXDfM4X?faN@tmW~TPpdXC9T(qXFX+9Fr5$~ zKeXr^_{>J2%NIdETOaMq{{@;|hxQeNL01PrZ=I8^{7_y5`1}T@(dd7}E2jJ4XX6v_ z8_$Bz_W@sU6MhTRVPE8j_M!o3-<%G9^L_MJ><#^5W3-oKLtfeu_N5ykFMAEW3SG#z z%!ItEKlth{~D8fphb|^Z1Ga`KOdT==x;ZL{SGUp?RF@7J6gcL)&TakZ#yde z?lOnouCJLtjed7eVEzI0cRvB$TZw-5?T5ep<=_uw!tUU1$Pb;s`0B>NPn{daS>G3W z^+k{$9=%kNAFhM^NF@3>YWGyJKh}DzqIbMG(;wis!K_}nnYk;-I$u#!k;PgTK!&Uv7UX`VP7q@ zJnLDpd@#!;_T$RD+Ya#VTFUL7%zLpP57zg|03R>|egoNm5bFoBJh(6P)%u|0lF&Ym z`3dzHe+c^x4FNytBJ{#WqMtD4BNoGN)L77|gU}wg0PP8TV4v^^^2C?Wn^psPD$ir)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&%7ds?Rl{O7aef;Z$c2e%A4fR{XuSi+@(j#{B38lRM6Ys!MJDGUp+qmbX>ns zUbpm;eo@L)9SN`HBcwMy5bX zG;_6(e-Kdb6{!0y8&EG>J!&f#wq)5G@5?MBQBT?oL>+9q81I1wwnaT`#d_vBsDsUd z@&2;Qc)W*dhW?~`%4^hCb+?srw5y6AYWfWGH+uj-1B&rpc5oE>8FCuGcZN+->_7NZ z`6EqeYHkFn?+6>g>Z`o4LlNB)g=>Guu>rjY~|{a_+Hzcp-I{)X@z?7f9L%p62)x)>u>eA>HW2 Date: Tue, 30 Apr 2013 19:36:31 -0600 Subject: [PATCH 088/112] Added all of the authors --- .DS_Store | Bin 15364 -> 15364 bytes DESCRIPTION | 5 ++++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.DS_Store b/.DS_Store index f671d7dd121776dbfae696f2165f616d143804a2..80222d1b77087c76f411740fa9905591d837ba67 100644 GIT binary patch delta 1555 zcmeHH-%lJ>6rS&}l)LGS-X(3rFavDaHBcz9)e8P7bSZ3*LY1;0ZQ3;1GGiGFvkSXL zYBc*G!8GavPBr>uV$<4(CQ3Gq^~Ipk$cu?Fqlre1Mx#%r@xk=PM9)yQx@)3;fDiZ1 zx%d0#-195n^3w8BR8bThIAiTmlsYyAuiz`U^0uNVQFS%iVpQ<~!7VSg`Qt987u?yb zdunz54lfZ8837#Hgy)pZEtqfMX_3aY`GJ~JjR*+{uf6UQTKTL*`udix=o`!koR80C ztwHNdVOmi>ymad}H*+>Uot?{VvS{7=scFY*p-HdaJS%lUl&QZ)yEcEl%DX+@5f0*6 z4_Mwl)d=xPcr)>rqvEKQDcJp%Wm~c2RDdf=EZO?I!R#lDR8gQ7^=QE^w4oh)aUTXT zhQk=gF=TKWIV>QL0-nTEcn;6wJYK+ycm)^nI4%B4kh-?WPXuq#o*}A$ov@DNV=8CYQ2a(u{f5_DCsbM$xG?s?n)MC-0n`wI?5Q ztisIEOn%ySEyq1I>A04?BqG=ymNkBJEN*&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bGDJSBV9wWXgs#f@rcswu$%<*6XrCHg9)gWsrFJp>3DT0<>czWx< XmgfJ;{0}O# +Katie Dodds +Ernest Chan +Damon McCafferty Maintainer: Tyler Hunt Description: The functions in this package were developed in a computational statistics course taught at the University of Utah. From 89e70de2360a8b0d36e5a25a64345ae7acee12c8 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:37:20 -0600 Subject: [PATCH 089/112] tweaking description --- DESCRIPTION | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 6f337cd..fe8051b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,10 +3,10 @@ Type: Package Title: Collection of Computational Statistic Tools Version: 1.0 Date: 2013-04-10 -Author: Tyler Hunt -Katie Dodds -Ernest Chan -Damon McCafferty +Author: Tyler Hunt tyler@psychoanalytix.com +Katie Dodds k.dodds@utah.edu +Ernest Chan faiernest418@gmail.com +Damon McCafferty damon.mccafferty@economics.utah.edu Maintainer: Tyler Hunt Description: The functions in this package were developed in a computational statistics course taught at the University of Utah. From bdce6bb6a7bd01c026f35bfd155aefbc42cea52a Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:39:00 -0600 Subject: [PATCH 090/112] fixed author field --- DESCRIPTION | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index fe8051b..e7da0a6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,10 +3,10 @@ Type: Package Title: Collection of Computational Statistic Tools Version: 1.0 Date: 2013-04-10 -Author: Tyler Hunt tyler@psychoanalytix.com -Katie Dodds k.dodds@utah.edu -Ernest Chan faiernest418@gmail.com -Damon McCafferty damon.mccafferty@economics.utah.edu +Author: Tyler Hunt , +Katie Dodds , +Ernest Chan , +Damon McCafferty Maintainer: Tyler Hunt Description: The functions in this package were developed in a computational statistics course taught at the University of Utah. From cc28648202c10db6631a988adb47e20ab420580a Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:39:53 -0600 Subject: [PATCH 091/112] Author tweak 10001 --- DESCRIPTION | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e7da0a6..2053a0b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,10 +3,7 @@ Type: Package Title: Collection of Computational Statistic Tools Version: 1.0 Date: 2013-04-10 -Author: Tyler Hunt , -Katie Dodds , -Ernest Chan , -Damon McCafferty +Author: Tyler Hunt , Katie Dodds , Ernest Chan , Damon McCafferty Maintainer: Tyler Hunt Description: The functions in this package were developed in a computational statistics course taught at the University of Utah. From cde9cd9e1720dcec86cfb7beb780579b48066a5e Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:41:04 -0600 Subject: [PATCH 092/112] author tweak 10002 --- DESCRIPTION | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 2053a0b..ce2ef0d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,7 +3,9 @@ Type: Package Title: Collection of Computational Statistic Tools Version: 1.0 Date: 2013-04-10 -Author: Tyler Hunt , Katie Dodds , Ernest Chan , Damon McCafferty +Author: Tyler Hunt , Katie Dodds , + Ernest Chan , Damon McCafferty + Maintainer: Tyler Hunt Description: The functions in this package were developed in a computational statistics course taught at the University of Utah. From d86166b8b2a170e6471ce6a227517ffd42e39faf Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:46:22 -0600 Subject: [PATCH 093/112] changed name to polar.rnorm --- man/polar.norm.Rd | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 man/polar.norm.Rd diff --git a/man/polar.norm.Rd b/man/polar.norm.Rd deleted file mode 100644 index 994bb73..0000000 --- a/man/polar.norm.Rd +++ /dev/null @@ -1,20 +0,0 @@ -\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} -} - From 63529d313ea5cc4f0f6dc35ed840888d45cd5d3a Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:49:50 -0600 Subject: [PATCH 094/112] lowered case --- .DS_Store | Bin 15364 -> 15364 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.DS_Store b/.DS_Store index 80222d1b77087c76f411740fa9905591d837ba67..df541d668bfdc09e0b03bf3c66b4702292b1736d 100644 GIT binary patch delta 1363 zcmeH{Sx8i26vxm1n00TL$vac(jNO?WmuykfjLa5uOl>hUt;unuW%AzYwoJxMW)c`7 z(MrLkpqF~6Xd&8cdsU*Mda0(3>Om?ahzb(*p`dH_AobAl(o5gN;e6+C&iC=>&#$?m zx#9d5r6~~BJgTaxf{;w#PjbPizN}v*tFIyx3FM?KDx^iUgz9KB?WTitgf7u#xT!)mO-Is_5I7Hq>F?8QFp z#{nG1F`UIYT);(KLo06L9_}N8hj@Vwyh9hd(Zk@uEOP=6XD7QjgD3J-F5&rH!IfOY zDzD>uqun`2kt{=e)qc4qZK*783~80x+CW&Z*NRL9LdI;@3el(6t`9EI8#SYDSZtgq z3QuEXt8J*6$J^bb#!Z}7R9b1cV!eW7@#;ZUYcTFw?M?C^E7CgNY#^+e1pW0D!KoBF2 z+(}B_Wb^fYt229d%h9rGe!-DHT`BNLKaUTPL!voeT%xo@CEnm(DZGoShWV<0ONw|? ziqkRn#E}^jrWDR9kMxNmNk*%6JS3yj>N8`R%^f9WOU4G9+q@aJBr{&IrI_)VE!gxg ztkut1{{Pnc3u|TnnYCulk_=CrBYJL`GOyfN8kaC=!9vBGZjp?wak0PSfM1~HHa(yx z^orin2kNBHkYI-!X~;k>ro;0MC?zOI6&7P9RzWwZ5=JAMu^l`7*oj>*a0o|n94BxR zr@ld@4cBqQ1j{WGEsxQTmw0WW?x;?B--n;Z)A#37pRb?BPN# P<%P!j_|z8P=rgvjcE4=sD?0oe|Gq7Q`%) zqD31|MLWSLS_Bm$)w1Z~GU5;s6-i;MXceuZzF9;tv*{0L^R0e-FVFM7zr}^cg?m5M zG-*f+MfE04(=~77fHhK*V~uAv#3W=O7sc?wk5bg&09p`4H+nFP5T-DTIhcsz9M0o1 zmT(1EaShA3iMv?C13bhdJi$6%;Vs_bJwD(IzTyXMArR3{N+*T`ht{>G6&yo zd%Q)ewVdVkvQk!_h)R4-;$*ujt5kV6tFeL^PCrkvUA1*8+b*Uebs z=fiQbc}^FvCP_9gE>V1bCMRNjrg2v1q4-A?l}c5$oJ>rK0=VfA#NJq~Qnyb|n$K}wg14egNIr;BOv1n^A@~`g_aZLfA}$HZ zuVV!_gyOew8~26ekA>n-@eD8U60h+Q8~B9J*u*z{$1kBeQ3|C}8aXMC@~MzKR3wDo XBXkc?12s_x^;$E#idP4HcQSqhr2<8c From d640ada8e6533e30685064ae8d747c018b58e60e Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:53:10 -0600 Subject: [PATCH 095/112] removed bootstrap --- .DS_Store | Bin 15364 -> 15364 bytes DESCRIPTION | 1 - NAMESPACE | 1 - R/Bootstrap.R | 24 ------------------------ man/Bootstrap.Rd | 26 -------------------------- 5 files changed, 52 deletions(-) delete mode 100644 R/Bootstrap.R delete mode 100644 man/Bootstrap.Rd diff --git a/.DS_Store b/.DS_Store index df541d668bfdc09e0b03bf3c66b4702292b1736d..cec8aa95e2eec9918f533ccf601f196b680ff053 100644 GIT binary patch delta 35 ocmZpvXsOuXDLk1&R*1<#W^=5t1@q)64G?>Btg!y(8)7=D0K#tyGynhq delta 63 scmZpvXsOuXDJ&j0`b diff --git a/DESCRIPTION b/DESCRIPTION index ce2ef0d..54d214a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -13,7 +13,6 @@ License: MIT Collate: 'anneal.R' 'around.R' - 'bootstrap.R' 'cvscore.R' 'cvscore1.R' 'cvscore2.R' diff --git a/NAMESPACE b/NAMESPACE index 4d2b219..c1d3111 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,5 @@ export(anneal) export(around) -export(bootstrap) export(cvscore) export(cvscore1) export(cvscore2) diff --git a/R/Bootstrap.R b/R/Bootstrap.R deleted file mode 100644 index 555f2fb..0000000 --- a/R/Bootstrap.R +++ /dev/null @@ -1,24 +0,0 @@ -#' 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, ie., mean, var, cov, etc. -#' -#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} -#' -#' @examples -#' x = runif(10, 0, 1) -#' bootstrap(x,fn=mean) -#' -#' @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/man/Bootstrap.Rd b/man/Bootstrap.Rd deleted file mode 100644 index 85d2796..0000000 --- a/man/Bootstrap.Rd +++ /dev/null @@ -1,26 +0,0 @@ -\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, ie., mean, - var, cov, etc.} -} -\description{ - This function is used for estimating standard errors when - the distribution is not know. -} -\examples{ -x = runif(10, 0, 1) -bootstrap(x,fn=mean) -} -\author{ - Tyler Hunt \email{tyler@psychoanalytix.com} -} - From 7f1745e167ebabcadd9d372ca547eebfeda556ad Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:54:42 -0600 Subject: [PATCH 096/112] added bootstrap back in --- .DS_Store | Bin 15364 -> 15364 bytes DESCRIPTION | 1 + NAMESPACE | 1 + R/bootstrap.R | 24 ++++++++++++++++++++++++ man/bootstrap.Rd | 26 ++++++++++++++++++++++++++ 5 files changed, 52 insertions(+) create mode 100644 R/bootstrap.R create mode 100644 man/bootstrap.Rd diff --git a/.DS_Store b/.DS_Store index cec8aa95e2eec9918f533ccf601f196b680ff053..256cb718b63969ca8f361abf5c1968ace4932362 100644 GIT binary patch delta 838 zcmZY7O-K}B9LMo~f3s$2o_N&N8fVmW7u5B=Oe=HMR7}@ueM?0VR%gmdofT&>3t|sR z(V>ge+f6WvZWSWcu_*EwF+@Z~QPe3sMaOy;I_+Mb)0gL&--lUVT3&jzl_haCU(*Yi z;)aU$CdQ3u+&mF8tTUEr@C`}!cyWp5FJNrwyk*3vN2AV^X&aV(b}U)8FPP#qB+28Y zWmwLl*BGZPr39 z>B;b-x!_nan}?H8dxzGUn;wl!#pdQrJMJW#?j9}No3g7(44X&}>y0|`Q}d=R5H`g+ zEz-wX0UJzRCrP8py3H_5!yPTt+^L+FgoJG5qZH)`q5}0ef(}H`hklG9iW$sf0S@B0 zgv+>&72Lp0+`=mE;UPBg1W)k{FR+QX_<)c2gwObiU-(1Y2t>4tvPh#KRZLCGcE=gIal=)7t#2?Vz)m*=yRj{hm zR1*IHCr_=Z)s_9M-i>7Yf;_`h8yag*(otmOELxa6t*1G-YdPN&wg#PJ`w+KK;;hr~shNFNArPDiuSwe7YfUZfw}yfq-Lu|KrA;keXO)8<-J7xdvL;oF&$IgH@czyA zmaYH!7Oft3 Date: Tue, 30 Apr 2013 19:57:14 -0600 Subject: [PATCH 097/112] Deleted bootstrap --- DESCRIPTION | 1 - NAMESPACE | 1 - R/bootstrap.R | 24 ------------------------ man/bootstrap.Rd | 26 -------------------------- 4 files changed, 52 deletions(-) delete mode 100644 R/bootstrap.R delete mode 100644 man/bootstrap.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 23c17e3..54d214a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -51,4 +51,3 @@ Collate: 'update.CompPack.R' 'uphill.mixnorm.R' 'wich.hill.R' - 'bootstrap.R' diff --git a/NAMESPACE b/NAMESPACE index 4d2b219..c1d3111 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,5 @@ export(anneal) export(around) -export(bootstrap) export(cvscore) export(cvscore1) export(cvscore2) diff --git a/R/bootstrap.R b/R/bootstrap.R deleted file mode 100644 index 555f2fb..0000000 --- a/R/bootstrap.R +++ /dev/null @@ -1,24 +0,0 @@ -#' 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, ie., mean, var, cov, etc. -#' -#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} -#' -#' @examples -#' x = runif(10, 0, 1) -#' bootstrap(x,fn=mean) -#' -#' @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/man/bootstrap.Rd b/man/bootstrap.Rd deleted file mode 100644 index 85d2796..0000000 --- a/man/bootstrap.Rd +++ /dev/null @@ -1,26 +0,0 @@ -\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, ie., mean, - var, cov, etc.} -} -\description{ - This function is used for estimating standard errors when - the distribution is not know. -} -\examples{ -x = runif(10, 0, 1) -bootstrap(x,fn=mean) -} -\author{ - Tyler Hunt \email{tyler@psychoanalytix.com} -} - From e4577d5931f22003c742e12a77b227eb5bc0db40 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:58:02 -0600 Subject: [PATCH 098/112] d --- DESCRIPTION | 41 ----------------------------------------- NAMESPACE | 40 ---------------------------------------- 2 files changed, 81 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 54d214a..003889c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,44 +10,3 @@ Maintainer: Tyler Hunt Description: The functions in this package were developed in a computational statistics course taught at the University of Utah. License: MIT -Collate: - 'anneal.R' - 'around.R' - 'cvscore.R' - 'cvscore1.R' - 'cvscore2.R' - 'cvscore3.R' - 'cvscore4.R' - 'cvscore5.R' - 'd1f.R' - 'd2f.R' - 'em.mixnorm.R' - 'f.models.R' - 'gold.sect.R' - 'grid.sect.R' - 'jackknife.R' - 'log.lik.R' - 'maxbound.R' - 'mc.R' - 'mixlike.R' - 'mixnorm.R' - 'nearest.R' - 'nearest.loc.R' - 'newton.raph.R' - 'onedfunction.R' - 'plot.mc.R' - 'pois.int.R' - 'pois.proc.R' - 'pois.rate.R' - 'polar.rnorm.R' - 'rand.exp.R' - 'rand.mvnorm.R' - 'rand.norm.R' - 'rand.unif.R' - 'rand.weib.R' - 'tpower.R' - 'twodfunction.R' - 'twodranduphill.R' - 'update.CompPack.R' - 'uphill.mixnorm.R' - 'wich.hill.R' diff --git a/NAMESPACE b/NAMESPACE index c1d3111..e69de29 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,40 +0,0 @@ -export(anneal) -export(around) -export(cvscore) -export(cvscore1) -export(cvscore2) -export(cvscore3) -export(cvscore4) -export(cvscore5) -export(d1f) -export(df) -export(em.mixnorm) -export(f.models) -export(gold.sect) -export(grid.sect) -export(jackknife) -export(log.lik) -export(maxbound) -export(mc) -export(mixlike) -export(mixnorm) -export(nearest) -export(nearest.loc) -export(newton.raph) -export(onedfunction) -export(plot.mc) -export(pois.int) -export(pois.proc) -export(pois.rate) -export(polar.rnorm) -export(rand.exp) -export(rand.mvnorm) -export(rand.norm) -export(rand.unif) -export(rand.weib) -export(tpower) -export(twodfunction) -export(twodranduphill) -export(update.CompPack) -export(uphill.mixnorm) -export(wich.hill) From 69beaa00d125ff2e21e5797a8a139042d94daf08 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 19:59:28 -0600 Subject: [PATCH 099/112] updated description --- DESCRIPTION | 41 +++++++++++++++++++++++++++++++++++++++++ NAMESPACE | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index 003889c..54d214a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -10,3 +10,44 @@ Maintainer: Tyler Hunt Description: The functions in this package were developed in a computational statistics course taught at the University of Utah. License: MIT +Collate: + 'anneal.R' + 'around.R' + 'cvscore.R' + 'cvscore1.R' + 'cvscore2.R' + 'cvscore3.R' + 'cvscore4.R' + 'cvscore5.R' + 'd1f.R' + 'd2f.R' + 'em.mixnorm.R' + 'f.models.R' + 'gold.sect.R' + 'grid.sect.R' + 'jackknife.R' + 'log.lik.R' + 'maxbound.R' + 'mc.R' + 'mixlike.R' + 'mixnorm.R' + 'nearest.R' + 'nearest.loc.R' + 'newton.raph.R' + 'onedfunction.R' + 'plot.mc.R' + 'pois.int.R' + 'pois.proc.R' + 'pois.rate.R' + 'polar.rnorm.R' + 'rand.exp.R' + 'rand.mvnorm.R' + 'rand.norm.R' + 'rand.unif.R' + 'rand.weib.R' + 'tpower.R' + 'twodfunction.R' + 'twodranduphill.R' + 'update.CompPack.R' + 'uphill.mixnorm.R' + 'wich.hill.R' diff --git a/NAMESPACE b/NAMESPACE index e69de29..c1d3111 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -0,0 +1,40 @@ +export(anneal) +export(around) +export(cvscore) +export(cvscore1) +export(cvscore2) +export(cvscore3) +export(cvscore4) +export(cvscore5) +export(d1f) +export(df) +export(em.mixnorm) +export(f.models) +export(gold.sect) +export(grid.sect) +export(jackknife) +export(log.lik) +export(maxbound) +export(mc) +export(mixlike) +export(mixnorm) +export(nearest) +export(nearest.loc) +export(newton.raph) +export(onedfunction) +export(plot.mc) +export(pois.int) +export(pois.proc) +export(pois.rate) +export(polar.rnorm) +export(rand.exp) +export(rand.mvnorm) +export(rand.norm) +export(rand.unif) +export(rand.weib) +export(tpower) +export(twodfunction) +export(twodranduphill) +export(update.CompPack) +export(uphill.mixnorm) +export(wich.hill) From 325950f1da83d7984eaf731b1758601f4fb9d4a8 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 20:04:05 -0600 Subject: [PATCH 100/112] h --- .DS_Store | Bin 15364 -> 15364 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.DS_Store b/.DS_Store index 256cb718b63969ca8f361abf5c1968ace4932362..3b98d1b66d279364acb3e6dfc39b3aa32f15546d 100644 GIT binary patch delta 275 zcmZpvXsOunSB8%xG9|Gj)iEU{HAUH>U~-IxqBti52ZJnw5rYdu1VaKt5koaYFT)Im zg_E0w=Q5U0ekkk3$-~PR9uX-J#WT4;q;eL1+fsg7C@o#uQUMocEFJdS+=Dp#YCPk!zoFmkV$i>me$iI+Cgv8UfNHG=ro<7FX&4; zN8iv@x}^4MKEBZ3{_ZwI@DtsTCf4H;5BSVFA{L^Hr~NLyodMk z0Y1b*9Komf3@30BU*Rk+AaWVs!N(Qc#BJQcFdpC`gD0}&BA(19hq!{Pc@a18T5jQ1 z?qZ93dBD46t}=x7Tu0{y*;Tq($~RoQ)$WNWodLT(VCi}*L$7=NxjFf&s$9>K*^_c| z^YRM{!!u`BFRpKF^+I{;CYm9k#hip?4|?Bb7pCNdY?P~tKdpGWE<&QTeZX;@Ej@PZ zO~*=Z>x{cw?S$ndx>Z$@ug@woo-fz5(M8GfjH3AZoVmseRhq~skCAaj_4UYnW5L4U z_a{bIrf17>(h644m(&R(y=jHJCp-_teviGHQu=|24dfkK2)iV8$fgXl=U zHlP{p*obaygA=4|5<4-3cd-k*u?HRw;4qHj7>?tkk&HcuuW>%e*^9W0$Pc)MAMtaL xw7=jkhMAaoERW;yoW*%Og~MFT)47Bzc^)s}r5xp2Zsazvub|{q$E;5#JqA|~z!3ld From f36c5d34a61688bef04519c3d103764e3a6c5013 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 30 Apr 2013 20:07:25 -0600 Subject: [PATCH 101/112] adding in bootstrap --- DESCRIPTION | 1 + NAMESPACE | 1 + R/bootstrap.R | 24 ++++++++++++++++++++++++ man/bootstrap.Rd | 26 ++++++++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 R/bootstrap.R create mode 100644 man/bootstrap.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 54d214a..23c17e3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -51,3 +51,4 @@ Collate: 'update.CompPack.R' 'uphill.mixnorm.R' 'wich.hill.R' + 'bootstrap.R' diff --git a/NAMESPACE b/NAMESPACE index c1d3111..4d2b219 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ export(anneal) export(around) +export(bootstrap) export(cvscore) export(cvscore1) export(cvscore2) diff --git a/R/bootstrap.R b/R/bootstrap.R new file mode 100644 index 0000000..555f2fb --- /dev/null +++ b/R/bootstrap.R @@ -0,0 +1,24 @@ +#' 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, ie., mean, var, cov, etc. +#' +#' @author Tyler Hunt \email{tyler@@psychoanalytix.com} +#' +#' @examples +#' x = runif(10, 0, 1) +#' bootstrap(x,fn=mean) +#' +#' @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/man/bootstrap.Rd b/man/bootstrap.Rd new file mode 100644 index 0000000..85d2796 --- /dev/null +++ b/man/bootstrap.Rd @@ -0,0 +1,26 @@ +\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, ie., mean, + var, cov, etc.} +} +\description{ + This function is used for estimating standard errors when + the distribution is not know. +} +\examples{ +x = runif(10, 0, 1) +bootstrap(x,fn=mean) +} +\author{ + Tyler Hunt \email{tyler@psychoanalytix.com} +} + From 8944f25d632282172414803fb00003906dd5c00e Mon Sep 17 00:00:00 2001 From: JackStat Date: Mon, 13 May 2013 09:31:05 -0600 Subject: [PATCH 102/112] Added main help file --- man/CompPack.Rd | 96 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 man/CompPack.Rd diff --git a/man/CompPack.Rd b/man/CompPack.Rd new file mode 100644 index 0000000..bfabbc1 --- /dev/null +++ b/man/CompPack.Rd @@ -0,0 +1,96 @@ +\name{CompPack} +\alias{CompPack} +\title{A collection of Computational Statistic Functions.} +\arguments{ + \item{anneal}{Uphill search on function} + + \item{around}{Find the Values Around a Particular Value} + + \item{bootstrap}{Bootstrap a simple function} + + \item{cvscore}{Cross Validation for 1-5 order polynomials} + + \item{cvscore1}{Cross Validation for 1st order polynomials} + + \item{cvsscore2}{Cross Validation for 2nd order polynomials} + + \item{cvsscore3}{Cross Validation for 3rd order polynomials} + + \item{cvsscore4}{Cross Validation for 4th order polynomials} + + \item{cvsscore5}{Cross Validation for 5th order polynomials} + + \item{d1f}{Take first derivative of a function} + + \item{df}{Take second derivative of a function} + + \item{em.mixnorm}{EM-Algorithm for Normal Distribution} + + \item{f.models}{Plot a linear, quadratic, cubic and 4th degree models for + a 2D dataset.} + + \item{gold.sect}{Golden Section Search Optimization} + + \item{grid.sect}{Grid Section Search Optimization} + + \item{jackknife}{Resamples Data using the Jackknife Method} + + \item{log.lik}{Find the log likelihood of a normal distribution} + + \item{maxbound}{Maxbound Optimization} + + \item{mc}{Generate Markov Chains} + + \item{mixlike}{Compute the log likelihood function for the mixture of + normal distributions} + + \item{mixnorm}{Create a Mixture of Normal Distributions} + + \item{nearest.loc}{Find Location of Nearest Value} + + \item{newton.raph}{Newton Raphson Alogorithm} + + \item{onedfunction}{Simple polynomial function} + + \item{plot.mc}{Plot Markov Chains} + + \item{pois.int}{Averages the length of an interval containing a + specified time} + + \item{pois.proc}{Simulate a Poisson process of specified length and rate.} + + \item{pois.rate}{Average Time Between Events in a Poisson Process} + + \item{polar.rnorm}{Polar Random Normal} + + \item{rand.exp}{Generate Random Exponential Variables} + + \item{rand.mvrnorm}{Generate Multivariate Normal Distribution} + + \item{rand.norm}{Generate Random Normal Variables} + + \item{rand.unif}{Generate Random Uniform Variables} + + \item{rand.weib}{Generate Random Weibull Variables} + + \item{tpower.data}{Matrix of p-values from the tpower function} + + \item{twodfunction}{Simple 2D function for demonstrations} + + \item{update.ComPack}{Updates CompPack} + + \item{uphill.mixnorm}{uphill search on a mixture of normal distribution} + + \item{wich.hill}{Wichman Hill RNG} +} +\description{ + General anneal function, where we conduct a uphill search + on the function to find maximum +} +\author{ + Tyler Hunt \email{tyler@psychoanalytix.com} + Damon McCafferty \email{damon.mccafferty@economics.utah.edu} + Katie Dodds \email{k.dodds@utah.edu} + Ernest Chan \email{faiernest418@gmail.com} +} + From 7415a6956b8998c9aedf67fbc6ed997e62bacc54 Mon Sep 17 00:00:00 2001 From: JackStat Date: Mon, 13 May 2013 09:32:13 -0600 Subject: [PATCH 103/112] formatting --- man/CompPack.Rd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/CompPack.Rd b/man/CompPack.Rd index bfabbc1..858fece 100644 --- a/man/CompPack.Rd +++ b/man/CompPack.Rd @@ -88,9 +88,9 @@ on the function to find maximum } \author{ - Tyler Hunt \email{tyler@psychoanalytix.com} - Damon McCafferty \email{damon.mccafferty@economics.utah.edu} - Katie Dodds \email{k.dodds@utah.edu} + Tyler Hunt \email{tyler@psychoanalytix.com} \\ + Damon McCafferty \email{damon.mccafferty@economics.utah.edu}\\ + Katie Dodds \email{k.dodds@utah.edu}\\ Ernest Chan \email{faiernest418@gmail.com} } From ebc563dc447333c807077e5892d82a736cb4e66d Mon Sep 17 00:00:00 2001 From: JackStat Date: Mon, 13 May 2013 09:33:45 -0600 Subject: [PATCH 104/112] formatting emails --- man/CompPack.Rd | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/man/CompPack.Rd b/man/CompPack.Rd index 858fece..51cf48e 100644 --- a/man/CompPack.Rd +++ b/man/CompPack.Rd @@ -88,9 +88,12 @@ on the function to find maximum } \author{ - Tyler Hunt \email{tyler@psychoanalytix.com} \\ - Damon McCafferty \email{damon.mccafferty@economics.utah.edu}\\ - Katie Dodds \email{k.dodds@utah.edu}\\ + Tyler Hunt \email{tyler@psychoanalytix.com} + + Damon McCafferty \email{damon.mccafferty@economics.utah.edu} + + Katie Dodds \email{k.dodds@utah.edu} + Ernest Chan \email{faiernest418@gmail.com} } From 1d414c3cc8687521982041158b937ee0a98342b6 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 5 May 2015 15:20:18 -0600 Subject: [PATCH 105/112] add travis --- .travis.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2862b3d --- /dev/null +++ b/.travis.yml @@ -0,0 +1 @@ +language: r \ No newline at end of file From b9592ddb9abfbfe42fa94512d3039a4a69910769 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 5 May 2015 15:22:40 -0600 Subject: [PATCH 106/112] add travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2862b3d..72fb5f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1 +1,2 @@ -language: r \ No newline at end of file +language: r +sudo: required \ No newline at end of file From 008d1c343af784de793b264b24f7a7cd06ab9d06 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 5 May 2015 15:27:36 -0600 Subject: [PATCH 107/112] copy travis from wickham --- .travis.yml | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 72fb5f8..602db1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,30 @@ -language: r -sudo: required \ No newline at end of file +# Sample .travis.yml for R projects from https://github.com/craigcitro/r-travis + +language: c + +env: + - global: + - WARNINGS_ARE_ERRORS=1 + + +before_install: + - curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh + - chmod 755 ./travis-tool.sh + - ./travis-tool.sh bootstrap + +install: + - ./travis-tool.sh install_deps + - ./travis-tool.sh github_package jimhester/covr + +script: ./travis-tool.sh run_tests + +on_failure: + - ./travis-tool.sh dump_logs + +after_success: + - Rscript -e 'library(covr);coveralls()' + +notifications: + email: + on_success: change + on_failure: change \ No newline at end of file From 6290d06879946bde5d543cbd27f4497e17831098 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 5 May 2015 15:58:45 -0600 Subject: [PATCH 108/112] Update README.md --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a1cc0a7..fbcc706 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -CompPack A collection of computational statistic functions -======================================================== +# CompPack A collection of computational statistic functions + +[![Travis-CI Build Status](https://travis-ci.org/JackStat/CompPack.png?branch=master)](https://travis-ci.org/JackStat/CompPack) + + The functions for this package were developed from a class taken at the University of Utah taught by Alun Thomas. From 24e544980f013cbec16b21ffef74ec9bd0c2ae95 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 5 May 2015 20:50:52 -0600 Subject: [PATCH 109/112] simplify travis --- .travis.yml | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/.travis.yml b/.travis.yml index 602db1c..72fb5f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,30 +1,2 @@ -# Sample .travis.yml for R projects from https://github.com/craigcitro/r-travis - -language: c - -env: - - global: - - WARNINGS_ARE_ERRORS=1 - - -before_install: - - curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh - - chmod 755 ./travis-tool.sh - - ./travis-tool.sh bootstrap - -install: - - ./travis-tool.sh install_deps - - ./travis-tool.sh github_package jimhester/covr - -script: ./travis-tool.sh run_tests - -on_failure: - - ./travis-tool.sh dump_logs - -after_success: - - Rscript -e 'library(covr);coveralls()' - -notifications: - email: - on_success: change - on_failure: change \ No newline at end of file +language: r +sudo: required \ No newline at end of file From 7a124998c2d7767437dda19d295bd863aeeb01bc Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Tue, 5 May 2015 21:29:02 -0600 Subject: [PATCH 110/112] add coveralls to travis --- .travis.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 72fb5f8..a001e83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,8 @@ language: r -sudo: required \ No newline at end of file +sudo: required + +r_github_packages: + - jimhester/covr + +after_success: + - Rscript -e 'library(covr);coveralls()' \ No newline at end of file From 8d4c20a4f379b410f4bdd54eedd15a52df35c6c5 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Wed, 6 May 2015 12:45:58 -0600 Subject: [PATCH 111/112] add coveralls to travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a001e83..13a1bb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: r sudo: required r_github_packages: - - jimhester/covr + - ./travis-tool.sh github_package jimhester/covr after_success: - Rscript -e 'library(covr);coveralls()' \ No newline at end of file From 77607bedf4bada8be1e3a48aa9300f69f8410b47 Mon Sep 17 00:00:00 2001 From: Tyler Hunt Date: Wed, 6 May 2015 14:36:55 -0600 Subject: [PATCH 112/112] add coveralls to travis --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 13a1bb8..28f84d1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,4 +5,5 @@ r_github_packages: - ./travis-tool.sh github_package jimhester/covr after_success: - - Rscript -e 'library(covr);coveralls()' \ No newline at end of file + - Rscript -e 'library(covr);coveralls()' + \ No newline at end of file