extracting stuff from bootstrap object

113 views
Skip to first unread message

Kery Marc

unread,
Jun 6, 2013, 11:38:24 AM6/6/13
to unma...@googlegroups.com
Hello everyone,

I want to fit Nmix models using pcount() to lots of individual data sets, do a parametric bootstrap GOF test in each case and save the bootstrapped p-value. How can I do this ?

Typing the name of the object created with an unmarked bootstrap, say, pb, yields as part of the output this:

Parametric Bootstrap Statistics:
               t0 mean(t0 - t_B) StdDev(t0 - t_B) Pr(t_B > t0)
SSE          2154           1488             87.2       0.0000

I used str(pb) to see where I can get the value of, here, 0.000 for saving, but couldn't find it. I then tried to inspect the code for the function, but typing "parboot" or "unmarked::parboot" did not help either.

Thanks for your help.

Kind regards  -  Marc

Richard Schuster

unread,
Jun 6, 2013, 12:36:57 PM6/6/13
to unma...@googlegroups.com
Hi Marc,

Below a function I use to extract parboot results. Slight modifications would allow you to get what you want.

Cheers,
Richard

The function call is e.g.:
AMROb <- parboot (AMRO, nsim = 1000)
save.parboot (AMROb,"AMRO")


save.parboot <- function(object, species = NULL){

ᅵᅵᅵ # save.parboot: a function for saving parboot outputs
ᅵᅵᅵ # Author: Richard Schuster (ma...@richard-schuster.com
ᅵᅵᅵ # 16 April 2012


ᅵ #Fields to put into the dataframe
ᅵ #t0ᅵᅵ mean(tB)ᅵ StdDev(tB)ᅵ mean(t0-tB) StdDev(t0-tB) Pr(tB > t0) nsim
ᅵᅵᅵ t.star <- obj...@t.star
ᅵᅵᅵ t0 <- object@t0
ᅵᅵᅵ nsim <- nrow(t.star)


ᅵᅵᅵ biasMat <- pMat <- matrix(NA, nsim, length(t0))
ᅵᅵᅵ for(i in 1:nsim) {
ᅵᅵᅵᅵᅵᅵᅵ biasMat[i,] <- t0 - t.star[i,]
ᅵᅵᅵᅵᅵᅵᅵ pMat[i,] <- abs(t.star[i,] - 1) > abs(t0 - 1)
ᅵᅵᅵᅵᅵᅵᅵ }
ᅵᅵᅵ mean.tB <- mean(t.star)
ᅵᅵᅵ tB.se <- apply(t.star, 2, sd)
ᅵᅵᅵ bias <- colMeans(biasMat)
ᅵᅵᅵ bias.se <- apply(biasMat, 2, sd)
ᅵᅵᅵ p.val <- colSums(pMat) / (1 + nsim)
ᅵᅵᅵ stats <- data.frame("species" = species, "t0" = t0, "mean(tB)" = mean.tB, "StdDev(tB)" = tB.se, "mean(t0 - t_B)" = bias,
ᅵᅵᅵᅵᅵᅵᅵ "StdDev(t0 - t_B)" = bias.se, "Pr(t_B > t0)" = p.val, "nsim" = nsim,
ᅵᅵᅵᅵᅵᅵᅵ check.names = FALSE)
ᅵᅵᅵ write.table(stats,append=T, "D://R_files/12_10_05_Birds_100m_resolved/parboot/parboot.csv", col.names=F)
}

Am 06/06/2013 08:38, schrieb Kery Marc:
Hello everyone,

I want to fit Nmix models using pcount() to lots of individual data sets, do a parametric bootstrap GOF test in each case and save the bootstrapped p-value. How can I do this ?

Typing the name of the object created with an unmarked bootstrap, say, pb, yields as part of the output this:

Parametric Bootstrap Statistics:
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ t0 mean(t0 - t_B) StdDev(t0 - t_B) Pr(t_B > t0)
SSEᅵᅵᅵᅵᅵᅵᅵᅵᅵ 2154ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ 1488ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵ 87.2ᅵᅵᅵᅵᅵᅵ 0.0000

I used str(pb) to see where I can get the value of, here, 0.000 for saving, but couldn't find it. I then tried to inspect the code for the function, but typing "parboot" or "unmarked::parboot" did not help either.

Thanks for your help.

Kind regardsᅵ -ᅵ Marc
--
You received this message because you are subscribed to the Google Groups "unmarked" group.
To unsubscribe from this group and stop receiving emails from it, send an email to unmarked+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
ᅵ
ᅵ

Richard Schuster

unread,
Jun 6, 2013, 12:38:57 PM6/6/13
to unma...@googlegroups.com
Looks like there is a formatting error, which is why I attached the script


save.parboot.12.10.10.r

Kery Marc

unread,
Jun 7, 2013, 3:41:30 AM6/7/13
to unma...@googlegroups.com

Hi Richard,

 

that is great: thanks a lot !

 

Kind regards  --  Marc

Reply all
Reply to author
Forward
0 new messages