Variáveis
library(readxl)
dados <- read_excel("case1 tipo_sa.xlsx")
str(dados)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 100 obs. of 9 variables:
$ tipo_sa : num 0 1 1 1 0 1 0 1 0 1 ...
$ tam : num 1 1 2 1 3 2 1 2 3 2 ...
$ patr_liq : num 63685 89430 81300 79945 105690 ...
$ ativo_cir : num 30475 53000 35775 30475 60950 ...
$ passivo_cir : num 41400 43125 74175 31050 58650 ...
$ ativo_perm : num 79300 128100 125050 118950 68625 ...
$ ativo_rlp : num 5004 25020 43368 8340 7506 ...
$ passivo_elp : num 40098 17604 33252 26406 58680 ...
$ lucro_liq_perc: num 0.0461 0.0758 0.095 0.0189 0.0245 0.027 0.0299 0.0013 -0.0108 -0.0129 ...
head(dados)
dados$tipo_sa <- factor(dados$tipo_sa, levels=c("0","1"), labels=c("capital aberto", "capital fechado"))
dados$tam <- factor(dados$tam, levels=c("1","2","3"), labels=c("Pequeno", "Médio", "Grande"))
head(dados)
Sumário
library(psych)
describe(dados[,3:9]) # apenas dados quantitativos
vars n mean sd median trimmed mad min
patr_liq 1 100 71245.90 15312.14 67750.00 71052.81 14062.46 33875.00
ativo_cir 2 100 35311.25 10213.83 34450.00 34830.94 7857.78 14575.00
passivo_cir 3 100 50249.25 12942.80 51750.00 50715.00 12787.42 12075.00
ativo_perm 4 100 106094.25 24257.34 109037.50 106654.69 28262.06 56425.00
ativo_rlp 5 100 19715.76 9971.79 17931.00 19202.85 9891.91 1668.00
passivo_elp 6 100 34376.70 12916.70 33252.00 34511.18 14499.83 0.00
lucro_liq_perc 7 100 0.02 0.03 0.02 0.02 0.02 -0.12
max range skew kurtosis se
patr_liq 111110.0 77235.00 0.19 -0.03 1531.21
ativo_cir 60950.0 46375.00 0.48 -0.02 1021.38
passivo_cir 79350.0 67275.00 -0.35 0.02 1294.28
ativo_perm 152500.0 96075.00 -0.20 -0.94 2425.73
ativo_rlp 45036.0 43368.00 0.46 -0.59 997.18
passivo_elp 59658.0 59658.00 -0.08 -0.59 1291.67
lucro_liq_perc 0.1 0.21 -0.75 3.56 0.00
table(dados[,1:2]) # apenas dados qualitativos
tam
tipo_sa Pequeno Médio Grande
capital aberto 10 16 34
capital fechado 24 16 0
Forma da distribuição
par(mfrow=c(3,3))
hist(dados$patr_liq)
hist(dados$ativo_cir)
hist(dados$passivo_cir)
hist(dados$ativo_perm)
hist(dados$ativo_rlp)
hist(dados$passivo_elp)
hist(dados$lucro_liq_perc)
par(mfrow=c(1,1))
Box Plot > obserações discrepantes (olhar univariado)
par(mfrow=c(3,3))
boxplot(dados$patr_liq)
boxplot(dados$ativo_cir)
boxplot(dados$passivo_cir)
boxplot(dados$ativo_perm)
boxplot(dados$ativo_rlp)
boxplot(dados$passivo_elp)
boxplot(dados$lucro_liq_perc)
par(mfrow=c(1,1))
par(mfrow=c(3,3))
boxplot(dados$patr_liq~dados$tipo_sa)
boxplot(dados$ativo_cir~dados$tipo_sa)
boxplot(dados$passivo_cir~dados$tipo_sa)
boxplot(dados$ativo_perm~dados$tipo_sa)
boxplot(dados$ativo_rlp~dados$tipo_sa)
boxplot(dados$passivo_elp~dados$tipo_sa)
boxplot(dados$lucro_liq_perc~dados$tipo_sa)
par(mfrow=c(1,1))
par(mfrow=c(3,3))
boxplot(dados$patr_liq~dados$tam)
boxplot(dados$ativo_cir~dados$tam)
boxplot(dados$passivo_cir~dados$tam)
boxplot(dados$ativo_perm~dados$tam)
boxplot(dados$ativo_rlp~dados$tam)
boxplot(dados$passivo_elp~dados$tam)
boxplot(dados$lucro_liq_perc~dados$tam)
par(mfrow=c(1,1))
obserações discrepantes (olhar multivarido)
outlier(dados[,3:9])
1 2 3 4 5 6 7 8
4.032547 8.848578 13.359090 6.485754 12.796781 5.135195 7.809779 6.975575
9 10 11 12 13 14 15 16
6.871492 3.773659 3.799299 2.511399 5.163402 7.292381 10.228835 2.376188
17 18 19 20 21 22 23 24
8.748011 7.306523 11.576402 7.326450 2.928180 33.018911 3.959360 2.217106
25 26 27 28 29 30 31 32
4.640975 3.140521 1.956124 5.668116 4.418777 3.120336 1.261850 3.679069
33 34 35 36 37 38 39 40
5.565535 2.948255 6.650399 2.703993 5.386768 2.647563 10.169109 3.180719
41 42 43 44 45 46 47 48
4.045813 13.326535 8.879716 4.613969 6.203606 6.248428 12.107547 4.906422
49 50 51 52 53 54 55 56
9.710786 23.259049 12.692866 5.586708 6.030362 2.911568 32.422807 3.661792
57 58 59 60 61 62 63 64
11.368709 4.343418 3.470123 13.712749 10.791706 6.026919 3.395965 3.830056
65 66 67 68 69 70 71 72
11.922612 1.819079 3.632052 5.947582 4.584401 2.854809 7.854088 9.463426
73 74 75 76 77 78 79 80
3.479269 5.509818 5.624415 3.210325 6.126097 5.308337 12.874402 2.215576
81 82 83 84 85 86 87 88
4.869197 11.749392 5.974835 2.378841 2.278607 3.814355 2.527496 2.309430
89 90 91 92 93 94 95 96
12.635408 12.065535 11.359848 4.776350 10.656086 2.783333 6.134458 15.814309
97 98 99 100
8.721706 3.170609 7.606874 3.720417
# Correlation matrix
dadosq <- dados[,3:9]
pairs(dadosq,
pch = 21,
bg = c("red", "green3")[unclass(dados$tipo_sa)])
pairs(dadosq,
pch = 21,
bg = c("red", "green3", "blue")[unclass(dados$tam)])
library(ggplot2)
Attaching package: 㤼㸱ggplot2㤼㸲
The following objects are masked from 㤼㸱package:psych㤼㸲:
%+%, alpha
library(ggcorrplot)
corr <- cor(dadosq)
corr <- round(corr, 2)
corr
patr_liq ativo_cir passivo_cir ativo_perm ativo_rlp passivo_elp
patr_liq 1.00 0.79 0.30 0.20 0.27 0.05
ativo_cir 0.79 1.00 0.24 0.15 0.19 0.08
passivo_cir 0.30 0.24 1.00 -0.07 0.51 0.62
ativo_perm 0.20 0.15 -0.07 1.00 0.46 -0.48
ativo_rlp 0.27 0.19 0.51 0.46 1.00 -0.35
passivo_elp 0.05 0.08 0.62 -0.48 -0.35 1.00
lucro_liq_perc 0.13 0.11 -0.05 0.01 0.01 -0.07
lucro_liq_perc
patr_liq 0.13
ativo_cir 0.11
passivo_cir -0.05
ativo_perm 0.01
ativo_rlp 0.01
passivo_elp -0.07
lucro_liq_perc 1.00
library(corrplot)
corrplot(corr)
ggcorrplot(corr, hc.order = TRUE,
type = "lower",
lab = TRUE,
lab_size = 3,
method="circle",
colors = c("tomato2", "white", "springgreen3"),
title="Correlograma",
ggtheme=theme_bw)