Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
144 commits
Select commit Hold shift + click to select a range
452e5d1
Updated Documentation
JackStat Apr 22, 2013
ece7a9f
Updated documentation
JackStat Apr 23, 2013
d074185
Added Bootstrap Function
JackStat Apr 23, 2013
997e2ca
test
JackStat Apr 23, 2013
eaa1758
Updated Bootstrap documentation
JackStat Apr 23, 2013
b03538e
Updated Bootstrap documentation 2
JackStat Apr 23, 2013
b2d9de9
Merge pull request #2 from cispy/master
cispy Apr 23, 2013
95c2fdf
test, added periods
dcaff Apr 24, 2013
e19b892
Polar random normal
dcaff Apr 24, 2013
ded8e52
Merge pull request #3 from dcaff/damon
JackStat Apr 24, 2013
6a4c8b7
Merge pull request #1 from JackStat/master
dcaff Apr 25, 2013
0ed074a
added descritpion
JackStat Apr 25, 2013
18e8154
Allowing Damon's edits
JackStat Apr 25, 2013
a86dc5c
Merge pull request #4 from dcaff/master
JackStat Apr 25, 2013
daf025b
Merge pull request #3 from JackStat/master
dcaff Apr 25, 2013
22c1108
Changed to polar norm
JackStat Apr 25, 2013
9e3e361
Merge branch 'master' of https://github.com/JackStat/CompPack
JackStat Apr 25, 2013
81bb40d
Added polar norm and tweaks
JackStat Apr 25, 2013
a318928
updated description
dcaff Apr 25, 2013
d56c510
updated documentation
dcaff Apr 25, 2013
ad8c31a
Merge pull request #5 from dcaff/master
JackStat Apr 25, 2013
174c6c6
Changed jackknife example to examples
JackStat Apr 25, 2013
11988c5
Merge pull request #4 from JackStat/master
dcaff Apr 25, 2013
a91ef3a
unchecked Bootstrap
dcaff Apr 25, 2013
0eff8a3
Merge pull request #6 from dcaff/master
JackStat Apr 25, 2013
d076f5c
checked bootstrap
JackStat Apr 25, 2013
ea4d33e
Merge pull request #5 from JackStat/master
dcaff Apr 25, 2013
ea6bd6f
added @return values and example
dcaff Apr 25, 2013
801e951
added an example
dcaff Apr 26, 2013
58a840e
added return values and an example
dcaff Apr 26, 2013
d0fd8ed
added tyler as the author, return values and an example
dcaff Apr 26, 2013
a0b1ccf
Merge pull request #7 from dcaff/master
JackStat Apr 26, 2013
3ccc53b
ran check on Damon's edits
JackStat Apr 26, 2013
7665b80
took out wrong quote before export
JackStat Apr 26, 2013
0382866
Merge pull request #6 from JackStat/master
dcaff Apr 26, 2013
80bc57d
Update em.mixnorm.R
dcaff Apr 26, 2013
f85aa81
Update gold.sect.R
dcaff Apr 26, 2013
233c682
Update grid.sect.R
dcaff Apr 26, 2013
11ee997
Update grid.sect.R
dcaff Apr 26, 2013
25e96c7
Update grid.sect.R
dcaff Apr 26, 2013
ced03f3
Update jackknife.R
dcaff Apr 26, 2013
dc6041a
Update maxbound.R
dcaff Apr 26, 2013
05c1d51
Update mc.R
dcaff Apr 26, 2013
0b1dc4c
Update mixnorm.R
dcaff Apr 26, 2013
83aa715
Update nearest.R
dcaff Apr 26, 2013
aa7a9a5
Update newton.raph.R
dcaff Apr 26, 2013
b5e9598
unchecked log liklihood function
dcaff Apr 26, 2013
33fe6aa
Merge pull request #8 from dcaff/master
dcaff Apr 26, 2013
943d3ae
no changes made to this, but it will not allow me to pull a merge req…
dcaff Apr 26, 2013
560e566
log liklihood function
dcaff Apr 26, 2013
7743539
Merge pull request #9 from dcaff/master
dcaff Apr 26, 2013
892e2b1
Update em.mixnorm.R
dcaff Apr 26, 2013
9eed25f
updated description, and/or results and/or added periods
dcaff Apr 26, 2013
aba9f84
added a description and periods
dcaff Apr 26, 2013
2481be1
Merge pull request #10 from dcaff/master
dcaff Apr 26, 2013
e39908f
function for the first derivative
dcaff Apr 26, 2013
e0fdff9
function of the second derivative
dcaff Apr 26, 2013
323269a
Merge pull request #7 from JackStat/master
dcaff Apr 26, 2013
409e980
Update df.R
dcaff Apr 26, 2013
7fd59b5
Rename df.R to d1f.R
dcaff Apr 26, 2013
c99a25c
Update newton.raph.R
dcaff Apr 26, 2013
5ae8a3d
Merge pull request #11 from dcaff/master
dcaff Apr 27, 2013
f2749b0
Uploaded a new 2dranduphill function that was use for hw4, for doing …
cispy Apr 27, 2013
158904b
Anneal function, haven't put anything in there description or comment…
cispy Apr 27, 2013
0e6165d
uphill.mixnorm function, basically is the same thing as the em one ex…
cispy Apr 27, 2013
0f6fe4f
added description/param on anneal, fixed a few errors on 2dranduphill…
cispy Apr 28, 2013
f23e54f
rda file for my economic data set, yes I think I figured out, maybe? …
cispy Apr 28, 2013
7603eda
Merge pull request #8 from JackStat/master
dcaff Apr 29, 2013
bc844cb
fix spelling error on anneal, added example and changed doc name on 2…
cispy Apr 30, 2013
c8dc3b8
Merge pull request #9 from JackStat/master
dcaff Apr 30, 2013
bf74ca0
Merge pull request #15 from dcaff/master
dcaff Apr 30, 2013
72ae3e5
add examples for anneal, uphill.mixnorm, add mixlike function which i…
cispy Apr 30, 2013
dd66071
Added a random weibull function
JackStat Apr 30, 2013
3de9786
Uploading Katie's additions
JackStat Apr 30, 2013
6a833c2
Added in random weibull
JackStat Apr 30, 2013
fdf764a
Fixing merge issues
JackStat Apr 30, 2013
70931c4
Fixed documentation issues
JackStat May 1, 2013
1a764ec
accepting Damon's additions
JackStat May 1, 2013
45d4716
updated documentation
JackStat May 1, 2013
07f2c72
added Katie's f.models function
JackStat May 1, 2013
c52b328
Update pois.rate.R
KatieDodds May 1, 2013
da18484
Added Katie's cross validation score function
JackStat May 1, 2013
7814519
Update anneal.R
cispy May 1, 2013
dc81c3f
Merge branch 'master' of https://github.com/JackStat/CompPack
JackStat May 1, 2013
676b0c1
Merge branch 'master' of https://github.com/JackStat/CompPack
JackStat May 1, 2013
3b79751
Merge pull request #10 from JackStat/master
dcaff May 1, 2013
ec26c64
renamed function
JackStat May 1, 2013
f7e8c4f
added in katie's function
JackStat May 1, 2013
31869e2
Merge pull request #16 from dcaff/master
JackStat May 1, 2013
080b279
cispy's functions
dcaff May 1, 2013
246b4ce
Merge pull request #11 from JackStat/master
dcaff May 1, 2013
74cfcf1
Merge pull request #17 from dcaff/master
JackStat May 1, 2013
6ab6caa
Accepted Ernest's new functions/tweaked documentation
JackStat May 1, 2013
f1c381e
Update twodranduphill.R
cispy May 1, 2013
65caa41
Update anneal.R
cispy May 1, 2013
7556c1c
Update anneal.R
cispy May 1, 2013
747268e
Update cvscore.R
KatieDodds May 1, 2013
1993c5b
Update twodfunction.R
cispy May 1, 2013
f82ba20
Update cvscore1.R
KatieDodds May 1, 2013
575a804
Update cvscore2.R
KatieDodds May 1, 2013
618b9c6
Update cvscore3.R
KatieDodds May 1, 2013
1abffdc
initialized econdata documentation
JackStat May 1, 2013
8335406
Update cvscore4.R
KatieDodds May 1, 2013
7c6d587
Update cvscore5.R
KatieDodds May 1, 2013
84a2696
Merge branch 'master' of https://github.com/JackStat/CompPack
JackStat May 1, 2013
0136665
Update onedfunction.R
cispy May 1, 2013
67d5a4f
Update anneal.R
cispy May 1, 2013
9a1bfa4
lowered case
JackStat May 1, 2013
b82b9e5
Update twodranduphill.R
cispy May 1, 2013
9163aeb
Changed documentation for econdata
JackStat May 1, 2013
cd5447e
Merge branch 'master' of https://github.com/JackStat/CompPack
JackStat May 1, 2013
85274cf
Accepted Documentation changes
JackStat May 1, 2013
8b0934f
Update twodfunction.R
cispy May 1, 2013
a3d071d
Update twodranduphill.R
cispy May 1, 2013
cc34fdd
Update twodranduphill.R
cispy May 1, 2013
497d2bb
shortened examples
JackStat May 1, 2013
4788fce
accepting Ernest's updated examples
JackStat May 1, 2013
f109bd4
removed econdata
JackStat May 1, 2013
52c80c1
Added all of the authors
JackStat May 1, 2013
89e70de
tweaking description
JackStat May 1, 2013
bdce6bb
fixed author field
JackStat May 1, 2013
cc28648
Author tweak 10001
JackStat May 1, 2013
cde9cd9
author tweak 10002
JackStat May 1, 2013
d86166b
changed name to polar.rnorm
JackStat May 1, 2013
63529d3
lowered case
JackStat May 1, 2013
d640ada
removed bootstrap
JackStat May 1, 2013
7f1745e
added bootstrap back in
JackStat May 1, 2013
a192a9b
Deleted bootstrap
JackStat May 1, 2013
e4577d5
d
JackStat May 1, 2013
69beaa0
updated description
JackStat May 1, 2013
325950f
h
JackStat May 1, 2013
f36c5d3
adding in bootstrap
JackStat May 1, 2013
8944f25
Added main help file
JackStat May 13, 2013
7415a69
formatting
JackStat May 13, 2013
ebc563d
formatting emails
JackStat May 13, 2013
1d414c3
add travis
JackStat May 5, 2015
b9592dd
add travis
JackStat May 5, 2015
008d1c3
copy travis from wickham
JackStat May 5, 2015
6290d06
Update README.md
JackStat May 5, 2015
24e5449
simplify travis
JackStat May 6, 2015
5ad9d27
simplify travis
JackStat May 6, 2015
7a12499
add coveralls to travis
JackStat May 6, 2015
8d4c20a
add coveralls to travis
JackStat May 6, 2015
77607be
add coveralls to travis
JackStat May 6, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: r
sudo: required

