Skip to content

Commit

Permalink
Moved trimcibt() to unmaintained status.
Browse files Browse the repository at this point in the history
  • Loading branch information
joefowler committed Feb 8, 2017
1 parent d6b3f6c commit 9637fe6
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 117 deletions.
19 changes: 0 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,25 +268,6 @@ Compute a (1-α) confidence interval for a trimmed mean by bootstrap methods.
p value: 0.086000




####30. `trimcibt()`
Compute a (1-α) confidence interval for the trimmed mean using a bootstrap percentile t method. The default amount of trimming is tr=.2. side=true, indicates the symmetric two-sided method. side=false yields an equal-tailed confidence interval. NOTE: p.value is reported when side=true only.

julia> trimcibt(x, nboot=5000, plotit=true)
Bootstrap .95 confidence interval for the trimmed mean
using a bootstrap percentile t method

Estimate: 1.292180
Statistic: 3.469611
Confidence interval: 0.292162 2.292199
p value: 0.022600

![plot](http://imageshack.us/a/img844/1970/34o.png)




#### `pcorb`
Compute a .95 confidence interval for Pearson's correlation coefficient. This function uses an adjusted percentile bootstrap method that gives good results when the error term is heteroscedastic.

Expand Down
13 changes: 13 additions & 0 deletions UNMAINTAINED.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,16 @@ Two examples are shown below to demonstrate the two ways of specifying data:
Degrees of freedom: 2.00 8.11
Statistic: 28.990510
p value: 0.000202


#### `trimcibt`
Compute a (1-α) confidence interval for the trimmed mean using a bootstrap percentile t method. The default amount of trimming is tr=.2. side=true, indicates the symmetric two-sided method. side=false yields an equal-tailed confidence interval. NOTE: p.value is reported when side=true only.

julia> trimcibt(x, nboot=5000)
Bootstrap .95 confidence interval for the trimmed mean
using a bootstrap percentile t method

Estimate: 1.292180
Statistic: 3.469611
Confidence interval: 0.292162 2.292199
p value: 0.022600
3 changes: 0 additions & 3 deletions src/RobustStats.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ export
trimpb,
pcorb,
yuend,

trimcibt,

bisquareWM,
huberWM,
trimean,
Expand Down
64 changes: 0 additions & 64 deletions src/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -685,70 +685,6 @@ end



# Compute a (1-α) confidence interval for the trimmed mean
# using a bootstrap percentile t method.
#
# The default amount of trimming is tr=.2
# side=T, for true, indicates the symmetric two-sided method
#
#
# Side=F yields an equal-tailed confidence interval
#
#
# NOTE: p.value is reported when side=T only.
#

function trimcibt{S <: Real}(x::AbstractArray{S}; tr::Real=0.2, alpha::Real=0.05, nboot::Integer=2000, side::Bool=true,
nullvalue::Real=0, seed=2, method::Bool=true)
if isa(seed, Bool)
if seed
srand(2)
end
else
srand(seed)
end
n=length(x)
test=(tmean(x, tr=tr)-nullval)./trimse(x, tr=tr)
randid=rand(1:n, n*nboot)
tempout=trimcibt_loop(x, n, nboot, tr, side, randid, test)
if side
tval=tempout[1]
pval=tempout[2]
end
icrit=floor((1-alpha)*nboot+0.5)
ibot=round(alpha*nboot/2)+1
itop=nboot-ibot-1
ci=zeros(2)
if method && side
METHOD="Bootstrap (1-α) confidence interval for the trimmed mean\nusing a bootstrap percentile t method\n"
elseif method && !side
METHOD="Bootstrap (1-α) confidence interval for the trimmed mean\nusing a bootstrap percentile t method\n[NOTE: p value is computed only when side=true]\n"
else
METHOD=nothing
end
if !side
ci[1]=tmean(x, tr=tr)-tempout[itop]*trimse(x, tr=tr)
ci[2]=tmean(x, tr=tr)-tempout[ibot]*trimse(x, tr=tr)
output = testOutput()
output.method = METHOD
output.estimate = tmean(x, tr=tr)
output.ci = ci
output.statistic = test
return output
else
ci[1]=tmean(x, tr=tr)-tval[icrit]*trimse(x, tr=tr)
ci[2]=tmean(x, tr=tr)+tval[icrit]*trimse(x, tr=tr)
output = testOutput()
output.method = METHOD
output.estimate = tmean(x, tr=tr)
output.ci = ci
output.statistic = test
output.p = pval
return output
end
end


"""`procb(x, y; seed=2)`
Compute a (1-α) confidence interval for Pearson's correlation coefficient.
Expand Down
95 changes: 95 additions & 0 deletions src/unmaintained.jl
Original file line number Diff line number Diff line change
Expand Up @@ -677,3 +677,98 @@ function t1waycore(args...)
output.method = METHOD
output
end


# Compute a (1-α) confidence interval for the trimmed mean
# using a bootstrap percentile t method.
#
# The default amount of trimming is tr=.2
# side=T, for true, indicates the symmetric two-sided method
#
#
# Side=F yields an equal-tailed confidence interval
#
#
# NOTE: p.value is reported when side=T only.
#

function trimcibt{S <: Real}(x::AbstractArray{S}; tr::Real=0.2, alpha::Real=0.05, nboot::Integer=2000, side::Bool=true,
nullvalue::Real=0, seed=2, method::Bool=true)
if isa(seed, Bool)
if seed
srand(2)
end
else
srand(seed)
end
n=length(x)
test=(tmean(x, tr=tr)-nullval)./trimse(x, tr=tr)
randid=rand(1:n, n*nboot)
tempout=trimcibt_loop(x, n, nboot, tr, side, randid, test)
if side
tval=tempout[1]
pval=tempout[2]
end
icrit=floor((1-alpha)*nboot+0.5)
ibot=round(alpha*nboot/2)+1
itop=nboot-ibot-1
ci=zeros(2)
if method && side
METHOD="Bootstrap (1-α) confidence interval for the trimmed mean\nusing a bootstrap percentile t method\n"
elseif method && !side
METHOD="Bootstrap (1-α) confidence interval for the trimmed mean\nusing a bootstrap percentile t method\n[NOTE: p value is computed only when side=true]\n"
else
METHOD=nothing
end
if !side
ci[1]=tmean(x, tr=tr)-tempout[itop]*trimse(x, tr=tr)
ci[2]=tmean(x, tr=tr)-tempout[ibot]*trimse(x, tr=tr)
output = testOutput()
output.method = METHOD
output.estimate = tmean(x, tr=tr)
output.ci = ci
output.statistic = test
return output
else
ci[1]=tmean(x, tr=tr)-tval[icrit]*trimse(x, tr=tr)
ci[2]=tmean(x, tr=tr)+tval[icrit]*trimse(x, tr=tr)
output = testOutput()
output.method = METHOD
output.estimate = tmean(x, tr=tr)
output.ci = ci
output.statistic = test
output.p = pval
return output
end
end


function trimcibt_loop(x, n, nboot, tr, side, randid, test)
xbar=tmean(x, tr=tr)
temp=zeros(n)
tval=zeros(nboot)
if side
test=abs(test)
pval=0.0
for i=1:(nboot*n)
if (i%n)!=0
temp[i%n]=x[randid[i]]-xbar
else
temp[n]=x[randid[i]]-xbar
tval[div(i, n)]=abs(tmean(temp, tr=tr)./trimse(temp, tr=tr))
pval += tval[div(i, n)]>=test? 1/nboot :0.0
end
end
return sort!(tval), pval
else
for i=1:(nboot*n)
if (i%n)!=0
temp[i%n]=x[randid[i]]-xbar
else
temp[n]=x[randid[i]]-xbar
tval[div(i, n)]=tmean(temp, tr=tr)./trimse(temp, tr=tr)
end
end
return sort!(tval)
end
end
31 changes: 0 additions & 31 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,3 @@ function duplicated(x::AbstractArray)
end
false
end


function trimcibt_loop(x, n, nboot, tr, side, randid, test)
xbar=tmean(x, tr=tr)
temp=zeros(n)
tval=zeros(nboot)
if side
test=abs(test)
pval=0.0
for i=1:(nboot*n)
if (i%n)!=0
temp[i%n]=x[randid[i]]-xbar
else
temp[n]=x[randid[i]]-xbar
tval[div(i, n)]=abs(tmean(temp, tr=tr)./trimse(temp, tr=tr))
pval += tval[div(i, n)]>=test? 1/nboot :0.0
end
end
return sort!(tval), pval
else
for i=1:(nboot*n)
if (i%n)!=0
temp[i%n]=x[randid[i]]-xbar
else
temp[n]=x[randid[i]]-xbar
tval[div(i, n)]=tmean(temp, tr=tr)./trimse(temp, tr=tr)
end
end
return sort!(tval)
end
end

0 comments on commit 9637fe6

Please sign in to comment.