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.1
#===============================================================================
dados <- read.csv("../dados/Tabela-2-1.csv",sep=";",dec=",",header=F)
print(dados)
V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 1 998,8 994,9 1001,0 1005,1 1004,8 1006,9 991,3 999,1 1004,4 995,7 2 997,2 993,2 992,6 996,1 996,9 991,5 997,7 998,4 1000,5 998,5 3 998,7 998,5 1005,4 999,7 999,3 997,9 1007,9 1003,5 1009,5 997,4 4 1006,6 993,6 1002,2 1003,6 1007,7 999,7 997,9 1002,7 998,5 1003,0 5 994,2 996,6 993,9 998,5 999,9 1000,1 998,7 1008,8 993,0 997,1 6 989,7 1005,8 994,9 997,4 1003,0 1001,9 1003,5 1002,4 994,5 995,5 7 1002,8 1001,3 996,2 999,0 1000,5 1002,2 1000,6 996,4 1007,5 1001,9 8 1000,3 1003,3 1003,4 997,5 996,3 1004,4 995,2 993,8 1002,8 1002,6 9 1008,8 1005,8 1005,2 1000,5 1000,0 1001,8 999,9 995,8 992,9 1003,3 10 1001,8 1002,5 1000,9 995,9 1005,0 998,8 996,6 996,7 998,3 998,2
In [3]:
#===============================================================================
# Transformando para vetor
#===============================================================================
x <- as.vector(unlist(dados))
print(x)
[1] 998,8 997,2 998,7 1006,6 994,2 989,7 1002,8 1000,3 1008,8 1001,8 [11] 994,9 993,2 998,5 993,6 996,6 1005,8 1001,3 1003,3 1005,8 1002,5 [21] 1001,0 992,6 1005,4 1002,2 993,9 994,9 996,2 1003,4 1005,2 1000,9 [31] 1005,1 996,1 999,7 1003,6 998,5 997,4 999,0 997,5 1000,5 995,9 [41] 1004,8 996,9 999,3 1007,7 999,9 1003,0 1000,5 996,3 1000,0 1005,0 [51] 1006,9 991,5 997,9 999,7 1000,1 1001,9 1002,2 1004,4 1001,8 998,8 [61] 991,3 997,7 1007,9 997,9 998,7 1003,5 1000,6 995,2 999,9 996,6 [71] 999,1 998,4 1003,5 1002,7 1008,8 1002,4 996,4 993,8 995,8 996,7 [81] 1004,4 1000,5 1009,5 998,5 993,0 994,5 1007,5 1002,8 992,9 998,3 [91] 995,7 998,5 997,4 1003,0 997,1 995,5 1001,9 1002,6 1003,3 998,2
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,] 999,84 4,34179 999,7 989,7 1009,5 19,8 0,0860078 -0,562461
In [5]:
#===============================================================================
# Histograma
#===============================================================================
inc <- (1010-986)/6
breakp <- seq(986,1010,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(986,1010),ylim=c(0,35))
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(985,1010))
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(-3,3),ylim=c(985,1015))
qqline(x,lwd=2,col="black",lty=2,xlim=c(-3,3),xpd=F)
In [8]:
#===============================================================================
# Teste de normalidade - Jarque Bera
#===============================================================================
print(jarque.bera.test(x))
Jarque Bera Test data: x X-squared = 1,223, df = 2, p-value = 0,542
In [9]:
#===============================================================================
# Teste de normalidade - Shapiro-Wilk
#===============================================================================
print(shapiro.test(x))
Shapiro-Wilk normality test data: x W = 0,9917, p-value = 0,799
In [10]:
#===============================================================================
# Fim
#===============================================================================