Importacion Datos

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)
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

Agua sub

water<-read.table("ion_waters.csv",head=T,dec=".",sep=",")
View(water)
player2 <- water[,1:3] 
View(ion_waters)
aguasub <- subset(water, type == "GW")
aguasub
##    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

Subconjutos de Datos para agua superf

water<-read.table("ion_waters.csv",head=T,dec=".",sep=",")
View(water)
player2 <- water[,1:3] 
View(ion_waters)
aguasuperf <- subset(water, type == "S")
aguasuperf
##    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

Comparacion de medias Nitrato

var.test(aguasub$n.nitrate,aguasuperf$n.nitrate)
## 
##  F test to compare two variances
## 
## data:  aguasub$n.nitrate and aguasuperf$n.nitrate
## F = 0.019781, num df = 10, denom df = 7, p-value = 1.041e-06
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.00415479 0.07813321
## sample estimates:
## ratio of variances 
##         0.01978144

Hipotesis nula: No se encuentran variaciones significativas en la varianza 0, y en caso de la hipotesis alternativa: si hay variacion de varianza(1) Prueba T: significancia de promedio Resultado: no hay diferencia en el promedio porque dio ¨no igual a 1¨

t.test(aguasuperf$n.nitrate,aguasub$n.nitrate, mu = 0, paired = FALSE, var.equal=FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  aguasuperf$n.nitrate and aguasub$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 se encuentran variaciones significativas en la varianza 0, y en caso de la hipotesis alternativa: si hay variacion de varianza(1) Resultado: no hay diferencia en el promedio porque dio ¨no igual a 1

t.test(aguasuperf$n.nitrate, aguasub$n.nitrate, mu = 0, paired = FALSE, var.equal=FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  aguasuperf$n.nitrate and aguasub$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

SULFATO

var.test(aguasuperf$sulphate, aguasub$sulphate)
## 
##  F test to compare two variances
## 
## data:  aguasuperf$sulphate and aguasub$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 se encuentran variaciones significativas en la varianza 0, y en caso de la hipotesis alternativa: si hay variacion de varianza(1) Prueba T: significancia de promedio sulfato Resultado: no hay diferencia en el promedio porque dio ¨no igual a 1¨

t.test(aguasuperf$sulphate, aguasub$sulphate, mu = 0, paired = FALSE, var.equal=FALSE)
## 
##  Welch Two Sample t-test
## 
## data:  aguasuperf$sulphate and aguasub$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 se encuentran variaciones significativas en la varianza 0, y en caso de la hipotesis alternativa: si hay variacion de varianza(1) Resultado: no hay diferencia en el promedio porque dio ¨no igual a 1¨

GRAFICAR VARIABLES

library(ggplot2)
plot(aguasub$n.nitrate,aguasub$sulphate,pch=19,col="green",cex=1)

plot(aguasuperf$sulphate,aguasuperf$n.nitrate,pch=19,col="blue",cex=1)

library(ggplot2)
plot(aguasub$n.nitrate,aguasub$.nitrate,pch=19,col="green",cex=1)

plot(aguasuperf$n.nitrate,aguasuperf$n.nitrate,pch=19,col="RED",cex=1)

plot(aguasub$sulphate,aguasub$sulphate,pch=19,col="PINK",cex=1)

ggplot(data = water) +
geom_point(aes(x = n.nitrate, y = sulphate), col='blue')

MODELO DE REGRESION LINEAL EL GRAFICO AZUL DE ARRIBA

WW=lm(aguasub$n.nitrate ~ aguasub$sulphate)
WW
## 
## Call:
## lm(formula = aguasub$n.nitrate ~ aguasub$sulphate)
## 
## Coefficients:
##      (Intercept)  aguasub$sulphate  
##          0.19612           0.01195
plot(WW,which=1)

WS=lm(aguasuperf$n.nitrate ~ aguasuperf$sulphate)
WS
## 
## Call:
## lm(formula = aguasuperf$n.nitrate ~ aguasuperf$sulphate)
## 
## Coefficients:
##         (Intercept)  aguasuperf$sulphate  
##             0.14060              0.06992
plot(WS,which=1)