library(readr)
ion_waters <- read_csv("ion_waters.csv")
## Rows: 19 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): type
## dbl (2): n.nitrate, sulphate
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
View(ion_waters)
str(ion_waters)
## spc_tbl_ [19 × 3] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ type : chr [1:19] "GW" "S" "S" "GW" ...
## $ n.nitrate: num [1:19] 0.2 0.98 0.59 0.19 0.46 0.2 0.31 0.27 0.33 0.2 ...
## $ sulphate : num [1:19] 2.57 10.82 4.99 2.43 7.04 ...
## - attr(*, "spec")=
## .. cols(
## .. type = col_character(),
## .. n.nitrate = col_double(),
## .. sulphate = col_double()
## .. )
## - attr(*, "problems")=<externalptr>
summary(ion_waters)
## type n.nitrate sulphate
## Length:19 Min. :0.1900 Min. : 0.810
## Class :character 1st Qu.:0.2000 1st Qu.: 2.020
## Mode :character Median :0.2700 Median : 2.810
## Mean :0.3232 Mean : 3.329
## 3rd Qu.:0.3200 3rd Qu.: 3.715
## Max. :0.9800 Max. :10.820
Aguas <- read.table("ion_waters.csv",head=T,dec=".",sep=",")
View(Aguas)
Aguas_GW <- Aguas[,1:3]
View(Aguas_GW)
GW <- subset(Aguas , type == "GW")
GW
## type n.nitrate sulphate
## 1 GW 0.20 2.57
## 4 GW 0.19 2.43
## 6 GW 0.20 3.12
## 8 GW 0.27 2.68
## 10 GW 0.20 0.81
## 11 GW 0.23 3.68
## 12 GW 0.26 4.01
## 15 GW 0.26 1.41
## 16 GW 0.27 2.93
## 17 GW 0.20 1.92
## 19 GW 0.20 1.43
Aguas <- read.table("ion_waters.csv",head=T,dec=".",sep=",")
View(Aguas)
Aguas_S <- Aguas[,1:3]
View(Aguas_S)
S <- subset(Aguas , type == "S")
S
## type n.nitrate sulphate
## 2 S 0.98 10.82
## 3 S 0.59 4.99
## 5 S 0.46 7.04
## 7 S 0.31 3.75
## 9 S 0.33 1.83
## 13 S 0.40 2.81
## 14 S 0.30 2.90
## 18 S 0.29 2.12
Prueba F nitrato
var.test(S$n.nitrate,GW$n.nitrate)
##
## F test to compare two variances
##
## data: S$n.nitrate and GW$n.nitrate
## F = 50.552, num df = 7, denom df = 10, p-value = 1.041e-06
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 12.79866 240.68604
## sample estimates:
## ratio of variances
## 50.55244
Hipotesis nula: NO hay variaciones significativas en la varianza (0) Hipotesis alternativa: SI hay variaciones significativas en la varianza (1)
RESULTADO: 0 (NO ES SIGNIFICATIVO)
Prueba T
t.test(S$n.nitrate, GW$n.nitrate, mu = 0, paired = FALSE, var.equal = FALSE)
##
## Welch Two Sample t-test
##
## data: S$n.nitrate and GW$n.nitrate
## t = 2.7796, df = 7.2018, p-value = 0.02655
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.03575589 0.42833502
## sample estimates:
## mean of x mean of y
## 0.4575000 0.2254545
Hipotesis nula: NO hay variaciones significativas en el promedio (0) Hipotesis alternativa: SI hay variaciones significativas en el promedio (1)
RESULTADO: 1 (SI ES SIGNIFICATIVO)
Prueba F sulfato
var.test(S$sulphate,GW$sulphate)
##
## F test to compare two variances
##
## data: S$sulphate and GW$sulphate
## F = 9.547, num df = 7, denom df = 10, p-value = 0.001975
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
## 2.417057 45.454144
## sample estimates:
## ratio of variances
## 9.546951
Hipotesis nula: NO hay variaciones significativas en la varianza (0) Hipotesis alternativa: SI hay variaciones significativas en la varianza (1)
RESULTADO: 0 (NO ES SIGNIFICATIVO)
Prueba T sulfato
t.test(S$sulphate, GW$sulphate, mu = 0, paired = FALSE, var.equal = FALSE)
##
## Welch Two Sample t-test
##
## data: S$sulphate and GW$sulphate
## t = 1.8544, df = 8.0743, p-value = 0.1005
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.5021694 4.6598967
## sample estimates:
## mean of x mean of y
## 4.532500 2.453636
Hipotesis nula: NO hay variaciones significativas en el promedio (0) Hipotesis alternativa: SI hay variaciones significativas en el promedio (1)
RESULTADO: 1 (SI ES SIGNIFICATIVO)
Grafico
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.3.3
plot(GW$n.nitrate,GW$sulphate,pch=19,col="blue",cex=1)
plot(S$n.nitrate,S$sulphate,pch=19,col="red",cex=1)
Regresion Lineal Aguas subterraneas
model=lm(GW$n.nitrate ~ GW$sulphate)
model
##
## Call:
## lm(formula = GW$n.nitrate ~ GW$sulphate)
##
## Coefficients:
## (Intercept) GW$sulphate
## 0.19612 0.01195
plot(GW$sulphate,GW$n.nitrate,pch=19,col="blue",cex=1)
abline(model,col="red")
summary(model)
##
## Call:
## lm(formula = GW$n.nitrate ~ GW$sulphate)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.03517 -0.02296 -0.01012 0.02740 0.04702
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.19612 0.02726 7.193 5.12e-05 ***
## GW$sulphate 0.01195 0.01037 1.153 0.279
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03245 on 9 degrees of freedom
## Multiple R-squared: 0.1286, Adjusted R-squared: 0.0318
## F-statistic: 1.328 on 1 and 9 DF, p-value: 0.2788
plot(model,which=1)
Regresion Lineal Aguas Superficiales
model=lm(S$n.nitrate ~ S$sulphate)
model
##
## Call:
## lm(formula = S$n.nitrate ~ S$sulphate)
##
## Coefficients:
## (Intercept) S$sulphate
## 0.14060 0.06992
plot(GW$sulphate,GW$n.nitrate,pch=19,col="blue",cex=1)
abline(model,col="red")
summary(model)
##
## Call:
## lm(formula = S$n.nitrate ~ S$sulphate)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.17281 -0.05572 0.03131 0.06792 0.10051
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.14060 0.06901 2.037 0.08775 .
## S$sulphate 0.06992 0.01288 5.429 0.00162 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1041 on 6 degrees of freedom
## Multiple R-squared: 0.8309, Adjusted R-squared: 0.8027
## F-statistic: 29.48 on 1 and 6 DF, p-value: 0.001618
plot(model,which=1)