0

(reproducible example added)
I tried to code the AR(1) model Yt=0.6Yt-1+Vt (Vt ~ N(0,1)).

# Function that makes (mean,sd) of a sample drawn from population exactly 
# same with those of the population
rnorm2 <- function(n,mean,sd) { mean + sd*scale(rnorm(n)) } 

N <- 1388; ro <- 0.6; a <- 0
set.seed(1)
v <- ts(rnorm2(N,0,1)) # white noise, v~N(0,1)
c(mean(v),sd(v)) # 1.160729e-17 = 0; 1.000000e+00 = 1
y <- ts(rep(0,N))  # y[1]:=0 defined    
for (t in 2:N){  y[t] <- a + ro*y[t-1]+v[t] }

After arranging rnorm function in the desired way as rnorm2 as above, I expected to obtain the mean and standard deviation of y as follows:

Mean(Yt) = alfa/(1-ρ)

a/(1-ro) # 0

StdDev(Yt)=sqrt[sd(v)2/(1-ρ2)]

sqrt(sd(v)^2/(1-(0.6)^2)) # 1.25

But, I get:

c(mean(y),sd(y)) # 0.002486451 1.227402426

Why are those mean and standard deviation different (0.002486451<>0; 1.227402426<>1.25)?

Erdogan CEVHER
  • 1,788
  • 1
  • 21
  • 40
  • That's like... The entire reason the field of statistics exists... – Dason Aug 03 '19 at 22:49
  • You took a random sample. Do you expect it to perfectly match the expected values? – Dason Aug 03 '19 at 22:51
  • @Dason, I took random v (white noise), and its mean is exactly same with that of the population it was drawn (`mean(v)=0`!). Hence, just as the exact equivalence of `c(mean(v),sd(v))` with its population, I expect `c(mean(y),sd(y))` to be same. – Erdogan CEVHER Aug 03 '19 at 22:54
  • @Dason, If I hadn't defined `rnorm2`, your reasoning would be valid: `set.seed(1); c(mean(ts(rnorm(1388,mean=0,sd=1))), sd(ts(rnorm(1388,mean=0,sd=1)))) # [1] -0.01590441<>0 1.03055089<>1. ` – Erdogan CEVHER Aug 03 '19 at 23:21
  • 1
    Ok but your reasoning is still flawed. Just because the expected value is 0 didn't mean the finite sample mean will be 0. Take generating two values. Ignore the standard deviation. Say to get mean 0 we use -1 and 1. Then your values for y will be 0, 0+.6*0+ -1= -1, 0 + .6*(-1) +1 = .4. so you have 0, -1, .4. Those don't have a sample mean of 0. Your process won't give 0 as the mean by default. – Dason Aug 04 '19 at 01:50
  • @Dason, Many many thanks for your clear concrete example. You can write it as an answer. I got your logic. – Erdogan CEVHER Aug 04 '19 at 07:55

0 Answers0