par(mfrow=c(1,2))
plot(variables$DE, variables$DL)
smoothScatter(variables$DE, variables$DL, bandwidth = 0.03)
library(ggplot2)
library(ggplot2)
ggplot(variables)+
geom_boxplot(aes(x=1, y=DE))+
geom_boxplot(aes(x=2, y=DL))
library(growthmodels)
time = 0:10
growth <- blumberg(time, 10, 2, 0.5)
plot(time, growth, pch = 16)
library(growthmodels)
time = 0:10
growth <- blumberg(time, 10, 2, 0.5)
growth[5] = 10
plot(time, growth, pch = 16, cex=2)
boxplot(growth, pch=16)
library(growthmodels)
time = 0:10
growth <- blumberg(time, 10, 2, 0.5)
correlacion = cor(time,growth)
plot(time, growth, pch = 16, cex=2, main = correlacion)
boxplot(growth, pch=16)
library(growthmodels)
time = 0:10
growth <- blumberg(time, 10, 2, 0.5)
correlacion_p = cor(time,growth)
correlacion_s = cor(time,growth, method='spearman')
plot(time, growth, pch = 16, cex=2, main = correlacion_s)
boxplot(growth, pch=16)
library(growthmodels)
time = 0:10
growth <- blumberg(time, 10, 2, 0.5)
correlacion_p = cor(time,growth)
correlacion_s = cor(time,growth, method='spearman')
correlacion_k = cor(time,growth, method='kendall')
plot(time, growth, pch = 16, cex=2, main = correlacion_k)
boxplot(growth, pch=16)
curve(expr = x^2,from = 0,to = 10)
curve(expr = 0.5*x^3,from = 0,to = 10)
# Funciones APPLY
apply(variables, MARGIN = 2, FUN = median)
## DE DL
## 4.52 5.23
apply(variables, MARGIN = 2, FUN = min)
## DE DL
## 3.82 4.52
apply(variables, MARGIN = 2, FUN = max)
## DE DL
## 5.28 5.92
apply(variables, MARGIN = 2, FUN = var)
## DE DL
## 0.0796 0.0837
# Matriz de varianzas y covarianzas
cov(variables)
## DE DL
## DE 0.0796 0.0548
## DL 0.0548 0.0837
#Matriz Correlaciones
cor(variables)
## DE DL
## DE 1.000 0.672
## DL 0.672 1.000
ggplot(variables)+
geom_density(aes(DE), fill = 'green', alpha=0.5)+
geom_density(aes(DL), fill = 'blue', alpha=0.5)
mi_scorez=function(x)
{z=(x-mean(x))/sd(x)
return(z)}
mi_scorez = function(x){
z = (x-mean(x))/sd(x)
return(z)
}
mi_scorez(variables$DE)
## [1] -0.36147 -0.47159 1.48081 0.08729 0.41222 1.54242 0.65873 -0.61741
## [9] -0.63016 -0.97372 1.30329 -0.05721 0.97033 -0.00348 -0.90285 1.45820
## [17] 0.29914 -1.75138 0.91987 -0.13748 -1.21933 0.07477 -0.90896 -0.72588
## [25] -1.55759 -1.47586 0.57010 -0.02148 -0.80815 1.10830 -0.36412 -0.62069
## [33] 0.71169 0.90110 1.57026 0.02828 1.04854 -0.52337 -1.27818 0.13806
## [41] -1.11801 -0.21967 -0.66026 2.63339 1.74319 -0.98490 0.12433 -0.89145
## [49] -0.31345 0.35557 -0.23993 -0.50404 -0.32399 1.63516 -0.30029 1.45495
## [57] -1.88180 0.59521 -0.44904 0.23985 -0.23546 -0.15490 0.10219 -2.55807
## [65] -0.98593 0.02587 0.01552 0.13085 0.52681 1.68245 -0.51407 -2.39581
## [73] 0.85202 -1.76525 -0.47099 1.34253 -0.42710 -1.45269 -0.15364 -0.06589
## [81] 0.34243 -0.32342 -0.33814 0.87182 -0.24333 0.27306 0.43230 0.24787
## [89] -0.78480 1.19678 0.72989 0.53901 0.05363 -0.34454 1.76171 -1.60171
## [97] 1.71223 1.90148 -0.09163 -0.60092
mi_scorez(variables$DL)
## [1] -0.9107 -0.1875 1.4625 -0.1153 -0.2930 1.7037 0.1155 -2.0168 -0.9109
## [10] -0.1488 0.9870 0.5609 -0.2755 0.0415 -0.4204 1.9146 0.5053 -2.3364
## [19] 0.3384 -0.9439 -1.1081 -0.6503 -1.3050 -0.9054 0.0309 -2.0515 0.9078
## [28] 0.1383 -1.6069 1.2167 0.9600 -0.1777 0.8904 0.6898 -0.0124 1.1073
## [37] -0.0551 0.1771 0.3865 -1.0142 -0.4919 -0.3694 -1.9794 1.5927 0.5652
## [46] -1.4213 -1.0444 -0.2617 1.5841 -0.6452 0.5218 0.2231 0.0359 0.9654
## [55] -0.3315 1.4056 -1.4293 0.4062 0.4627 0.0243 0.7569 -0.9843 -0.8928
## [64] 0.1758 -1.3232 0.3804 0.6635 -0.1872 1.1062 2.2134 -0.6435 -2.4117
## [73] 0.9750 0.0563 -1.0547 0.5763 -0.3304 -1.1900 0.3087 -0.3755 -0.4648
## [82] 0.8459 -0.5721 0.2733 -0.3721 0.2141 1.5207 0.4322 -0.0901 0.9392
## [91] 1.0604 0.3876 0.2331 -1.0534 0.8378 0.1171 2.4467 1.0390 -0.5358
## [100] -1.5797
var_z = apply(variables, 2, mi_scorez)
colMeans(var_z)
## DE DL
## 6.36e-16 1.51e-15
apply(var_z, 2, var)
## DE DL
## 1 1
var_z = as.data.frame(var_z)
ggplot(var_z)+
geom_density(aes(DE), fill = 'green', alpha=0.5)+
geom_density(aes(DL), fill = 'blue', alpha=0.5)
cor(variables)
## DE DL
## DE 1.000 0.672
## DL 0.672 1.000
cor(var_z)
## DE DL
## DE 1.000 0.672
## DL 0.672 1.000
\[cv=100*\frac{s}{\bar{x}}\]
par(mfrow=c(1,2))
plot(variables$DE, variables$DL, pch = 16, asp=1)
plot(var_z$DE, var_z$DL, pch = 16, asp=1)
set.seed(123)
mi_excen = function(diam_menor, diam_mayor){
a = diam_mayor/2
b = diam_menor/2
c = sqrt(a^2 - b^2)
e = c/a
return(e)}
variables$EXC = mi_excen(
diam_menor = variables$DE,
diam_mayor = variables$DL)
hist(variables$EXC)
abline(v=mean(variables$EXC), lwd=2, col='red')
abline(v=quantile(variables$EXC, 0.05), lwd=2, col='blue')
#Usar la funcion ‘mi_excen’ para calcular también el cociente $DL’..