-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path07ejemplo.jl
More file actions
35 lines (29 loc) · 864 Bytes
/
07ejemplo.jl
File metadata and controls
35 lines (29 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
### Ejemplo de estimación por máxima verosimilitud
### Autor: Dr. Arturo Erdely
### Versión: 2024-08-11
# Cargar paquetes y código externo necesarios:
begin
using Distributions # previamente instalado
include("06EDA.jl") # en misma carpeta
end
# Simulamos una muestra aleatoria
begin
m, p = 17, 0.35 # parámetros
X = Binomial(m, p) # variable aleatoria Binomial
n = 100 # tamaño de muestra a simular
muestra = rand(X, n)
println(muestra)
end
# Estimación inicial por método de momentos
begin
μ = mean(muestra)
σ2 = var(muestra)
p0 = 1 - σ2/μ
m0 = max(1, Int(round(μ/p0)))
m0, p0
end
# Estimación por máxima verosimilitud
mlogV(θ) = -sum(log.(pdf(Binomial(θ[1], θ[2]), muestra))) # menos log-verosimilitud
mlogV([m, p])
mlogV([15, 0.6])
emv = EDA(mlogV, [10, 0.15], [20, 0.6], iEnteros = [1])