In [1]:
# rm(list=ls())
options(OutDec = ",")
#===============================================================================
silence <- suppressPackageStartupMessages # Para omitir mensagens de alertas
silence(library(psych)) # Para a funcao 'describe'
silence(library(tseries)) # Para o teste de normalidade de Jarque-Bera
In [2]:
#===============================================================================
# Dados da Tabela 2.2
#===============================================================================
dados <- read.csv("../dados/Tabela-2-2.csv",sep=";",dec=",",header=F)
print(dados)
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1 1010,2 1002,3 1003,8 1000,2 1008,8 992,1 1008,9 999,4 1011,3 1014,0 2 1010,5 995,0 994,0 1011,2 1008,1 1008,3 1017,6 1005,3 1003,8 1019,6 3 995,0 1010,2 999,9 1009,5 1017,9 1012,9 1008,5 1003,1 1010,5 1009,5 4 994,1 991,2 1001,6 1002,1 1010,5 1009,0 992,3 1002,3 1012,7 1006,9 5 994,8 989,1 1002,5 1008,7 1014,6 1004,9 1002,2 1007,3 1002,4 1011,7 6 980,2 999,4 1002,0 1011,9 997,8 997,5 986,9 1014,4 1024,0 1006,9 7 992,0 1004,4 1005,3 1003,2 1016,5 1015,3 1003,3 992,6 1013,1 1016,1 8 997,2 994,5 1006,9 1012,8 1014,5 1021,7 1007,2 996,1 1008,8 1000,2 9 1004,5 998,7 1002,4 1012,9 1011,1 1007,8 994,2 1012,0 1017,8 1018,4 10 988,2 991,1 1004,3 1010,6 1009,9 1011,3 998,9 1002,9 997,5 1002,0
In [3]:
#===============================================================================
# Transformando para vetor
#===============================================================================
x <- as.vector(unlist(dados))
print(x)
[1] 1010,2 1010,5 995,0 994,1 994,8 980,2 992,0 997,2 1004,5 988,2 [11] 1002,3 995,0 1010,2 991,2 989,1 999,4 1004,4 994,5 998,7 991,1 [21] 1003,8 994,0 999,9 1001,6 1002,5 1002,0 1005,3 1006,9 1002,4 1004,3 [31] 1000,2 1011,2 1009,5 1002,1 1008,7 1011,9 1003,2 1012,8 1012,9 1010,6 [41] 1008,8 1008,1 1017,9 1010,5 1014,6 997,8 1016,5 1014,5 1011,1 1009,9 [51] 992,1 1008,3 1012,9 1009,0 1004,9 997,5 1015,3 1021,7 1007,8 1011,3 [61] 1008,9 1017,6 1008,5 992,3 1002,2 986,9 1003,3 1007,2 994,2 998,9 [71] 999,4 1005,3 1003,1 1002,3 1007,3 1014,4 992,6 996,1 1012,0 1002,9 [81] 1011,3 1003,8 1010,5 1012,7 1002,4 1024,0 1013,1 1008,8 1017,8 997,5 [91] 1014,0 1019,6 1009,5 1006,9 1011,7 1006,9 1016,1 1000,2 1018,4 1002,0
In [4]:
#===============================================================================
# Estatísticas descritivas
#===============================================================================
options(digits=6)
xdescribe <- describe(x)
xmedia <- xdescribe[,3]
xdesvpad <- xdescribe[,4]
xmediana <- xdescribe[,5]
xmin <- xdescribe[,8]
xmax <- xdescribe[,9]
xrange <- xdescribe[,10]
xassimetria <- xdescribe[,11]
xexccurtose <- xdescribe[,12]
STATS <- cbind(xmedia,xdesvpad,xmediana,xmin,xmax,xrange,
xassimetria,xexccurtose)
print(STATS)
xmedia xdesvpad xmediana xmin xmax xrange xassimetria xexccurtose [1,] 1005,01 8,47764 1005,3 980,2 1024 43,8 -0,314446 -0,285388
In [5]:
#===============================================================================
# Histograma
#===============================================================================
inc <- (1025-980)/8
breakp <- seq(980,1025,inc)
par(mfrow=c(1,1),lwd=2.0,cex.lab=1.5,cex.axis=1.5,lab=c(12,5,5),
mar=c(5,5,2,2.5),xpd=T,cex.main=2.0,bty="n")
hist(x,breaks=breakp,lwd=2,col="darkorange",main="",xlab=expression(x),
ylab="Frequência",xlim=c(975,1030),ylim=c(0,30))
In [6]:
#===============================================================================
# Boxplot
#===============================================================================
par(mfrow=c(1,1),lwd=2.0,cex.lab=1.5,cex.axis=1.5,lab=c(10,5,5),
mar=c(5,5,2,2.5),xpd=T,cex.main=2.0,bty="n")
boxplot(x,lwd=2,col="darkorange",main="",ylab=expression(x),pch=16,
ylim=c(970,1030))
In [7]:
#===============================================================================
# Normal qq-plot
#===============================================================================
par(mfrow=c(1,1),lwd=2.0,cex.lab=1.5,cex.axis=1.5,lab=c(8,5,5),
mar=c(5,5,2,2.5),xpd=T,cex.main=2.0,bty="n")
qqnorm(x,col="darkorange",main="",xlab="Percentis teóricos",cex=2,
ylab="Percentis amostrais",pch=16,xlim=c(-4,4),ylim=c(970,1030))
qqline(x,lwd=2,col="black",lty=2,xlim=c(-3.5,3.5),xpd=F)
In [8]:
#===============================================================================
# Teste de normalidade - Jarque Bera
#===============================================================================
print(jarque.bera.test(x))
Jarque Bera Test data: x X-squared = 1,919, df = 2, p-value = 0,383
In [9]:
#===============================================================================
# Teste de normalidade - Shapiro-Wilk
#===============================================================================
print(shapiro.test(x))
Shapiro-Wilk normality test data: x W = 0,9874, p-value = 0,463
In [10]:
#===============================================================================
# Fim
#===============================================================================