Está en la página 1de 13

Tarea 1.

Confiabilidad
Salinas René Uriel
24 de septiembre de 2018

Problema 1.

Dados los siguientes tiempos de vida (semanas):


4.30 14.76 13.03 17.15 7.12 1.00 19.30 6.43 17.59 1.51
3.33 11.54 3.66 7.10 8.93 0.31 0.26 3.61 3.04 1.78
23.32 0.40 5.90 43.39 0.20 13.05 0.59 2.98 11.00 5.76
18.39 2.42 11.45 8.61 1.23 14.68 13.11 5.62 16.43 7.80
8.65 1.31 6.29 6.55 3.83 8.47 33.49 9.14 18.11 7.05
26.74 19.42 12.56 1.18 16.38 27.39 1.93 17.48 5.79 21.03
6.60 16.55 10.73 5.37 37.29 3.76 2.69 8.28 12.67 2.31
3.10 6.12 19.68 0.85 5.62 3.59 6.49 0.95 4.53 26.41
19.94 30.93 13.79 2.83 0.93 20.62 23.13 0.42 16.44 6.35
2.55 3.73 1.35 22.96 3.62 11.00 1.10 1.35 29.53 10.76
+ Calcule la función de supervivencia empírica Sn(t)
Solución:
S(t) = P (un individuo viva mas que t)
S(t) = P (T > t)
la cual se puede estimar como:
sobrevivientes hasta t
Ŝ(t) = total de individuos

Utilizando la función generada en el problema 6:


sprvivint<-function(datos){
Datos<-sort(datos)
sup<-max(datos)
total<-length(datos)
muertos<-c(0)
tmps<-c(0)
ss<-c()
s<-1
fv<-c()
tiempo<-0:sup+1
reps<-c(0)
for ( i in 1:length(Datos)) {

rep<-0
v<-Datos[i]
for (j in 1:length(Datos))
{
if (v == Datos[j]){

1
rep<-rep+1
}
}
muertos<-rep
vivos<-total-muertos
reps<-c(reps,rep)
tmps<-c(tmps,v)
}
matriz<-cbind(tmps,reps)
unique(matriz)
matriz<-matriz[!duplicated(matriz), ]

tmps<-as.numeric(matriz[,1])
mrt<-as.numeric(matriz[,2])
for (i in 1:length(tmps)){
f<-mrt[i]/length(datos)
fv<-c(fv,f)
s<-round(s-f,5)
ss<-c(ss,s)
}
matriz<-cbind(tmps,mrt,ss)
print(matriz)
plot(tmps,ss,type = "s")
}