r_github_packages:
- ./travis-tool.sh github_package jimhester/covr

after_success:
- Rscript -e 'library(covr);coveralls()'

13 changes: 13 additions & 0 deletions CompPack/CompPack.Rproj
Original file line number Diff line number Diff line change
@@ -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
Empty file added CompPack/debug.log
Empty file.
34 changes: 29 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,52 @@ Type: Package
Title: Collection of Computational Statistic Tools
Version: 1.0
Date: 2013-04-10
Author: Tyler Hunt
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 <tyler@psychoanalytix.com>
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'
'pois.proc.R'
'nearest.R'
'around.R'
'nearest.loc.R'
'bootstrap.R'
23 changes: 23 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
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)
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)
1 change: 1 addition & 0 deletions R/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rand.norm.R
42 changes: 42 additions & 0 deletions R/anneal.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#' uphill search on fucntion
#'
#' @description
#' General anneal function, where we conduct a uphill search on the function to find maximum
#'
#' @param f function 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
#'
#' @examples
#' anneal(onedfunction, 2, 100, 1, 10, .99)
#' @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)
}
12 changes: 10 additions & 2 deletions R/around.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
#'
#' @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}
#' @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)
Expand Down
24 changes: 24 additions & 0 deletions R/bootstrap.R
Original file line number Diff line number Diff line change
@@ -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)
}
96 changes: 96 additions & 0 deletions R/cvscore.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#' 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.
#'
#' @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)
}
34 changes: 34 additions & 0 deletions R/cvscore1.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#' 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.
#'
#' @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)
}
33 changes: 33 additions & 0 deletions R/cvscore2.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#' 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.
#'
#' @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)
}
Loading