Ajusta una Pareto a los siguientes datos
library(ggplot2)
library(actuar)
datos=c(10, 11, 15, 22, 28, 30, 32, 36, 38, 48,
55, 56, 68, 68, 85, 87, 94, 103, 104, 105,
109, 119, 121, 137, 178, 181, 226, 287, 310, 106,
393, 438, 591, 1045, 1210, 1212, 2423, 321, 354, 51)
Esto se realiza mediante estadística descriptiva: cálculo de medidas descriptivas y gráficos estadísticos
hist(datos,freq=F,breaks = 20,col="blue")#¿de qué le veo cara?
d<-density(datos)
lines(d)
a= boxplot(datos)
Tenemos 3 picos, dos datos atipicos 1210, 1212, 2423, Datos sesgados a la derecha
mean(datos)
[1] 272.675
median(datos)
[1] 104.5
var(datos)
[1] 212649
summary(datos)
Min. 1st Qu. Median Mean 3rd Qu. Max.
10.00 50.25 104.50 272.68 292.75 2423.00
quantile(datos)
0% 25% 50% 75% 100%
10.00 50.25 104.50 292.75 2423.00
Tenemos indicios de asimetría
var(datos)
[1] 212649
sd(datos)
[1] 461.1389
range(datos)
[1] 10 2423
IQR(datos)
[1] 242.5
range(datos)
[1] 10 2423
diff(range(datos))
[1] 2413
Usamos libreria moments, para el sesgo y kurtosis
library(moments)
sesgo=skewness(datos)
sesgo
[1] 3.136381
sesgo > 0: La curva es asimétricamente positiva por lo que los valores se tienden a reunir más en la parte izquierda que en la derecha de la media
kurtosis_1=kurtosis(datos)
kurtosis_1
[1] 13.58214
kurtosis_1 > 3 la distribución es Leptocúrtica
Podemos estimar los parámetros mediante MLE, Momentos, erc. Usamos la siguiente libreria
library(fitdistrplus)
Grafica el sesgo vs curtosis
descdist(datos)
summary statistics
------
min: 10 max: 2423
median: 104.5
mean: 272.675
estimated sd: 461.1389
estimated skewness: 3.259925
estimated kurtosis: 15.20117
Ajusta distribuciones univariadas
f1 <- fitdist(datos,"pareto")
$start.arg
$start.arg$shape
[1] 3.118228
$start.arg$scale
[1] 577.5879
$fix.arg
NULL
plot(f1)
f1
Fitting of the distribution ' pareto ' by maximum likelihood
Parameters:
Aparentemente el ajuste es bueno para una Pareto (1.83, 247.60)
Realizado a los datos Mediante pruebas de hipótesis, qqplots, curvas de densidad, etc.
Ho:Pertenecen a la misma distribución continua Pareto (p value > alfa=.05)) Ha:No Pertenecen a la misma distribución continua Pareto (p value < alfa=.05)
test de kolmogorof smirnov
ks.test(datos,ppareto,f1$estimate[1],f1$estimate[2])
Warning in ks.test(datos, ppareto, f1$estimate[1], f1$estimate[2]) :
ties should not be present for the Kolmogorov-Smirnov test
One-sample Kolmogorov-Smirnov test
data: datos
D = 0.10741, p-value = 0.7454
alternative hypothesis: two-sided
como p-value = 0.7454 > alfa=.05 Aceptamos Ho
ADGofTest::ad.test(datos,ppareto,f1$estimate[1],f1$estimate[2])
Anderson-Darling GoF Test
data: datos and ppareto
AD = 0.46132, p-value = 0.7855
alternative hypothesis: NA
Como p-value = 0.7855 > alfa=.05 Aceptamos Ho
hist(datos,freq=F,breaks = 20,col="blue")
u<-seq(min(datos),max(datos),by=.01)
lines(u,dpareto(u,f1$estimate[1],f1$estimate[2]),col="orange",lwd=2)