Open JeffreyRacine opened 7 years ago
Avar should be p(x)(1-p(x))/n
set.seed(42) n <- 100 X <- sort(rbinom(n,2,0.4)) p <- as.numeric(prop.table(table(X))) Avar.p <- p*(1-p)/n
require(np)
model <- npudens(~factor(X),bws=0,ukertype="aitchisonaitken") p.hat <- unique(fitted(model)) Avar.p.hat <- unique(se(model))**2
cbind(p,Avar.p,p.hat,Avar.p.hat,p.hat/n)
Note that npudens is returning p.hat/n for the variance in this case but it ought to be p.hat*(1-p.hat)/n
Avar should be p(x)(1-p(x))/n
set.seed(42) n <- 100 X <- sort(rbinom(n,2,0.4)) p <- as.numeric(prop.table(table(X))) Avar.p <- p*(1-p)/n
require(np)
model <- npudens(~factor(X),bws=0,ukertype="aitchisonaitken") p.hat <- unique(fitted(model)) Avar.p.hat <- unique(se(model))**2
cbind(p,Avar.p,p.hat,Avar.p.hat,p.hat/n)
Note that npudens is returning p.hat/n for the variance in this case but it ought to be p.hat*(1-p.hat)/n