set.seed(10) x_runif(16) x hist(x) chisq.gof(x,dist="uniform") x.chi1_chisq.gof(x,dist="uniform") x.chi1$c x.chi1$e x.chi1 (x.chi1$c-x.chi1$e)^2/x.chi1$e sum((x.chi1$c-x.chi1$e)^2/x.chi1$e) 1-pchisq(sum((x.chi1$c-x.chi1$e)^2/x.chi1$e),6) x.chi1$c x.chi1$e (x.chi1$c-x.chi1$e)^2/x.chi1$e sum((x.chi1$c-x.chi1$e)^2/x.chi1$e) 1-pchisq(sum((x.chi1$c-x.chi1$e)^2/x.chi1$e),6) 2*16^(2/5) x.chi1$s x.chi1_chisq.gof(x,n.classes=3,dist="uniform") x.chi1 x.chi1$c x.chi1$e x_rnorm(50) x y_rexp(60,3) y summary(y) par(mfrow=c(1,2)) hist(x) hist(y) cdf.compare(x,distr="norm") cdf.compare(x,distr="norm",mean=mean(x),sd=sqrt(var(x))) mean(x) var(x) cdf.compare(y,distr="norm",mean=mean(y),sd=sqrt(var(y))) cdf.compare(x,y) cdf.compare(y,distr="exp",rate=3) qqnorm(y) qqline(y) qqnorm(x) qqline(x) chisq.gof(y,dist="norm",mean=1/3,sd=1/3) chisq.gof(y,dist="norm",mean=0,sd=1) chisq.gof(x,dist="norm") chisq.gof(x,dist="norm",mean=0,sd=1) chisq.gof(x,dist="norm",mean=1/3,sd=1/3) chisq.gof(x,dist="norm",n.param.est=2) chisq.gof(x,dist="norm",n.param.est=2,mean=mean(x),sd=sqrt(var(x))) mean(x) var(x) x.chi1_chisq.gof(x,dist="norm") x.chi1$c x.chi1$e x.chi1_chisq.gof(x,dist="norm",n.param.est=2) x.chi1$c x.chi1$e cut1_(-3:3) cut1 x.chi1_chisq.gof(x,cut.points=cut1,dist="norm") x.chi1 x.chi1$c x.chi1$e cut3_c(min(x)-0.1,seq(-1.5,1.5,by=.5),max(x)+0.1) cut3 x.chi3_chisq.gof(x,cut.points=cut3,dist="norm") x.chi3$c x.chi3$e x.chi3 sum(x.chi3$e) cut3_c(min(x)-10,seq(-1.5,1.5,by=.5),max(x)+10) x.chi3_chisq.gof(x,cut.points=cut3,dist="norm") x.chi3 x.chi3$e x.chi3$c sum(x.chi3$e) ks.gof(x,dist="norm") ks.gof(x,dist="norm",mean=0,sd=1) x_rbinom(20,size=5,prob=1/2) x table(x) x_rbinom(20,size=5,prob=1/2) table(x) x_rbinom(20,size=5,prob=1/2) table(x) chisq.gof(x,dist="binom",size=5,prob=1/2) cut_quantile(x) table(cut(x,cut)) chisq.gof(x,cut.points=cut,dist="binom",size=5,prob=1/2) cut[1]_cut[1]-1 cut[4]_cut[4]+1 cut[5]_cut[5]+1 cut table(cut(x,cut)) cut_c(-0.5:5.5,1) cut cut_c(-0.5:5.5) table(cut(x,cut)) chisq.gof(x,cut.points=cut,dist="binom",size=5,prob=1/2) chisq.gof(x,cut.points=cut,dist="binom",size=5,prob=1/2)$e cut_c(-0.5,1.5:3.5,5.5) chisq.gof(x,cut.points=cut,dist="binom",size=5,prob=1/2) chisq.gof(x,cut.points=cut,dist="binom",size=5,prob=1/2)$e x_rep(0:7,c(89,143,94,42,20,8,3,1)) x table(x) cut_c(0:7) table(cut(x,cut)) cut_c(-1:7) table(cut(x,cut)) chisq.gof(x,cut.points=cut,n.param.est=1,dist="pois",lambda=mean(x))$e chisq.gof(x,cut.points=cut,n.param.est=1,dist="pois",lambda=mean(x))$c cut_c(-1:4,7) table(cut(x,cut)) chisq.gof(x,cut.points=cut,n.param.est=1,dist="pois",lambda=mean(x))$e chisq.gof(x,cut.points=cut,n.param.est=1,dist="pois",lambda=mean(x)) sum(chisq.gof(x,cut.points=cut,n.param.est=1,dist="pois",lambda=mean(x))$e)