`xor` function in R -
i'm trying work through code in bootstrap simulation on this post 2 major hurdles. first, few times have played bootstrapping, have done without using {boot}
package, , relying on functions replicate
, or loops. , second, , main object of question, don't know function xor
takes in inputs, , does:
n <- 1000 dat <- c("a", rep("b", n-1)) indicator <- function(x, ndx) xor("a"%in%x[ndx], true)
i see assesses whether "a"
in x
, returns false
if in it. issue comes input ndx
. stands "index", , connected bootstrapping follows:
p_hat <- function(dat, m=1e3){ foo <- boot(data=dat, statistic=indicator, r=m) 1/mean(foo$t) } reps <- replicate(100, p_hat(dat))
but how? in last chunk of code feeds ndx
in first chunk?
Comments
Post a Comment