Datos<-c(4.30,14.76,13.03,17.15,7.12,1.00,19.30,6.43,17.59,1.51,3.33,11.54,3.66,7.10,8.93,0.31,0.26,3.61

sprvivint(Datos)

## tmps mrt ss
## [1,] 0.00 0 1.00
## [2,] 0.20 1 0.99
## [3,] 0.26 1 0.98
## [4,] 0.31 1 0.97
## [5,] 0.40 1 0.96
## [6,] 0.42 1 0.95
## [7,] 0.59 1 0.94
## [8,] 0.85 1 0.93
## [9,] 0.93 1 0.92
## [10,] 0.95 1 0.91
## [11,] 1.00 1 0.90
## [12,] 1.10 1 0.89
## [13,] 1.18 1 0.88
## [14,] 1.23 1 0.87
## [15,] 1.31 1 0.86
## [16,] 1.35 2 0.84
## [17,] 1.51 1 0.83
## [18,] 1.78 1 0.82
## [19,] 1.93 1 0.81
## [20,] 2.31 1 0.80
## [21,] 2.42 1 0.79
## [22,] 2.55 1 0.78
## [23,] 2.69 1 0.77

2
## [24,] 2.83 1 0.76
## [25,] 2.98 1 0.75
## [26,] 3.04 1 0.74
## [27,] 3.10 1 0.73
## [28,] 3.33 1 0.72
## [29,] 3.59 1 0.71
## [30,] 3.61 1 0.70
## [31,] 3.62 1 0.69
## [32,] 3.66 1 0.68
## [33,] 3.73 1 0.67
## [34,] 3.76 1 0.66
## [35,] 3.83 1 0.65
## [36,] 4.30 1 0.64
## [37,] 4.53 1 0.63
## [38,] 5.37 1 0.62
## [39,] 5.62 2 0.60
## [40,] 5.76 1 0.59
## [41,] 5.79 1 0.58
## [42,] 5.90 1 0.57
## [43,] 6.12 1 0.56
## [44,] 6.29 1 0.55
## [45,] 6.35 1 0.54
## [46,] 6.43 1 0.53
## [47,] 6.49 1 0.52
## [48,] 6.55 1 0.51
## [49,] 6.60 1 0.50
## [50,] 7.05 1 0.49
## [51,] 7.10 1 0.48
## [52,] 7.12 1 0.47
## [53,] 7.80 1 0.46
## [54,] 8.28 1 0.45
## [55,] 8.47 1 0.44
## [56,] 8.61 1 0.43
## [57,] 8.65 1 0.42
## [58,] 8.93 1 0.41
## [59,] 9.14 1 0.40
## [60,] 10.73 1 0.39
## [61,] 10.76 1 0.38
## [62,] 11.00 2 0.36
## [63,] 11.45 1 0.35
## [64,] 11.54 1 0.34
## [65,] 12.56 1 0.33
## [66,] 12.67 1 0.32
## [67,] 13.03 1 0.31
## [68,] 13.05 1 0.30
## [69,] 13.11 1 0.29
## [70,] 13.79 1 0.28
## [71,] 14.68 1 0.27
## [72,] 14.76 1 0.26
## [73,] 16.38 1 0.25
## [74,] 16.43 1 0.24
## [75,] 16.44 1 0.23
## [76,] 16.55 1 0.22
## [77,] 17.15 1 0.21

3
## [78,] 17.48 1 0.20
## [79,] 17.59 1 0.19
## [80,] 18.11 1 0.18
## [81,] 18.39 1 0.17
## [82,] 19.30 1 0.16
## [83,] 19.42 1 0.15
## [84,] 19.68 1 0.14
## [85,] 19.94 1 0.13
## [86,] 20.62 1 0.12
## [87,] 21.03 1 0.11
## [88,] 22.96 1 0.10
## [89,] 23.13 1 0.09
## [90,] 23.32 1 0.08
## [91,] 26.41 1 0.07
## [92,] 26.74 1 0.06
## [93,] 27.39 1 0.05
## [94,] 29.53 1 0.04
## [95,] 30.93 1 0.03
## [96,] 33.49 1 0.02
## [97,] 37.29 1 0.01
## [98,] 43.39 1 0.00
1.0
0.8
0.6
ss

0.4
0.2
0.0

0 10 20 30 40

tmps

+ Estime la probabilidad de que el tiempo de vida sea mayor que 20 semanas


Solución:
probsupervivencia<-function(datos,cuantil){

4
sup<-max(datos)
total<-length(datos)
c<-0
for (p in 1:total){
if(datos[p]>cuantil) {
c<-c+1
}
}
s<-c/total
print(s)
}

probsupervivencia(Datos,20)

## [1] 0.13

5
Problema 2.

Explique si la función

1−u 0≤u≤1
S(u) =
0 1<u

satisface las propiedades de una función de supervivencia. Si las satisface, encuentre la dis-
tribución de U , h(u) y E[U − u|U > u]
u<-seq(0,1,by=0.1)
su<-1-u
plot(u,su,type = "s")
1.0
0.8
0.6
su

0.4
0.2
0.0

0.0 0.2 0.4 0.6 0.8 1.0

Podemos observar que la función S(u) es una recta con pendiente negativa, osea que es decreciente, además
cuando u > 1 se tiene que la función es 0. Por lo tanto se cumple la propiedad de que S(u) es una función no
creciente.
Entonces para S(u = 0) = 1 y para S(u = ∞) = 0 con los que podemos concluir que S(u) cumple con las
propiedades requeridas para ser una función de supervivencia.
Como S(t) 6= 0 parael intervalo 0 ≤ u ≤ 1, entonces la funcion de riezgo h(u) y la función densidad f (u)
tambien estarán definidas para 0 ≤ u ≤ 1.
Por propiedades de las funciones de supervivencia tenemos:

d
h(u) = − log(S(u)) y f (u) = h(u)S(u)
du

6
d
h(u) = − log(S(u))
du

d
h(u) = − log(1 − u)
du

1 1
h(u) = − (−1) =
1−u 1−u
Entonces,utilizando las propiedades dadas:

1
f (u) = h(u)S(u) = (1 − u) = 1
1−u
Z u
F (u) = 1dx = x|u0 = u
o

Ahora:
Z ∞
1
E[U − u|U > u] = S(t)dt
S(u) u

Z 1
1
E[U − u|U > u] = (1 − t)dt
1−u u

1 t2
E[U − u|U > u] = (t − )|1u
1−u 2

1 1 u2
E[U − u|U > u] = ( −u+ )
1−u 2 2

1 u2 + 1
E[U − u|U > u] = (−u + )
1−u 2

7
Problema 3.

Muestre que si T es una variable aleatoria que representa el tiempo de vida y t > 0 es una
constante, la vida media residual E[T − t|T > t] puede calcularse como:
Z ∞
1
E[T − t|T > t] = S(t)dt
S(t) t

Tenemos que:
Z ∞
E[T ] = S(t)dt
0

Problema 4.

Muestre que si la variable aleatoria T > 0 representa el tiempo de vida y tiene función de
−t
supervivencia S(t) = e β , t,β > 0 , entonces S satisface S(t + y) = S(t)S(y) donde y, t > 0
Tenemos:

−t
S(t) = e β

entonces S(t + y) es:

−(t+y)
S(t + y) = e β

−t−y
S(t + y) = e β

−t −y
S(t + y) = e β e β

−t −y
∴ S(t + y) = e β e β = S(t)S(h)

Problema 5.

Ejercicio 2.1
Considere los datos de supervivencia dados en la tabla de ejercicios 2.1. Calcule y grafique la función de
supervivencia estimada, la función de densidad de probabilidad y la función de peligro.
Tabla de ejercicios 2.1

Año Vivos al iniciar Muertes en intervalo


0-1 1100 240
1-2 860 180
2-3 680 184
3-4 496 138
4-5 358 118
5-6 240 60
6-7 180 52
7-8 128 44
8-9 84 32
9+ 52 28
8
t<-c(0,1,2,3,4,5,6,7,8,9,10)
vt<-c(1100,1100,860,680,496,358,240,180,128,84,52)
Mt<-c(0,240,180,184,138,118,60,52,44,2,28)
Sest<-round((vt-Mt)/vt[1],5)
fest<-round(Mt/vt[1],5)
hest<-round(Mt/(vt[1]-Mt/2),5)

matriz<-(cbind(t,vt,Mt,Sest,fest,hest))
matriz

## t vt Mt Sest fest hest


## [1,] 0 1100 0 1.00000 0.00000 0.00000
## [2,] 1 1100 240 0.78182 0.21818 0.24490
## [3,] 2 860 180 0.61818 0.16364 0.17822
## [4,] 3 680 184 0.45091 0.16727 0.18254
## [5,] 4 496 138 0.32545 0.12545 0.13385
## [6,] 5 358 118 0.21818 0.10727 0.11335
## [7,] 6 240 60 0.16364 0.05455 0.05607
## [8,] 7 180 52 0.11636 0.04727 0.04842
## [9,] 8 128 44 0.07636 0.04000 0.04082
## [10,] 9 84 2 0.07455 0.00182 0.00182
## [11,] 10 52 28 0.02182 0.02545 0.02578
plot(t,Sest,type="s")
1.0
0.8
0.6
Sest

0.4
0.2
0.0

0 2 4 6 8 10

plot(t,fest,type="o")

9
0.20
0.15
fest

0.10
0.05
0.00

0 2 4 6 8 10

plot(t,hest,type="o")

10
0.25
0.20
0.15
hest

0.10
0.05
0.00

0 2 4 6 8 10

Ejercicio 2.4
Dada la función de riesgo: h(t) = c, obtenga la función de supervivencia y la función de densidad.
Rt
− h(x)dx
S(t) = e 0

Rt
− cdx
S(t) = e 0

t
S(t) = e−cx|0
S(t) = e−ct

y con lo anterior tenemos que:

f (t) = h(t)S(t)
f (t) = ce−ct

Ejercicio 2.5
y
Dada la función de supervivencia S(t) = e−t encuentre la función de densidad y la función de riesgo.

d
h(t) = − log(S(t))
dt
d y
h(t) = − log(e−t )
dt

11
d y
h(t) = − −t
dt
d
h(t) = ty
dt
h(t) = yty−1
f (t) = h(t)S(t)
y
f (t) = yty−1 e−t

Problema 6.

Código para calcular y graficar Sn (t) con datos completos.


spv1<-function(datos){
sup<-max(datos)
total<-length(datos)
sups<-c(1)
tiempo<-0:sup+1
for (t in 0:round(sup)+1){
c<-0
s<-0
for (p in 1:total){
if(datos[p]>t ) {
c<-c+1
}
s<-c/total
}
sups<-c(sups,s)
}
print(sups)
plot(sups)
}

sprvivint<-function(datos){
Datos<-sort(datos)
sup<-max(datos)
total<-length(datos)
muertos<-c(0)
tmps<-c(0)
ss<-c()
s<-1
fv<-c()
tiempo<-0:sup+1
reps<-c(0)
for ( i in 1:length(Datos)) {
rep<-0
v<-Datos[i]
for (j in 1:length(Datos))
{
if (v == Datos[j]){
rep<-rep+1

12
}
}
muertos<-rep
vivos<-total-muertos
reps<-c(reps,rep)
tmps<-c(tmps,v)
}
matriz<-cbind(tmps,reps)
unique(matriz)
matriz<-matriz[!duplicated(matriz), ]
tmps<-as.numeric(matriz[,1])
mrt<-as.numeric(matriz[,2])
for (i in 1:length(tmps)){
f<-mrt[i]/length(datos)
fv<-c(fv,f)
s<-round(s-f,5)
ss<-c(ss,s)
}
matriz<-cbind(tmps,mrt,ss)
print(matriz)
plot(tmps,ss)
}

13

También podría gustarte