Documentos de Académico
Documentos de Profesional
Documentos de Cultura
2023-11-19
library(readxl)
library(dplyr)
##
## Attaching package: 'dplyr'
library(ggplot2)
library(ggpmisc)
##
## Attaching package: 'ggpp'
##
## Attaching package: 'ggpmisc'
## The following object is masked from 'package:ggpp':
##
## quadrant_example.df
##
## Call:
## lm(formula = Lt ~ Le, data = Hoplias_LtvsLe)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.60199 -0.31110 -0.01126 0.28884 1.76169
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.102871 0.128245 8.6 <2e-16 ***
## Le 1.181782 0.005546 213.1 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4264 on 1062 degrees of freedom
## Multiple R-squared: 0.9771, Adjusted R-squared: 0.9771
## F-statistic: 4.541e+04 on 1 and 1062 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = Lt ~ Le, data = hoplias_machos)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.98941 -0.32319 -0.02362 0.29528 1.75340
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.037227 0.182341 5.688 2.08e-08 ***
## Le 1.184681 0.007967 148.690 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4123 on 555 degrees of freedom
## Multiple R-squared: 0.9755, Adjusted R-squared: 0.9755
## F-statistic: 2.211e+04 on 1 and 555 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = Lt ~ Le, data = hoplias_hembras)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.59925 -0.30217 -0.01541 0.28281 1.47295
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.158502 0.183466 6.315 5.94e-10 ***
## Le 1.179370 0.007846 150.318 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.4421 on 505 degrees of freedom
## Multiple R-squared: 0.9781, Adjusted R-squared: 0.9781
## F-statistic: 2.26e+04 on 1 and 505 DF, p-value: < 2.2e-16
##Regresión Potencial
Hoplias_RPE <- subset(Hoplias_malabaricus,!is.na(Pe) & !is.na(Lt))
##
## Call:
## lm(formula = log(Pe) ~ log(Lt), data = Hoplias_RPE)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.222742 -0.039930 -0.000657 0.041526 0.277688
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.77023 0.06681 -71.4 <2e-16 ***
## log(Lt) 3.06090 0.02001 153.0 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.06428 on 1061 degrees of freedom
## Multiple R-squared: 0.9566, Adjusted R-squared: 0.9566
## F-statistic: 2.34e+04 on 1 and 1061 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = log(Pe) ~ log(Lt), data = hoplias_machos)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.218672 -0.038689 0.000297 0.040132 0.270072
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.65546 0.09213 -50.53 <2e-16 ***
## log(Lt) 3.02603 0.02767 109.38 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.0606 on 554 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.9557, Adjusted R-squared: 0.9557
## F-statistic: 1.196e+04 on 1 and 554 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = log(Pe) ~ log(Lt), data = hoplias_hembras)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.207000 -0.041281 0.001633 0.042724 0.245638
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.86355 0.09773 -49.77 <2e-16 ***
## log(Lt) 3.08921 0.02918 105.86 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.06803 on 505 degrees of freedom
## Multiple R-squared: 0.9569, Adjusted R-squared: 0.9568
## F-statistic: 1.121e+04 on 1 and 505 DF, p-value: < 2.2e-16
##Estimación de párametros
intercept <- exp(coef(fit2)[1])
intercept
## (Intercept)
## 0.00847847
## [1] 0.02000777
##Tipo de crecimiento
#Estadístico de prueba
#$t_{n-2}= \frac{b-β}{EE_b}$
t <- (3-slope)/std_error_slope
## log(Lt)
## 0.002360499
##Modelo logistico
#Grafica
ggplot(data = Hoplias_malabaricus, aes(x = Lt, y = Madurez)) +
geom_point()+ ggtitle(expression(paste("Relación entre Longitud Total y
Madurez en ", italic("Hoplias malabaricus"))))+theme_classic()
ggplot(data = Hoplias_malabaricus, aes(x = Lt, y = Madurez)) +
geom_point() +geom_smooth(method = "glm", method.args = list(family =
"binomial"), se = FALSE, color = "red")+ ggtitle("Modelo ajustado")
+theme_classic()
##
## Call:
## glm(formula = Madurez ~ Lt, family = "binomial", data =
Hoplias_malabaricus)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.4235 -0.9141 -0.6360 1.1377 2.3427
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -9.54751 0.80477 -11.86 <2e-16 ***
## Lt 0.31953 0.02808 11.38 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 1422.2 on 1063 degrees of freedom
## Residual deviance: 1258.6 on 1062 degrees of freedom
## AIC: 1262.6
##
## Number of Fisher Scoring iterations: 3
##
## Call:
## glm(formula = Madurez ~ Lt, family = "binomial", data = hoplias_machos)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.2078 -0.7588 -0.5855 0.9324 2.2107
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -10.17299 1.23468 -8.239 < 2e-16 ***
## Lt 0.32182 0.04278 7.523 5.35e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 644.94 on 556 degrees of freedom
## Residual deviance: 576.87 on 555 degrees of freedom
## AIC: 580.87
##
## Number of Fisher Scoring iterations: 4
##
## Call:
## glm(formula = Madurez ~ Lt, family = "binomial", data = hoplias_hembras)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -2.1654 -1.0275 0.4423 1.0641 2.1100
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -8.94694 1.12229 -7.972 1.56e-15 ***
## Lt 0.31791 0.03949 8.051 8.20e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 701.62 on 506 degrees of freedom
## Residual deviance: 617.15 on 505 degrees of freedom
## AIC: 621.15
##
## Number of Fisher Scoring iterations: 3
# Calcula el log(odds)
log_odds <- -9.54751 + 0.31953 * longitud_total
# Carga de bibliotecas
library(ggplot2)
# Datos
longitudes <- seq(0, 50, by = 1) # Cambia según el rango de tus datos
probabilidades <- modelo_logistico(longitudes)
# Gráfico
ggplot(df, aes(x = Longitud_Total, y = Prob_Madurez)) +
geom_line(color = "blue", size = 1) +
geom_hline(yintercept = 1 , linetype = "dashed", color = "red") +
labs(x = "Longitud Total", y = "Probabilidad de Madurez") +
ggtitle("Relación entre Longitud Total y Probabilidad de Madurez") +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.