1.Tabela da distribuição da variável frota
| Frota | Quantidade |
|---|---|
| São Paulo | 117 |
| Ubatuba | 39 |
| Estatística | Valor |
|---|---|
| Min. | 500000 |
| Median | 12000000 |
| Mean | 16232756 |
| Max. | 65000000 |
| Estatística | Valor |
|---|---|
| Min. | 4375000 |
| Median | 16641026 |
| Mean | 19554557 |
| Max. | 60000000 |
##
## Shapiro-Wilk normality test
##
## data: dados$cpue
## W = 0.90468, p-value = 1.492e-08
attach(dados)
modelo1=glm(cpue~ano+trim+latit+long+dia+captura,family=gaussian(link="identity"))
summary(modelo1)
##
## Call:
## glm(formula = cpue ~ ano + trim + latit + long + dia + captura,
## family = gaussian(link = "identity"))
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.163e+07 5.628e+08 0.127 0.899
## ano -2.076e+04 2.821e+05 -0.074 0.941
## trim -1.868e+05 4.120e+05 -0.453 0.651
## latit 6.081e+05 5.724e+05 1.062 0.290
## long -5.512e+05 6.308e+05 -0.874 0.384
## dia -2.092e+06 1.365e+05 -15.324 <2e-16 ***
## captura 1.049e+00 4.251e-02 24.686 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 2.586026e+13)
##
## Null deviance: 2.2717e+16 on 155 degrees of freedom
## Residual deviance: 3.8532e+15 on 149 degrees of freedom
## AIC: 5269.4
##
## Number of Fisher Scoring iterations: 2
\[ AIC = -2 \sum_{i=1}^{n} l(\hat{\mu}_i, y_i) + 2p \]
stepAIC(modelo1)
## Start: AIC=5269.41
## cpue ~ ano + trim + latit + long + dia + captura
##
## Df Deviance AIC
## - ano 1 3.8533e+15 5267.4
## - trim 1 3.8585e+15 5267.6
## - long 1 3.8729e+15 5268.2
## - latit 1 3.8824e+15 5268.6
## <none> 3.8532e+15 5269.4
## - dia 1 9.9256e+15 5415.0
## - captura 1 1.9612e+16 5521.3
##
## Step: AIC=5267.41
## cpue ~ trim + latit + long + dia + captura
##
## Df Deviance AIC
## - trim 1 3.8585e+15 5265.6
## - long 1 3.8734e+15 5266.2
## - latit 1 3.8829e+15 5266.6
## <none> 3.8533e+15 5267.4
## - dia 1 9.9324e+15 5413.1
## - captura 1 1.9618e+16 5519.3
##
## Step: AIC=5265.63
## cpue ~ latit + long + dia + captura
##
## Df Deviance AIC
## - long 1 3.8804e+15 5264.5
## - latit 1 3.8851e+15 5264.7
## <none> 3.8585e+15 5265.6
## - dia 1 9.9444e+15 5411.3
## - captura 1 1.9895e+16 5519.5
##
## Step: AIC=5264.51
## cpue ~ latit + dia + captura
##
## Df Deviance AIC
## - latit 1 3.8861e+15 5262.7
## <none> 3.8804e+15 5264.5
## - dia 1 1.0073e+16 5411.3
## - captura 1 2.0650e+16 5523.3
##
## Step: AIC=5262.73
## cpue ~ dia + captura
##
## Df Deviance AIC
## <none> 3.8861e+15 5262.7
## - dia 1 1.0201e+16 5411.3
## - captura 1 2.2673e+16 5535.9
##
## Call: glm(formula = cpue ~ dia + captura, family = gaussian(link = "identity"))
##
## Coefficients:
## (Intercept) dia captura
## 1.995e+07 -2.105e+06 1.065e+00
##
## Degrees of Freedom: 155 Total (i.e. Null); 153 Residual
## Null Deviance: 2.272e+16
## Residual Deviance: 3.886e+15 AIC: 5263
\[ BIC = -2 \sum_{i=1}^{n} l(\hat{\mu}_i, y_i) + p \log(n)\]
stepAIC(modelo1, k = log(156))
## Start: AIC=5290.76
## cpue ~ ano + trim + latit + long + dia + captura
##
## Df Deviance AIC
## - ano 1 3.8533e+15 5285.7
## - trim 1 3.8585e+15 5285.9
## - long 1 3.8729e+15 5286.5
## - latit 1 3.8824e+15 5286.9
## <none> 3.8532e+15 5290.8
## - dia 1 9.9256e+15 5433.3
## - captura 1 1.9612e+16 5539.6
##
## Step: AIC=5285.71
## cpue ~ trim + latit + long + dia + captura
##
## Df Deviance AIC
## - trim 1 3.8585e+15 5280.9
## - long 1 3.8734e+15 5281.5
## - latit 1 3.8829e+15 5281.9
## <none> 3.8533e+15 5285.7
## - dia 1 9.9324e+15 5428.4
## - captura 1 1.9618e+16 5534.6
##
## Step: AIC=5280.87
## cpue ~ latit + long + dia + captura
##
## Df Deviance AIC
## - long 1 3.8804e+15 5276.7
## - latit 1 3.8851e+15 5276.9
## <none> 3.8585e+15 5280.9
## - dia 1 9.9444e+15 5423.5
## - captura 1 1.9895e+16 5531.7
##
## Step: AIC=5276.71
## cpue ~ latit + dia + captura
##
## Df Deviance AIC
## - latit 1 3.8861e+15 5271.9
## <none> 3.8804e+15 5276.7
## - dia 1 1.0073e+16 5420.5
## - captura 1 2.0650e+16 5532.5
##
## Step: AIC=5271.88
## cpue ~ dia + captura
##
## Df Deviance AIC
## <none> 3.8861e+15 5271.9
## - dia 1 1.0201e+16 5417.4
## - captura 1 2.2673e+16 5542.0
##
## Call: glm(formula = cpue ~ dia + captura, family = gaussian(link = "identity"))
##
## Coefficients:
## (Intercept) dia captura
## 1.995e+07 -2.105e+06 1.065e+00
##
## Degrees of Freedom: 155 Total (i.e. Null); 153 Residual
## Null Deviance: 2.272e+16
## Residual Deviance: 3.886e+15 AIC: 5263
# Seleção Stepwise: mostra o que acontece com AIC do modelo caso
#uma variável seja retirada ou adiconada
step(modelo1, direction ="both")
## Start: AIC=5269.41
## cpue ~ ano + trim + latit + long + dia + captura
##
## Df Deviance AIC
## - ano 1 3.8533e+15 5267.4
## - trim 1 3.8585e+15 5267.6
## - long 1 3.8729e+15 5268.2
## - latit 1 3.8824e+15 5268.6
## <none> 3.8532e+15 5269.4
## - dia 1 9.9256e+15 5415.0
## - captura 1 1.9612e+16 5521.3
##
## Step: AIC=5267.41
## cpue ~ trim + latit + long + dia + captura
##
## Df Deviance AIC
## - trim 1 3.8585e+15 5265.6
## - long 1 3.8734e+15 5266.2
## - latit 1 3.8829e+15 5266.6
## <none> 3.8533e+15 5267.4
## + ano 1 3.8532e+15 5269.4
## - dia 1 9.9324e+15 5413.1
## - captura 1 1.9618e+16 5519.3
##
## Step: AIC=5265.63
## cpue ~ latit + long + dia + captura
##
## Df Deviance AIC
## - long 1 3.8804e+15 5264.5
## - latit 1 3.8851e+15 5264.7
## <none> 3.8585e+15 5265.6
## + trim 1 3.8533e+15 5267.4
## + ano 1 3.8585e+15 5267.6
## - dia 1 9.9444e+15 5411.3
## - captura 1 1.9895e+16 5519.5
##
## Step: AIC=5264.51
## cpue ~ latit + dia + captura
##
## Df Deviance AIC
## - latit 1 3.8861e+15 5262.7
## <none> 3.8804e+15 5264.5
## + long 1 3.8585e+15 5265.6
## + trim 1 3.8734e+15 5266.2
## + ano 1 3.8801e+15 5266.5
## - dia 1 1.0073e+16 5411.3
## - captura 1 2.0650e+16 5523.3
##
## Step: AIC=5262.73
## cpue ~ dia + captura
##
## Df Deviance AIC
## <none> 3.8861e+15 5262.7
## + latit 1 3.8804e+15 5264.5
## + trim 1 3.8831e+15 5264.6
## + long 1 3.8851e+15 5264.7
## + ano 1 3.8857e+15 5264.7
## - dia 1 1.0201e+16 5411.3
## - captura 1 2.2673e+16 5535.9
##
## Call: glm(formula = cpue ~ dia + captura, family = gaussian(link = "identity"))
##
## Coefficients:
## (Intercept) dia captura
## 1.995e+07 -2.105e+06 1.065e+00
##
## Degrees of Freedom: 155 Total (i.e. Null); 153 Residual
## Null Deviance: 2.272e+16
## Residual Deviance: 3.886e+15 AIC: 5263
##
## Call:
## glm(formula = cpue ~ dia + captura, family = gaussian)
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.995e+07 1.027e+06 19.42 <2e-16 ***
## dia -2.105e+06 1.335e+05 -15.77 <2e-16 ***
## captura 1.065e+00 3.914e-02 27.20 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for gaussian family taken to be 2.539917e+13)
##
## Null deviance: 2.2717e+16 on 155 degrees of freedom
## Residual deviance: 3.8861e+15 on 153 degrees of freedom
## AIC: 5262.7
##
## Number of Fisher Scoring iterations: 2
## Gaussian model (glm object)
## Gaussian model (glm object)
## [1] 3.886072e+15
## [1] 179.5806
y=cpue
muhat=modelo_final$fitted.values
func_var=1
est_pearson=sum((y-modelo_final$fitted.values)^2/func_var)
est_pearson # note que coincide com o Desvio (pelo caso normal)
## [1] 3.886072e+15
qchisq(0.95,156-6)
## [1] 179.5806
| PseudoR2 | Valor |
|---|---|
| McFadden | 0.04980879 |
| McFaddenAdj | 0.04872384 |
| CoxSnell | 0.828936 |
| Nagelkerke | 0.828936 |
fit0<-glm(cpue ~1, family=gaussian)
lr.test(fit0,modelo_final)
## $LR
## [1] 275.4519
##
## $pvalue
## [1] 1.535949e-60
##
## attr(,"class")
## [1] "lrt.test"
## $W
## [1] 755.9393
##
## $pvalue
## [1] 7.077371e-165
##
## attr(,"class")
## [1] "wald.test"
X <- model.matrix(modelo_final)
summary(mdscore(fit0, X1=X[, 2:3], phi=NULL))
modelo3=glm(cpue~ano+trim+latit+long+dia+captura,family=Gamma(link="log"))
summary(modelo3)
##
## Call:
## glm(formula = cpue ~ ano + trim + latit + long + dia + captura,
## family = Gamma(link = "log"))
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -5.799e+01 3.132e+01 -1.852 0.0660 .
## ano 3.802e-02 1.570e-02 2.422 0.0166 *
## trim 2.449e-02 2.293e-02 1.068 0.2871
## latit 5.323e-02 3.185e-02 1.671 0.0968 .
## long -5.941e-02 3.510e-02 -1.693 0.0926 .
## dia -1.049e-01 7.597e-03 -13.810 <2e-16 ***
## captura 5.310e-08 2.366e-09 22.445 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.08006605)
##
## Null deviance: 59.362 on 155 degrees of freedom
## Residual deviance: 14.104 on 149 degrees of freedom
## AIC: 5264.9
##
## Number of Fisher Scoring iterations: 5
stepAIC(modelo3)
## Start: AIC=5264.85
## cpue ~ ano + trim + latit + long + dia + captura
##
## Df Deviance AIC
## - trim 1 14.197 5264.0
## <none> 14.104 5264.9
## - latit 1 14.332 5265.7
## - long 1 14.345 5265.9
## - ano 1 14.565 5268.6
## - dia 1 29.930 5460.5
## - captura 1 51.284 5727.2
##
## Step: AIC=5263.88
## cpue ~ ano + latit + long + dia + captura
##
## Df Deviance AIC
## <none> 14.197 5263.9
## - long 1 14.415 5264.6
## - latit 1 14.476 5265.4
## - ano 1 14.626 5267.3
## - dia 1 30.117 5461.7
## - captura 1 52.009 5736.3
##
## Call: glm(formula = cpue ~ ano + latit + long + dia + captura, family = Gamma(link = "log"))
##
## Coefficients:
## (Intercept) ano latit long dia captura
## -5.536e+01 3.660e-02 5.831e-02 -5.634e-02 -1.054e-01 5.266e-08
##
## Degrees of Freedom: 155 Total (i.e. Null); 150 Residual
## Null Deviance: 59.36
## Residual Deviance: 14.2 AIC: 5264
stepAIC(modelo3, k = log(156))
## Start: AIC=5286.2
## cpue ~ ano + trim + latit + long + dia + captura
##
## Df Deviance AIC
## - trim 1 14.197 5282.3
## - latit 1 14.332 5284.0
## - long 1 14.345 5284.2
## <none> 14.104 5286.2
## - ano 1 14.565 5286.9
## - dia 1 29.930 5478.8
## - captura 1 51.284 5745.5
##
## Step: AIC=5282.18
## cpue ~ ano + latit + long + dia + captura
##
## Df Deviance AIC
## - long 1 14.415 5279.9
## - latit 1 14.476 5280.6
## <none> 14.197 5282.2
## - ano 1 14.626 5282.5
## - dia 1 30.117 5476.9
## - captura 1 52.009 5751.6
##
## Step: AIC=5279.55
## cpue ~ ano + latit + dia + captura
##
## Df Deviance AIC
## - latit 1 14.482 5275.3
## - ano 1 14.803 5279.3
## <none> 14.415 5279.5
## - dia 1 30.955 5480.8
## - captura 1 54.211 5770.8
##
## Step: AIC=5275.24
## cpue ~ ano + dia + captura
##
## Df Deviance AIC
## - ano 1 14.854 5274.8
## <none> 14.482 5275.2
## - dia 1 31.528 5483.7
## - captura 1 59.247 5830.9
##
## Step: AIC=5274.2
## cpue ~ dia + captura
##
## Df Deviance AIC
## <none> 14.854 5274.2
## - dia 1 31.906 5483.7
## - captura 1 59.248 5827.7
##
## Call: glm(formula = cpue ~ dia + captura, family = Gamma(link = "log"))
##
## Coefficients:
## (Intercept) dia captura
## 1.668e+01 -1.079e-01 5.387e-08
##
## Degrees of Freedom: 155 Total (i.e. Null); 153 Residual
## Null Deviance: 59.36
## Residual Deviance: 14.85 AIC: 5265
step(modelo3, direction ="both")
## Start: AIC=5264.85
## cpue ~ ano + trim + latit + long + dia + captura
##
## Df Deviance AIC
## - trim 1 14.197 5264.0
## <none> 14.104 5264.9
## - latit 1 14.332 5265.7
## - long 1 14.345 5265.9
## - ano 1 14.565 5268.6
## - dia 1 29.930 5460.5
## - captura 1 51.284 5727.2
##
## Step: AIC=5263.88
## cpue ~ ano + latit + long + dia + captura
##
## Df Deviance AIC
## <none> 14.197 5263.9
## - long 1 14.415 5264.6
## + trim 1 14.104 5264.7
## - latit 1 14.476 5265.4
## - ano 1 14.626 5267.3
## - dia 1 30.117 5461.7
## - captura 1 52.009 5736.3
##
## Call: glm(formula = cpue ~ ano + latit + long + dia + captura, family = Gamma(link = "log"))
##
## Coefficients:
## (Intercept) ano latit long dia captura
## -5.536e+01 3.660e-02 5.831e-02 -5.634e-02 -1.054e-01 5.266e-08
##
## Degrees of Freedom: 155 Total (i.e. Null); 150 Residual
## Null Deviance: 59.36
## Residual Deviance: 14.2 AIC: 5264
##
## Call:
## glm(formula = cpue ~ ano + latit + long + dia + captura, family = Gamma(link = "log"))
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -5.536e+01 3.118e+01 -1.775 0.0779 .
## ano 3.660e-02 1.562e-02 2.343 0.0204 *
## latit 5.831e-02 3.143e-02 1.856 0.0655 .
## long -5.634e-02 3.490e-02 -1.615 0.1085
## dia -1.054e-01 7.557e-03 -13.953 <2e-16 ***
## captura 5.266e-08 2.345e-09 22.454 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.07969423)
##
## Null deviance: 59.362 on 155 degrees of freedom
## Residual deviance: 14.197 on 150 degrees of freedom
## AIC: 5263.9
##
## Number of Fisher Scoring iterations: 5
## Gamma model
## Gamma model
O residual deviance reflete o quão bem o modelo se ajusta aos dados observados, enquanto o valor crítico qui-quadrado é utilizado para determinar a significância estatística desse ajuste.
modelo_final3$deviance
## [1] 14.19664
qchisq(0.95,156-6)
## [1] 179.5806
y=cpue
muhat=modelo_final3$fitted.values
func_var=1
est_pearson=sum((y-modelo_final3$fitted.values)^2/func_var)
est_pearson # note que coincide com o Desvio (pelo caso normal)
## [1] 1.812648e+16
## [1] 3.886072e+15
qchisq(0.95,156-6)
## [1] 179.5806
## [1] 179.5806
| PseudoR2 | Valor |
|---|---|
| McFadden | 0.04208752 |
| McFaddenAdj | 0.03989795 |
| CoxSnell | 0.7720449 |
| Nagelkerke | 0.7720449 |
fit3<-glm(cpue ~1, family=Gamma(link="log"))
lr.test(fit3,modelo_final3)
## $LR
## [1] 230.6626
##
## $pvalue
## [1] 7.712112e-48
##
## attr(,"class")
## [1] "lrt.test"
wald.test(modelo_final3, terms = 2:5)
## $W
## [1] 191.8328
##
## $pvalue
## [1] 2.140049e-40
##
## attr(,"class")
## [1] "wald.test"
X <- model.matrix(modelo_final3)
summary(mdscore(fit3, X1=X[, 2:5], phi=NULL))
MATOS, Larissa Avila. ME720 - Modelos Lineares Generalizados. Disponível em: https://larissamatos.github.io/Disciplinas/ME_720_2s2019/Parte1.pdf. Acesso em: 22 Junho 2023.
BORDIGNON, Amanda; LIMA, Brendha; LAZZARIN,Giovanna.Trabalho de modelos lineares generalizados. Disponível em: https://docplayer.com.br/129771006-Trabalho-de-modelos-lineares-generalizados.html. Acesso em: 22 Junho 2023.
ROSS, Steven Dutt.COMO INTERPRETAR A RAZÃO DE CHANCES NA REGRESSÃO LOGÍSTICA. Disponível em: https://rpubs.com/StevenDuttRoss/razao_de_chances. Acesso em: 22 Junho 2023.
VALTER, Leandro.Uma Aplicação do MLG nas Medições de Qualidade do Ar New York. Disponível em: https://larissamatos.github.io/Disciplinas/ME_720_2s2019/Parte1.pdf. Acesso em: 22 Junho 2023.
ROCHA, Tiago Costa. Apresentation MLG. Disponível em: https://www.rpubs.com/TiagoCosta/502155 21/06. Acesso em: 22 Junho 2023.
OLINDA, Ricardo Alves de. Introducción a los Modelos Lineales Generalizados: Modelo de Regresión Logistico. Disponível em: https://rpubs.com/ricardo_olinda/USAC_Log. Acesso em: 22 Junho 2023.
VALTER, Leandro. Modelos Lineares Generalizados. Disponível em: https://rpubs.com/ValterL/MLG4 21/06. Acesso em: 22 Junho 2023.
EXISTE R² PARA MODELOS LINEARES GENERALIZADOS (GLMS)?. Disponível em: https://betaanalitica.com.br/existe-r%C2%B2-para-modelos-lineares-generalizados-glms/. Acesso em: 22 Junho 2023.
VALTER, Leandro. MLG. Disponível em: https://rpubs.com/ValterL/mlgfe. Acesso em: 22 Junho 2023.
https://www.icmbio.gov.br/cepsul/images/stories/artes_de_pesca/industrial/espinhel/e