Skip to content

Commit

Permalink
version 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
youhuachen authored and cran-robot committed Nov 20, 2018
1 parent 4d66090 commit 6a9ab90
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: RSE
Type: Package
Title: Number of Newly Discovered Rare Species Estimation
Version: 1.2
Date: 2018-10-15
Version: 1.3
Date: 2018-11-03
Author: Youhua Chen,Tsung-Jen Shen
Maintainer: Youhua Chen <haydi@126.com>
Description: A Bayesian-weighted estimator and two unweighted estimators are
Expand All @@ -17,6 +17,6 @@ Description: A Bayesian-weighted estimator and two unweighted estimators are
License: GPL-3
RoxygenNote: 6.1.0
NeedsCompilation: no
Packaged: 2018-10-15 14:47:37 UTC; Adminstrator
Packaged: 2018-11-03 02:27:39 UTC; Adminstrator
Repository: CRAN
Date/Publication: 2018-10-19 15:30:07 UTC
Date/Publication: 2018-11-20 05:40:03 UTC
6 changes: 3 additions & 3 deletions MD5
@@ -1,7 +1,7 @@
7d6de3f60f1495ead9fdfae85df3a4c4 *DESCRIPTION
374686c0be483775c2824f61143a4507 *DESCRIPTION
4cd72b2ff08731d85191b0ee0aa8a953 *NAMESPACE
56de3ebf0ea7ed8d056700fec4fd3039 *R/RSE.R
a6772b89bf5e00582977876bbd14f5c5 *build/partial.rdb
2c85d5ce003a6e5d24e9908a442a2eef *R/RSE.R
d46c411a48225bec1d6a0cbd759de75b *build/partial.rdb
fd073cde37982461bc3bbfdf92142528 *data/CanadaMite.rdata
431a77b0a775700087ee1924b1fd0937 *data/HerpetologicalData.rdata
66969de94aa6f93d5780521314d7f650 *man/CanadaMite.Rd
Expand Down
25 changes: 14 additions & 11 deletions R/RSE.R
Expand Up @@ -118,14 +118,13 @@ Pred.Fk.BW = function(f,m,b,k.show=3){
d = ind/n*(1-b[1]*exp(-b[2]*ind))

for(i in 1:k.show){## i for k
for(j in 1:min(i,kmax)){## j for q
tmp = prod(1+n/(m-(0:(i-1))))
for(j in 1:min(i,kmax)){## j for q
# est.f[i] = est.f[i] +
# f[j]*choose(m,i)/(choose(m+n,i)-choose(m,i))*
# dbinom(i-j,m,d[j]);

tmp = prod(1+n/(m-(0:(i-1))))
est.f[i] = est.f[i] +
f[j]*1/(tmp-1)*dbinom(i-j,m,d[j]);

est.f[i] = est.f[i]+f[j]*1/(tmp-1)*dbinom(i-j,m,d[j]);
}
}

Expand Down Expand Up @@ -188,7 +187,10 @@ Pred.Fk.unweighted = function(f,m,b,f0, k.show=3){
f1 = f[1]
f2 = f[2]
}
d0 = f1 / n * ((n-1)*f1 / ((n-1)*f1 + 2*max(f2,1)))/f0
if(f0>0) {d0 = f1 / n * ((n-1)*f1 / ((n-1)*f1 + 2*max(f2,1)))/f0
} else {
d0=0
}


### relative abundance estimation by Chao et al. (2015)
Expand All @@ -201,7 +203,8 @@ Pred.Fk.unweighted = function(f,m,b,f0, k.show=3){
# );
# est.f[k] = est.f[k] + choose(m,k)*f0*d0^k*(1-d0)^(n+m-k)

est.f[k] = sum(f*dbinom(k,m,d)*(1-d)^n)+f0*dbinom(k,m,d0)*(1-d0)^n;
est.f[k] = sum(f*dbinom(k,m,d)*(1-d)^n)
if(f0>0) est.f[k] = est.f[k]+f0*dbinom(k,m,d0)*(1-d0)^n;
}# loop: k

return(est.f)
Expand Down Expand Up @@ -255,10 +258,9 @@ Pred.abundance.rare = function(boot.rep = 100,f=NULL,xi=NULL,m,k.show = 3){
b.pred.fk.BW = Pred.Fk.BW(b.f, m, b=b.a.p.1)

b.pred.fk.unweighted = Pred.Fk.unweighted(b.f, m, b=b.a.p.1, b.est.f0)

boot.output = rbind(boot.output,c(proposed=b.pred.fk.BW[1:k.show], naive=b.naive[1:k.show], unweighted=b.pred.fk.unweighted[1:k.show]))
}### loop: boot.rep

point.est = cbind(proposed=est.R,naive=est.Naive,unweighted=est.R2)
boot.sd = apply(boot.output, 2, sd, na.rm=T)
boot.sd = matrix(boot.sd, ncol=3)
Expand Down Expand Up @@ -346,7 +348,7 @@ Pred.Qk.unweighted = function(Q,nT,u,b,Q0,k.show = 3){
f1 = f[1]
f2 = f[2]
}
d0 = f1 / n * ((n-1)*f1 / ((n-1)*f1 + 2*max(f2,1)))/Q0
if(Q0>0) d0 = f1 / n * ((n-1)*f1 / ((n-1)*f1 + 2*max(f2,1)))/f0

### relative abundance estimation by Chao et al. (2015)
ind = 1:kmax
Expand All @@ -356,7 +358,8 @@ Pred.Qk.unweighted = function(Q,nT,u,b,Q0,k.show = 3){
# est.f[k] = choose(m,k)*sum(f*d^k*(1-d)^(n+m-k));
# est.f[k] = est.f[k] + choose(m,k)*f0*d0^k*(1-d0)^(n+m-k)

est.f[k] = sum(f*dbinom(k,m,d)*(1-d)^n)+f0*dbinom(k,m,d0)*(1-d0)^n;
est.f[k] = sum(f*dbinom(k,m,d)*(1-d)^n)
if(f0>0) est.f[k] = est.f[k]+f0*dbinom(k,m,d0)*(1-d0)^n;
}# loop: k

return(est.f)
Expand Down
Binary file modified build/partial.rdb
Binary file not shown.

0 comments on commit 6a9ab90

Please sign in to comment.