Brian <- read.csv("~/Desktop/Brian.csv")
x<-Brian$Concentración
y<-Brian$Absorbancia
#Covarianza
cov(x,y)
## [1] 0.007944821
#Correlación
cor(x,y)
## [1] 0.9920163
#Normalidad
library(pastecs)
stat.desc(Brian, norm = TRUE)
## Concentración Absorbancia
## nbr.val 8.000000000 8.00000000
## nbr.null 0.000000000 0.00000000
## nbr.na 0.000000000 0.00000000
## min 0.005000000 0.04300000
## max 0.080000000 0.82500000
## range 0.075000000 0.78200000
## sum 0.325000000 3.31400000
## median 0.040000000 0.39550000
## mean 0.040625000 0.41425000
## SE.mean 0.010019512 0.09991456
## CI.mean.0.95 0.023692382 0.23626040
## var 0.000803125 0.07986336
## std.dev 0.028339460 0.28260106
## coef.var 0.697586711 0.68219929
## skewness 0.058117154 0.09412565
## skew.2SE 0.038636513 0.06257510
## kurtosis -1.840910489 -1.70561644
## kurt.2SE -0.621559442 -0.57587917
## normtest.W 0.934752632 0.95913164
## normtest.p 0.560298420 0.80178816
#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=Brian, ellipses = FALSE, lm = TRUE, method = "spearman")

#Regresión lineal
Reg<-lm(y~x, Brian)
summary(Reg)
##
## Call:
## lm(formula = y ~ x, data = Brian)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.072991 -0.008395 0.003933 0.020145 0.047857
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.01237 0.02490 0.497 0.637
## x 9.89238 0.51340 19.268 1.26e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03849 on 6 degrees of freedom
## Multiple R-squared: 0.9841, Adjusted R-squared: 0.9814
## F-statistic: 371.3 on 1 and 6 DF, p-value: 1.265e-06
plot(y~x,Brian)
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,Brian)
anova(Cur_Polif)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## x 1 0.55015 0.55015 371.27 1.265e-06 ***
## Residuals 6 0.00889 0.00148
## ---
## 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.92087, p-value = 0.437
#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.035607, df = 1, p-value = 0.8503
#Independencia (Durbin-Watson) (no hay independencia)
dwtest(y~x)
##
## Durbin-Watson test
##
## data: y ~ x
## DW = 2.3751, p-value = 0.5353
## alternative hypothesis: true autocorrelation is greater than 0
#Ho: hay independencia
#Ha: no hay independencia