Capítulo 11 Teoria Assintotica dos Estimadores de MQO
11.1 Consistência de MQO
= function(n){
f = rnorm(n,10,15)
x1 = rnorm(n,0,50)
e = 10 + 5*x1 + e
y = cbind(1,x1)
X = solve(t(X)%*%X)%*%t(X)%*%y
beta
beta }
f(10)
## [,1]
## 3.562267
## x1 4.865959
for (i in c(5,50,100,1000)){
= replicate(n = 100, expr = f(i))
x print(mean(x[2, 1, ]))
}
## [1] 4.927486
## [1] 4.943381
## [1] 5.021904
## [1] 4.993664
par(mfrow = c(2, 2))
for (i in c(5,50,100,1000)){
= replicate(n = 100, expr = f(i))
x plot(density( x[2, 1, ]), xlim = c(0,10))
abline(v=5)
}
par(mfrow = c(2, 2))
for (i in c(1000,5000,10000,100000)){
= replicate(n = 100, expr = f(i))
x plot(density( x[2, 1, ]), xlim = c(0,10))
abline(v=5)
}
11.2 Normalidade Assintótica
Distribuição Uniforme
Mostrar a distribuição do termo de erro
= 10000
N = 5 beta
= 1000
n = runif(n, min = 0, max = 100)
x = runif(n = n, min = -10, max = 10)
e = cbind(1,x)
X = 10 + beta * x + e
y = solve(t(X)%*%X)%*%t(X)%*%y
B = y - X%*%B
e_hat
hist(e_hat)
= function(n){
f = runif(n, min = 0, max = 100)
x = runif(n = n, min = -10, max = 10)
e = cbind(1,x)
X = 10 + beta * x + e
y = solve(t(X)%*%X)%*%t(X)%*%y
B
B }
par(mfrow = c(2, 2))
for (i in c(10,50,100,1000)){
= replicate(n = N, expr = f(i))
x = (var(x[2,1,]) * i)
var = sqrt(i) *( (x[2, 1, ] - beta)) / sqrt(var)
z plot(density(z), xlim = c(-4,4))
curve(dnorm(x,0,1), col = "red", xlim = c(-4,4), add = TRUE)
}
Distribuição Poison
Mostrar a distribuição do termo de erro
= 10000
N = 5 beta
= 1000
n = runif(n, min = 0, max = 100)
x = rpois(n = n, lambda = 1 ) - 1
e = cbind(1,x)
X = 10 + beta * x + e
y = solve(t(X)%*%X)%*%t(X)%*%y
B = y - X%*%B
e_hat
hist(e_hat)
= function(n){
f = runif(n, min = 0, max = 100)
x = rpois(n = n, lambda = 1 ) - 1
e = cbind(1,x)
X = 10 + beta * x + e
y = solve(t(X)%*%X)%*%t(X)%*%y
B
B }
par(mfrow = c(2, 2))
for (i in c(10,50,100,1000)){
= replicate(n = N, expr = f(i))
x = (var(x[2,1,]) * i)
var = sqrt(i) *( (x[2, 1, ] - beta)) / sqrt(var)
z plot(density(z), xlim = c(-4,4))
curve(dnorm(x,0,1), col = "red", xlim = c(-4,4), add = TRUE)
}
Distribuição Binomial
Mostrar a distribuição do termo de erro
= 10000
N = 5 beta
= 1000
n = runif(n, min = 0, max = 100)
x = rbinom(n = n, size = 5, prob = 0.5 ) - ((5*0.5)/1-0.5)
e = cbind(1,x)
X = 10 + beta * x + e
y = solve(t(X)%*%X)%*%t(X)%*%y
B = y - X%*%B
e_hat
hist(e_hat)
= function(n){
f = runif(n, min = 0, max = 100)
x = rbinom(n = n, size = 5, prob = 0.5 ) - ((5*0.5)/1-0.5)
e = cbind(1,x)
X = 10 + beta * x + e
y = solve(t(X)%*%X)%*%t(X)%*%y
B
B }
par(mfrow = c(2, 2))
for (i in c(10,50,100,1000)){
= replicate(n = N, expr = f(i))
x = (var(x[2,1,]) * i)
var = sqrt(i) *( (x[2, 1, ] - beta)) / sqrt(var)
z plot(density(z), xlim = c(-4,4))
curve(dnorm(x,0,1), col = "red", xlim = c(-4,4), add = TRUE)
}