setwd("D:\\Aulas\\2013_Curso_R-Kteam\\Aulas\\Sessao2")
getwd() #confirmar directoria
## [1] "D:/Aulas/2013_Curso_R-Kteam/Aulas/Sessao2"
# carregar a base de dados
spz <- read.table("Tubarao-pelagico_amostra.csv", header = TRUE, sep = ",",
dec = ".", na.strings = "NA")
head(spz, 20)
## Index ForkLength1cm Sex
## 1 1 183 Male
## 2 2 182 Male
## 3 3 175 Male
## 4 4 200 Female
## 5 5 200 Female
## 6 6 205 Male
## 7 7 228 Female
## 8 8 233 Female
## 9 9 218 Female
## 10 10 190 Female
## 11 11 222 Male
## 12 12 190 Female
## 13 13 170 Female
## 14 14 190 Male
## 15 15 195 Male
## 16 16 140 Female
## 17 17 205 Male
## 18 18 191 Female
## 19 19 185 Female
## 20 20 203 Male
str(spz)
## 'data.frame': 139 obs. of 3 variables:
## $ Index : int 1 2 3 4 5 6 7 8 9 10 ...
## $ ForkLength1cm: int 183 182 175 200 200 205 228 233 218 190 ...
## $ Sex : Factor w/ 2 levels "Female","Male": 2 2 2 1 1 2 1 1 1 1 ...
summary(spz$ForkLength1cm)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 136 173 182 184 190 233
mean(spz$ForkLength1cm)
## [1] 183.9
sd(spz$ForkLength1cm)
## [1] 17.03
library(fBasics)
## Loading required package: MASS
## Loading required package: timeDate
## Loading required package: timeSeries
## Attaching package: 'fBasics'
## The following object is masked from 'package:base':
##
## norm
by(spz$ForkLength1cm, spz$Sex, range)
## spz$Sex: Female
## [1] 140 233
## --------------------------------------------------------
## spz$Sex: Male
## [1] 136 230
by(spz$ForkLength1cm, spz$Sex, mean)
## spz$Sex: Female
## [1] 187.3
## --------------------------------------------------------
## spz$Sex: Male
## [1] 180.8
by(spz$ForkLength1cm, spz$Sex, sd)
## spz$Sex: Female
## [1] 17.9
## --------------------------------------------------------
## spz$Sex: Male
## [1] 15.72
boxplot(ForkLength1cm ~ Sex, data = spz)
hist(spz$ForkLength1cm, breaks = c(136:233))
ks.test(spz$ForkLength1cm, "pnorm", 184, 17)
## Warning: ties should not be present for the Kolmogorov-Smirnov test
##
## One-sample Kolmogorov-Smirnov test
##
## data: spz$ForkLength1cm
## D = 0.1247, p-value = 0.0266
## alternative hypothesis: two-sided
ks.test(spz$ForkLength1cm, "pnorm", mean(spz$ForkLength1cm), sd(spz$ForkLength1cm))
## Warning: ties should not be present for the Kolmogorov-Smirnov test
##
## One-sample Kolmogorov-Smirnov test
##
## data: spz$ForkLength1cm
## D = 0.122, p-value = 0.03187
## alternative hypothesis: two-sided
library(nortest)
lillie.test(spz$ForkLength1cm)
##
## Lilliefors (Kolmogorov-Smirnov) normality test
##
## data: spz$ForkLength1cm
## D = 0.122, p-value = 2.834e-05
shapiro.test(spz$ForkLength1cm)
##
## Shapiro-Wilk normality test
##
## data: spz$ForkLength1cm
## W = 0.9495, p-value = 5.869e-05
qqnorm(spz$ForkLength1cm)
qqline(spz$ForkLength1cm)
library(car)
## Loading required package: nnet
leveneTest(spz$ForkLength1cm, spz$Sex)
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 1 0.48 0.49
## 137
bartlett.test(spz$ForkLength1cm, spz$Sex)
##
## Bartlett test of homogeneity of variances
##
## data: spz$ForkLength1cm and spz$Sex
## Bartlett's K-squared = 1.148, df = 1, p-value = 0.2839
boxplot(ForkLength1cm ~ Sex, xlab = "Sex", ylab = "Size (FL, cm)", main = "Boxplot SPZ por Sexos",
data = spz)
# Deve-se usar o teste não paramétrico devido á falta de normalidade No
# entanto, a falta de normalidade não é tão grave como a heterogeneidade
# de vars logo pode-se tb experimentar um teste paramétrico
wilcox.test(ForkLength1cm ~ Sex, alternative = "two.sided", data = spz)
##
## Wilcoxon rank sum test with continuity correction
##
## data: ForkLength1cm by Sex
## W = 3030, p-value = 0.008352
## alternative hypothesis: true location shift is not equal to 0
t.test(ForkLength1cm ~ Sex, alternative = "two.sided", data = spz)
##
## Welch Two Sample t-test
##
## data: ForkLength1cm by Sex
## t = 2.255, df = 128.4, p-value = 0.02582
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.7949 12.1755
## sample estimates:
## mean in group Female mean in group Male
## 187.3 180.8
ls()
## [1] "spz"
rm(spz)
ls()
## character(0)
cap.tol <- read.table("Dados-turtl-sizes.csv", header = T, dec = ".", sep = ",")
head(cap.tol, 30)
## TotalLength HookType Bait HokLoc
## 1 64 G S Mou
## 2 63 G S Mou
## 3 65 J S Mou
## 4 64 J S Mou
## 5 62 G S Mou
## 6 62 G S Mou
## 7 61 G S Mou
## 8 61 G S Mou
## 9 65 J S Mou
## 10 65 J S Mou
## 11 70 Gt S Fli
## 12 NA J S Eso
## 13 63 G S Eso
## 14 61 G S Eso
## 15 60 Gt S Mou
## 16 64 Gt S Mou
## 17 61 J S Mou
## 18 64 J S Mou
## 19 65 J S Mou
## 20 67 J S Mou
## 21 69 J M Mou
## 22 69 J M Mou
## 23 61 G M Eso
## 24 61 G M Eso
## 25 66 J S Mou
## 26 66 J S Mou
## 27 61 G S Mou
## 28 59 G S Mou
## 29 63 J S Eso
## 30 64 J S Eso
str(cap.tol)
## 'data.frame': 161 obs. of 4 variables:
## $ TotalLength: int 64 63 65 64 62 62 61 61 65 65 ...
## $ HookType : Factor w/ 3 levels "G","Gt","J": 1 1 3 3 1 1 1 1 3 3 ...
## $ Bait : Factor w/ 2 levels "M","S": 2 2 2 2 2 2 2 2 2 2 ...
## $ HokLoc : Factor w/ 4 levels "Ent","Eso","Fli",..: 4 4 4 4 4 4 4 4 4 4 ...
hist(cap.tol$TotalLength, main = "Distibuicao de tamanhos")
str(cap.tol)
## 'data.frame': 161 obs. of 4 variables:
## $ TotalLength: int 64 63 65 64 62 62 61 61 65 65 ...
## $ HookType : Factor w/ 3 levels "G","Gt","J": 1 1 3 3 1 1 1 1 3 3 ...
## $ Bait : Factor w/ 2 levels "M","S": 2 2 2 2 2 2 2 2 2 2 ...
## $ HokLoc : Factor w/ 4 levels "Ent","Eso","Fli",..: 4 4 4 4 4 4 4 4 4 4 ...
summary(cap.tol)
## TotalLength HookType Bait HokLoc
## Min. :43.0 G :41 M: 45 Ent: 2
## 1st Qu.:57.0 Gt:31 S:116 Eso: 28
## Median :61.0 J :89 Fli: 7
## Mean :60.4 Mou:124
## 3rd Qu.:65.0
## Max. :71.0
## NA's :13
library(fBasics)
cap.tol.sizes2 <- cap.tol[, 1] # vector dos dados de tamanhos de TOL
cap.tol.sizes2
## [1] 64 63 65 64 62 62 61 61 65 65 70 NA 63 61 60 64 61 64 65 67 69 69 61
## [24] 61 66 66 61 59 63 64 57 59 47 48 70 71 55 57 57 55 60 NA 59 NA 60 63
## [47] 66 63 59 64 66 63 NA 56 NA 56 56 58 59 57 56 55 61 NA 60 NA 68 56 69
## [70] 52 67 69 63 61 NA NA NA NA 49 53 50 55 67 69 59 61 55 54 58 58 57 NA
## [93] 55 53 60 68 62 60 69 61 58 60 56 54 57 55 61 60 54 52 62 64 46 43 69
## [116] 66 63 61 46 48 61 59 59 70 68 67 67 65 69 68 66 64 59 58 56 60 61 62
## [139] 55 57 58 48 49 47 66 65 60 68 65 66 60 59 NA 61 57 66 56 62 60 62 54
length(cap.tol.sizes2)
## [1] 161
basicStats(cap.tol.sizes2)
## cap.tol.sizes2
## nobs 161.00000
## NAs 13.00000
## Minimum 43.00000
## Maximum 71.00000
## 1. Quartile 57.00000
## 3. Quartile 65.00000
## Mean 60.35135
## Median 61.00000
## Sum 8932.00000
## SE Mean 0.47727
## LCL Mean 59.40815
## UCL Mean 61.29455
## Variance 33.71245
## Stdev 5.80624
## Skewness -0.52379
## Kurtosis 0.03838
cap.tol.sizes <- subset(cap.tol, TotalLength != "NA") # seleccionar apenas as que foram medidas
dim(cap.tol)
## [1] 161 4
dim(cap.tol.sizes)
## [1] 148 4
boxplot(TotalLength ~ HookType, data = cap.tol, ylab = "TL (cm)", xlab = "Hook Type")
boxplot(TotalLength ~ Bait, data = cap.tol, ylab = "TL", xlab = "Bait")
boxplot(TotalLength ~ HokLoc, data = cap.tol, ylab = "TL", xlab = "Hook loc")
# tiff(file='tamanhos-factors.tiff', bg = 'white', compression='lzw',
# width = 28, height = 14, units = 'cm', res = 360,)
par(mfrow = c(1, 3))
boxplot(TotalLength ~ HookType, data = cap.tol, ylab = "TL (cm)", xlab = "Hook Type")
boxplot(TotalLength ~ Bait, data = cap.tol, ylab = "TL", xlab = "Bait")
boxplot(TotalLength ~ HokLoc, data = cap.tol, ylab = "TL", xlab = "Hook loc")
# dev.off()
library(nortest)
library(car)
lillie.test(cap.tol$TotalLength) # Dist tamanhos não normais
##
## Lilliefors (Kolmogorov-Smirnov) normality test
##
## data: cap.tol$TotalLength
## D = 0.0772, p-value = 0.03089
leveneTest(TotalLength ~ Bait, data = cap.tol) # Homogeneidade vars entre iscos
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 1 0.11 0.74
## 146
leveneTest(TotalLength ~ HookType, data = cap.tol) # Homegeneidade vars entre Anzois
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 2 1.81 0.17
## 145
leveneTest(TotalLength ~ HokLoc, data = cap.tol) # Homegeneidade vars entre hooking locations
## Levene's Test for Homogeneity of Variance (center = median)
## Df F value Pr(>F)
## group 3 1.57 0.2
## 144
# t-test para Isco
t.test(TotalLength ~ Bait, data = cap.tol)
##
## Welch Two Sample t-test
##
## data: TotalLength by Bait
## t = 1.407, df = 84.1, p-value = 0.1632
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.5957 3.4769
## sample estimates:
## mean in group M mean in group S
## 61.36 59.92
# teste nao parametrico
wilcox.test(TotalLength ~ Bait, alternative = "two.sided", data = cap.tol)
##
## Wilcoxon rank sum test with continuity correction
##
## data: TotalLength by Bait
## W = 2622, p-value = 0.1616
## alternative hypothesis: true location shift is not equal to 0
# tamanhos capturados com diferentes iscos são iguais
# ANOVA univariada
fit.tol.hook <- aov(TotalLength ~ HookType, data = cap.tol)
summary(fit.tol.hook)
## Df Sum Sq Mean Sq F value Pr(>F)
## HookType 2 22 11.1 0.33 0.72
## Residuals 145 4934 34.0
## 13 observations deleted due to missingness
# teste nao parametrico
kruskal.test(TotalLength ~ HookType, data = cap.tol)
##
## Kruskal-Wallis rank sum test
##
## data: TotalLength by HookType
## Kruskal-Wallis chi-squared = 0.9155, df = 2, p-value = 0.6327
# tamanhos capturados com diferentes anzois são iguais
# ANOVA univariada para hooking location
fit.tol.loc <- aov(TotalLength ~ HokLoc, data = cap.tol)
summary(fit.tol.loc)
## Df Sum Sq Mean Sq F value Pr(>F)
## HokLoc 3 417 139.1 4.41 0.0053 **
## Residuals 144 4538 31.5
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 13 observations deleted due to missingness
# Teste nao parametrico
kruskal.test(TotalLength ~ HokLoc, data = cap.tol)
##
## Kruskal-Wallis rank sum test
##
## data: TotalLength by HokLoc
## Kruskal-Wallis chi-squared = 13, df = 3, p-value = 0.004632
# tamanhos capturados com cada mecanismo (hooking location) são diferentes
library(agricolae)
## Attaching package: 'agricolae'
## The following object is masked from 'package:timeDate':
##
## kurtosis, skewness
SNK.test(fit.tol.loc, "HokLoc") # Student newman Kewls
##
## Study:
##
## Student Newman Keuls Test
## for TotalLength
##
## Mean Square Error: 31.52
##
## HokLoc, means
##
## TotalLength std.err r Min. Max.
## Ent 70.50 0.5000 2 70 71
## Eso 62.69 0.8625 26 54 69
## Fli 61.17 3.1667 6 48 70
## Mou 59.60 0.5398 114 43 70
##
## alpha: 0.05 ; Df Error: 144
##
## Critical Range
## 2 3 4
## 6.630 7.943 8.718
##
## Harmonic Mean of Cell Sizes 5.603
##
## Different value for each comparison
## Means with the same letter are not significantly different.
##
## Groups, Treatments and means
## a Ent 70.5
## b Eso 62.69
## b Fli 61.17
## b Mou 59.6
HSD.test(fit.tol.loc, "HokLoc") # Multiple comparisons Tuckey. Só para desenhos equilibrados, o que não é o caso
##
## Study:
##
## HSD Test for TotalLength
##
## Mean Square Error: 31.52
##
## HokLoc, means
##
## TotalLength std.err r Min. Max.
## Ent 70.50 0.5000 2 70 71
## Eso 62.69 0.8625 26 54 69
## Fli 61.17 3.1667 6 48 70
## Mou 59.60 0.5398 114 43 70
##
## alpha: 0.05 ; Df Error: 144
## Critical Value of Studentized Range: 3.676
##
## Harmonic Mean of Cell Sizes 5.603
## Honestly Significant Difference: 8.718
##
## Means with the same letter are not significantly different.
##
## Groups, Treatments and means
## a Ent 70.5
## ab Eso 62.69
## ab Fli 61.17
## b Mou 59.6
LSD.test(fit.tol.loc, "HokLoc", p.adj = "none", group = F) #Least significant difference a dar os p-value
##
## Study:
##
## LSD t Test for TotalLength
##
## Mean Square Error: 31.52
##
## HokLoc, means and individual ( 95 %) CI
##
## TotalLength std.err r LCL UCL Min. Max.
## Ent 70.50 0.5000 2 69.51 71.49 70 71
## Eso 62.69 0.8625 26 60.99 64.40 54 69
## Fli 61.17 3.1667 6 54.91 67.43 48 70
## Mou 59.60 0.5398 114 58.53 60.66 43 70
##
## alpha: 0.05 ; Df Error: 144
## Critical Value of t: 1.977
##
## Comparison between treatments means
##
## Difference pvalue sig. LCL UCL
## Ent - Eso 7.808 0.06006 . -0.3348 15.950
## Ent - Fli 9.333 0.04357 * 0.2732 18.393
## Ent - Mou 10.904 0.00727 ** 2.9887 18.818
## Eso - Fli 1.526 0.54943 -3.5000 6.551
## Eso - Mou 3.096 0.01223 * 0.6842 5.507
## Fli - Mou 1.570 0.50536 -3.0776 6.218
LSD.test(fit.tol.loc, "HokLoc", p.adj = "none", group = T) #Least significant difference com grupos formados
##
## Study:
##
## LSD t Test for TotalLength
##
## Mean Square Error: 31.52
##
## HokLoc, means and individual ( 95 %) CI
##
## TotalLength std.err r LCL UCL Min. Max.
## Ent 70.50 0.5000 2 69.51 71.49 70 71
## Eso 62.69 0.8625 26 60.99 64.40 54 69
## Fli 61.17 3.1667 6 54.91 67.43 48 70
## Mou 59.60 0.5398 114 58.53 60.66 43 70
##
## alpha: 0.05 ; Df Error: 144
## Critical Value of t: 1.977
##
## Minimum difference changes for each comparison
##
## Means with the same letter are not significantly different.
##
## Groups, Treatments and means
## a Ent 70.5
## ab Eso 62.69
## bc Fli 61.17
## c Mou 59.6
# Aparentemente apenas o 'entangled' captura TOL sig. maiores, mas o
# desenho é muito pouco equilibrado...
par(mfrow = c(1, 1))
mosaicplot(~Bait + HookType, data = cap.tol, col = rainbow(5), main = "TOL catches",
ylab = "Hook Type")
mosaicplot(~Bait + HookType + HokLoc, data = cap.tol, col = rainbow(5), main = "TOL catches",
ylab = "Hook Type")
fit.tol1 <- aov(TotalLength ~ Bait + HookType + HokLoc, data = cap.tol)
summary(fit.tol1)
## Df Sum Sq Mean Sq F value Pr(>F)
## Bait 1 64 64.2 2.01 0.159
## HookType 2 26 13.0 0.41 0.668
## HokLoc 3 356 118.8 3.72 0.013 *
## Residuals 141 4509 32.0
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 13 observations deleted due to missingness
fit.tol2 <- aov(TotalLength ~ Bait + HookType + HokLoc + Bait:HookType + Bait:HokLoc +
HookType:HokLoc, data = cap.tol)
summary(fit.tol2)
## Df Sum Sq Mean Sq F value Pr(>F)
## Bait 1 64 64.2 2.02 0.157
## HookType 2 26 13.0 0.41 0.666
## HokLoc 3 356 118.8 3.74 0.013 *
## Bait:HookType 2 87 43.3 1.37 0.259
## Bait:HokLoc 2 45 22.4 0.71 0.495
## HookType:HokLoc 5 189 37.8 1.19 0.317
## Residuals 132 4189 31.7
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 13 observations deleted due to missingness
fit.tol3 <- aov(TotalLength ~ Bait * HookType * HokLoc, data = cap.tol)
summary(fit.tol3)
## Df Sum Sq Mean Sq F value Pr(>F)
## Bait 1 64 64.2 2.04 0.155
## HookType 2 26 13.0 0.41 0.663
## HokLoc 3 356 118.8 3.78 0.012 *
## Bait:HookType 2 87 43.3 1.38 0.256
## Bait:HokLoc 2 45 22.4 0.71 0.492
## HookType:HokLoc 5 189 37.8 1.20 0.311
## Bait:HookType:HokLoc 3 134 44.8 1.42 0.239
## Residuals 129 4054 31.4
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 13 observations deleted due to missingness
rs <- rstandard(fit.tol1) #resíduos standardizados
boxplot(rs, main = "Resíduos Standardizados") # Alguns possiveis outliers
par(mfrow = c(2, 2))
plot(fit.tol1)
names(fit.tol1) # Variaveis criadas e que existem no objecto fit.tol1
## [1] "coefficients" "residuals" "effects" "rank"
## [5] "fitted.values" "assign" "qr" "df.residual"
## [9] "na.action" "contrasts" "xlevels" "call"
## [13] "terms" "model"
par(mfrow = c(1, 1))
plot(fit.tol1$fit, fit.tol1$res, xlab = "valores ajustados", ylab = "resíduos")
abline(h = 0)
title("resíduos vs Predictos")
par(mfrow = c(1, 1))
plot(fit.tol1$fit, rs, xlab = "valores ajustados", ylab = "resíduos standardizados")
abline(h = 0)
title("resíduos vs Predictos") # problema de falta de homogeneidade ao longo dos resíduos
qqnorm(rs)
qqline(rs, col = 2, lwd = 2) # Problemas de falta de normalidade nos resíduos
library(gmodels)
citation("gmodels")
Tabela1 <- matrix(c(28, 13, 13, 18, 50, 39), nrow = 3, ncol = 2, byrow = T)
colnames(Tabela1) <- c("Alive", "Dead")
rownames(Tabela1) <- c("G", "Gt", "J")
Tabela1 # Counts
## Alive Dead
## G 28 13
## Gt 13 18
## J 50 39
CrossTable(Tabela1, digits = 1, expected = T, prop.chisq = F, prop.r = T, prop.c = F,
prop.t = F, fisher = F, format = "SPSS")
##
## Cell Contents
## |-------------------------|
## | Count |
## | Expected Values |
## | Row Percent |
## |-------------------------|
##
## Total Observations in Table: 161
##
## |
## | Alive | Dead | Row Total |
## -------------|-----------|-----------|-----------|
## G | 28 | 13 | 41 |
## | 23.2 | 17.8 | |
## | 68.3% | 31.7% | 25.5% |
## -------------|-----------|-----------|-----------|
## Gt | 13 | 18 | 31 |
## | 17.5 | 13.5 | |
## | 41.9% | 58.1% | 19.3% |
## -------------|-----------|-----------|-----------|
## J | 50 | 39 | 89 |
## | 50.3 | 38.7 | |
## | 56.2% | 43.8% | 55.3% |
## -------------|-----------|-----------|-----------|
## Column Total | 91 | 70 | 161 |
## -------------|-----------|-----------|-----------|
##
##
## Statistics for All Table Factors
##
##
## Pearson's Chi-squared test
## ------------------------------------------------------------
## Chi^2 = 5 d.f. = 2 p = 0.0821
##
##
##
## Minimum expected frequency: 13.48
prop.test(Tabela1, alternative = "two.sided", conf.level = 0.95, correct = F)
##
## 3-sample test for equality of proportions without continuity
## correction
##
## data: Tabela1
## X-squared = 5, df = 2, p-value = 0.0821
## alternative hypothesis: two.sided
## sample estimates:
## prop 1 prop 2 prop 3
## 0.6829 0.4194 0.5618
Tabela2 <- matrix(c(25, 17, 3, 0, 99, 11, 4, 2), nrow = 2, ncol = 4, byrow = T)
colnames(Tabela2) <- c("Mouth", "Esophagus", "Flippers", "Entangled")
rownames(Tabela2) <- c("Mackerel", "Squid")
Tabela2 # Counts
## Mouth Esophagus Flippers Entangled
## Mackerel 25 17 3 0
## Squid 99 11 4 2
CrossTable(Tabela2, digits = 1, expected = T, prop.chisq = F, prop.r = T, prop.c = F,
prop.t = F, fisher = F, format = "SPSS")
## Warning: Chi-squared approximation may be incorrect
##
## Cell Contents
## |-------------------------|
## | Count |
## | Expected Values |
## | Row Percent |
## |-------------------------|
##
## Total Observations in Table: 161
##
## |
## | Mouth | Esophagus | Flippers | Entangled | Row Total |
## -------------|-----------|-----------|-----------|-----------|-----------|
## Mackerel | 25 | 17 | 3 | 0 | 45 |
## | 34.7 | 7.8 | 2.0 | 0.6 | |
## | 55.6% | 37.8% | 6.7% | 0.0% | 28.0% |
## -------------|-----------|-----------|-----------|-----------|-----------|
## Squid | 99 | 11 | 4 | 2 | 116 |
## | 89.3 | 20.2 | 5.0 | 1.4 | |
## | 85.3% | 9.5% | 3.4% | 1.7% | 72.0% |
## -------------|-----------|-----------|-----------|-----------|-----------|
## Column Total | 124 | 28 | 7 | 2 | 161 |
## -------------|-----------|-----------|-----------|-----------|-----------|
##
##
## Statistics for All Table Factors
##
##
## Pearson's Chi-squared test
## ------------------------------------------------------------
## Chi^2 = 20.21 d.f. = 3 p = 0.0001536
##
##
##
## Minimum expected frequency: 0.559
## Cells with Expected Frequency < 5: 3 of 8 (37.5%)
# Problemas nos pressupostos das tabelas
Tabela3 <- matrix(c(25, 17, 3, 99, 11, 6), nrow = 2, ncol = 3, byrow = T)
colnames(Tabela3) <- c("Mouth", "Esophagus", "External")
rownames(Tabela3) <- c("Mackerel", "Squid")
Tabela3
## Mouth Esophagus External
## Mackerel 25 17 3
## Squid 99 11 6
CrossTable(Tabela3, digits = 1, expected = T, prop.chisq = F, prop.r = T, prop.c = F,
prop.t = F, fisher = F, format = "SPSS")
## Warning: Chi-squared approximation may be incorrect
##
## Cell Contents
## |-------------------------|
## | Count |
## | Expected Values |
## | Row Percent |
## |-------------------------|
##
## Total Observations in Table: 161
##
## |
## | Mouth | Esophagus | External | Row Total |
## -------------|-----------|-----------|-----------|-----------|
## Mackerel | 25 | 17 | 3 | 45 |
## | 34.7 | 7.8 | 2.5 | |
## | 55.6% | 37.8% | 6.7% | 28.0% |
## -------------|-----------|-----------|-----------|-----------|
## Squid | 99 | 11 | 6 | 116 |
## | 89.3 | 20.2 | 6.5 | |
## | 85.3% | 9.5% | 5.2% | 72.0% |
## -------------|-----------|-----------|-----------|-----------|
## Column Total | 124 | 28 | 9 | 161 |
## -------------|-----------|-----------|-----------|-----------|
##
##
## Statistics for All Table Factors
##
##
## Pearson's Chi-squared test
## ------------------------------------------------------------
## Chi^2 = 18.79 d.f. = 2 p = 8.311e-05
##
##
##
## Minimum expected frequency: 2.516
## Cells with Expected Frequency < 5: 1 of 6 (16.67%)
# q()