Andrea <- read.csv("~/Desktop/Andrea.csv")
x<-Andrea$Concentración
y<-Andrea$Absorbancia
#Covarianza
cov(x,y)
## [1] 0.002511518
#Correlación
cor(x,y)
## [1] 0.9696036
#Normalidad
library(pastecs)
stat.desc(Andrea, norm = TRUE)
## Concentración Absorbancia
## nbr.val 8.000000000 8.000000000
## nbr.null 0.000000000 0.000000000
## nbr.na 0.000000000 0.000000000
## min 0.005000000 0.030000000
## max 0.080000000 0.306000000
## range 0.075000000 0.276000000
## sum 0.325000000 1.119000000
## median 0.040000000 0.132000000
## mean 0.040625000 0.139875000
## SE.mean 0.010019512 0.032315099
## CI.mean.0.95 0.023692382 0.076413067
## var 0.000803125 0.008354125
## std.dev 0.028339460 0.091400903
## coef.var 0.697586711 0.653447025
## skewness 0.058117154 0.419039395
## skew.2SE 0.038636513 0.278579043
## kurtosis -1.840910489 -1.164925382
## kurt.2SE -0.621559442 -0.393321878
## normtest.W 0.934752632 0.958051849
## normtest.p 0.560298420 0.791350936
#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=Andrea, ellipses = FALSE, lm = TRUE, method = "spearman")

#Regresión lineal
Reg<-lm(y~x, Andrea)
summary(Reg)
##
## Call:
## lm(formula = y ~ x, data = Andrea)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.025736 -0.019260 0.000213 0.008919 0.042992
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.01283 0.01563 0.821 0.443
## x 3.12718 0.32217 9.707 6.86e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.02416 on 6 degrees of freedom
## Multiple R-squared: 0.9401, Adjusted R-squared: 0.9302
## F-statistic: 94.22 on 1 and 6 DF, p-value: 6.862e-05
plot(y~x,Andrea)
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,Andrea)
anova(Cur_Polif)
## Analysis of Variance Table
##
## Response: y
## Df Sum Sq Mean Sq F value Pr(>F)
## x 1 0.054978 0.054978 94.219 6.862e-05 ***
## Residuals 6 0.003501 0.000584
## ---
## 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.92304, p-value = 0.455
#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 = 5.2314, df = 1, p-value = 0.02218
#Independencia (Durbin-Watson) (no hay independencia)
dwtest(y~x)
##
## Durbin-Watson test
##
## data: y ~ x
## DW = 1.6369, p-value = 0.1363
## alternative hypothesis: true autocorrelation is greater than 0
#Ho: hay independencia
#Ha: no hay independencia