From: Christian Hennig <chrish_at_stats.ucl.ac.uk>

Date: Wed 28 Jun 2006 - 03:42:02 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jun 28 03:52:34 2006

Date: Wed 28 Jun 2006 - 03:42:02 EST

See below the code and the results.

Did I do something wrong or are the numbers in
fact negatively correlated? (A type I error is quite unlikely with a
p-value below 2.2e-16.)

Best,

Christian

set.seed(123456)

n <- 100

p <- 0.5

simruns <- 10000

est <- est11 <- numeric(0)

for (i in 1:simruns){

# if (i/100==round(i/100)) print(i)

x <- rbinom(n,1,p) est[i] <- mean(x) x11 <- 3*x[2:n]-x[1:(n-1)] est11[i] <- sum(x11==2)/sum(x11==2 | x11==(-1)) # x11==(-1): 0 follows 1, x11==2: 1 follows 1.}

> print(mean(est))

[1] 0.499554

> print(sd(est)/sqrt(simruns))

[1] 0.0004958232

# OK

> print(mean(est11))

[1] 0.4935211

> print(sd(est11)/sqrt(simruns))

[1] 0.0007136213

# mean(est11)+2*sd(mean) < 0.495

> print(sum(est>est11))

[1] 5575

> binom.test(5575,10000)

Exact binomial test

data: 5575 and 10000

number of successes = 5575, number of trials = 10000, p-value <
2.2e-16

- --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
chrish@stats.ucl.ac.uk, www.homepages.ucl.ac.uk/~ucakche

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jun 28 03:52:34 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Wed 28 Jun 2006 - 06:12:39 EST.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*