Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions R/em.mixnorm.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#'
#' @author Tyler Hunt \email{tyler@@psychoanalytix.com}
#' @export

em.mixnorm <-
function (x,k){
p = rep(1/k,k)
Expand Down
37 changes: 37 additions & 0 deletions R/jackknife.R
Original file line number Diff line number Diff line change
@@ -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)
}