Miranda <- read.csv("~/Desktop/Miranda.csv")
x<-Miranda$Concentración
y<-Miranda$Absrobancia
#Covarianza
cov(x,y)
## [1] 0.005581339
#Correlación
cor(x,y)
## [1] 0.9872343
#Normalidad
library(pastecs)
stat.desc(Miranda, norm = TRUE)
## Concentración Absrobancia
## nbr.val 8.000000000 8.00000000
## nbr.null 0.000000000 0.00000000
## nbr.na 0.000000000 0.00000000
## min 0.005000000 0.05600000
## max 0.080000000 0.61700000
## range 0.075000000 0.56100000
## sum 0.325000000 2.62500000
## median 0.040000000 0.33300000
## mean 0.040625000 0.32812500
## SE.mean 0.010019512 0.07053126
## CI.mean.0.95 0.023692382 0.16677993
## var 0.000803125 0.03979727
## std.dev 0.028339460 0.19949253
## coef.var 0.697586711 0.60797722
## skewness 0.058117154 0.02185149
## skew.2SE 0.038636513 0.01452696
## kurtosis -1.840910489 -1.65340157
## kurt.2SE -0.621559442 -0.55824950
## normtest.W 0.934752632 0.96591814
## normtest.p 0.560298420 0.86419566
#Prueba de Spearman
cor.test(x,y, method = "spearman")
##
## Spearman's rank correlation rho
##
## data: x and y
## S = 0, p-value = 4.96e-05
## alternative hypothesis: true rho is not equal to 0
## sample estimates:
## rho
## 1
library(psych)
pairs.panels(x=Miranda, ellipses = FALSE, lm = TRUE, method = "spearman")

#Regresión lineal
Reg<-lm(y~x, Miranda)
summary(Reg)
##
## Call:
## lm(formula = y ~ x, data = Miranda)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.042277 -0.020966 -0.003282 0.015730 0.060714
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0458 0.0222 2.063 0.0847 .
## x 6.9495 0.4577 15.183 5.15e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03432 on 6 degrees of freedom
## Multiple R-squared: 0.9746, Adjusted R-squared: 0.9704
## F-statistic: 230.5 on 1 and 6 DF, p-value: 5.151e-06
plot(y~x,Miranda)
abline(Reg)

#ANOVA (para ver la relación entre las variable)
#Hó: No existe relación
#Ha: Existe relación
Cur_Polif<-aov(y~x,Miranda)
anova(Cur_Polif)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## x 1 0.271514 0.271514 230.51 5.151e-06 ***
## Residuals 6 0.007067 0.001178
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Supuestos
#Normalidad (no se rechaza, se cumple normalidad)
shapiro.test(Cur_Polif$residuals)
##
## Shapiro-Wilk normality test
##
## data: Cur_Polif$residuals
## W = 0.95656, p-value = 0.7768
#Homogeneidad de variaza (Breush-Pagan)(no se recahza, cumple la homogeneidad)
library(lmtest)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
bptest(Cur_Polif)
##
## studentized Breusch-Pagan test
##
## data: Cur_Polif
## BP = 0.1582, df = 1, p-value = 0.6908
#Independencia (Durbin-Watson) (no hay independencia)
dwtest(y~x)
##
## Durbin-Watson test
##
## data: y ~ x
## DW = 2.061, p-value = 0.3407
## alternative hypothesis: true autocorrelation is greater than 0
#Ho: hay independencia
#Ha: no hay independencia