This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.
###Parcial practico 2 estadistica. ##Univerisdad externado de colombia - Economía. #Paula Guzmán - Carlos Galvis. #21/04/2022.
##Introducción. # Un fondo de inversión (mutual fund) es un producto financiero compuesto por el dinero de varios inversionistas, #recaudado con el fin de invertir en valores como acciones, bonos, instrumentos del mercado monetario y otros #activos. Los fondos de inversión son operados por administradores de fondos profesionales, quienes invierten #los activos del fondo para producir ganancias de capital e ingresos para los inversionistas. Así, cada accionista #participa proporcionalmente en las ganancias o pérdidas del fondo. Por lo general, los fondos invierten en una #gran cantidad de valores, y el rendimiento se suele rastrear como el cambio en la capitalización de mercado #total del fondo, derivado del rendimiento agregado de las inversiones subyacentes. El objetivo de este caso es #estudiar descriptiva y probabilísticamene la estructura de los fondos, primordialmente en términos de riesgo.
library(readr)
Bond_Funds <- read_delim("Bond Funds.txt",
delim = "\t", escape_double = FALSE,
trim_ws = TRUE)
## Rows: 184 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr (4): Fund Number, Type, Fees, Risk
## dbl (5): Assets, Expense Ratio, Return 2009, 3-Year Return, 5-Year Return
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
colnames(Bond_Funds) <- c("id","tipo","activos","cargos","relacion",
"retorno09","retorno3", "retorno5","riesgo")
attach(Bond_Funds)
##Analisis exploratorio
##1.Clasificar las variables según su naturaleza (cualitativa/cuantitativa discreta/cuantitativa continua) y escala de medición (nomina/ordinal/intervalo/razón).
| Variable. | Tipo de variable. | Escala de medición. |
|---|---|---|
| Número de fondo. | Cualitativa ordinal. | Ordinal. |
| Tipo. | Cualitativa nominal. | Nominal. |
| Activos. | Cuantitativa continua. | Razon. |
| Cargos. | Cualitativa nominal. | Nominal. |
| Relación de gastos. | Cuantitativa continua. | Razon. |
| Retorno en 2009. | Cuantitativa continua. | Razon. |
| Retorno a tres años. | Cuantitativa continua. | Razon. |
| Retorno a cinco años. | Cuantitativa continua. | Razon. |
| Riesgo. | Cualitativa ordinal. | Ordinal. |
#2.Construir tablas cruzadas junto con los gráficos de barras correspondientes para: a. tipo (columnas) frente a cargos (filas), b. tipo (columnas) frente riesgo (filas), y c. cargos (columnas) frente a riesgo (filas). Teniendo en cuenta estas tablas de contingencia y los gráficos, ¿qué puede decir acerca de las relaciones entre estas variables? Nota: usar frecuencias relativas e incluir los totales marginalmente.
ta = table(cargos, tipo)
ta1 = round(prop.table(ta), 4)
ta1*100
## tipo
## cargos Intermediate Government Short Term Corporate
## No 28.80 41.85
## Yes 18.48 10.87
| Intermediado por el gob. | Corporativo a corto plazo. | Total. | |
|---|---|---|---|
| No. | 28,80 | 41,85 | 70,65 |
| Si. | 18,48 | 10,87 | 29,35 |
| Total. | 47,28 | 52,72 | 100 |
taf = barplot(height = (ta1*100), beside = TRUE,
names.arg = c("Intermediado por el gobierno","Corporativo a corto plazo"), legend.text = c("No","Si"),
xlab = "Tipo", ylab = "Porcentaje",
main = "Cargo de venta, según el tipo de fondo", ylim = c(0,60),
args.legend = list(x = "topright"),
col=c("purple","green"))
text(taf,0,round(ta1*100, 2), cex = 1, pos = 3, col = "black", font = 3)
#Las intervenciones intermendiadas por el gobierno en total tienen un
47.8% y los corporativos a corto plazo 5.44 puntos porcentales por
encima con un total de 52.72. Podemos ver que su mayoria los coporativos
no tienen cargos por impuestos, y asi mismo hay un menor porcentaje de
corporativos que tienen cargos por impuestos.
#B. tipo (columnas) frente riesgo (filas).
tb = table(riesgo, tipo)
tb1 = round(prop.table(tb), 4)
tb1*100
## tipo
## riesgo Intermediate Government Short Term Corporate
## Above average 15.76 16.30
## Average 17.39 20.11
## Below average 14.13 16.30
| Intermediado por el gob. | Corporativo corto plazo. | Total. | |
|---|---|---|---|
| Encima del prom. | 15,76 | 16,30 | 32,07 |
| Promedio. | 17,39 | 20,11 | 37,50 |
| Debajo del prom. | 14,13 | 16,30 | 30,43 |
| Total. | 47,28 | 52,72 | 100 |
tbf = barplot(height = (tb1*100), beside = TRUE,
names.arg = c("Intermediado por el gobierno","Corporativo a corto plazo"), legend.text = c("Por encima del promedio","Promedio", "Por debajo del promedio"),
xlab = "Tipo", ylab = "Porcentaje",
main = "Riesgo de perdida, segun el tipo de fondo", ylim = c(0,60),
args.legend = list(x = "topright"),
col=c("lightblue","lightgreen", "lightpink"))
text(tbf,0,round(tb1*100, 2), cex = 1, pos = 3, col = "black", font = 3)
#De la Tabla del punto b se puede observar el 32.07 por ciento de los
F.I presentan riesgo de pérdida por encima del estandar promedio, un
37.50 por ciento muestra un riesgo teniendo en cuenta el rpoemdio y por
ultimo el 30.43 por ciento de los F.I por abajo del promedio sus
riesgos.
#C. cargos (columnas) frente a riesgo (filas).
tc = table(riesgo, cargos)
tc1 = round(prop.table(tc), 4)
tc1*100
## cargos
## riesgo No Yes
## Above average 20.11 11.96
## Average 26.63 10.87
## Below average 23.91 6.52
| No. | Si. | Total. | |
|---|---|---|---|
| Por encima del promedio. | 20,11 | 11,96 | 32,07 |
| Promedio. | 26,63 | 10,87 | 37,5 |
| Por debajo del promedio. | 23,91 | 6,52 | 30,43 |
| Total. | 70,65 | 29,35 | 100 |
tcf = barplot(height = (tc1*100), beside = TRUE,
names.arg = c("No","Si"), legend.text = c("Por encima del promedio","Promedio", "Por debajo del promedio"),
xlab = "Tipo", ylab = "Porcentaje",
main = "Riesgo de perdida, según los cargos", ylim = c(0,60),
args.legend = list(x = "topright"),
col=c("lightblue","lightpink","lightyellow"))
text(tcf,0,round(tc1*100, 2), cex = 1, pos = 3, col = "black", font = 3)
#Podemos encontrar que los que presentan menos riesgo por debajo del promedio son los que si presentan cargos por impuestos, pues su riesgo es el 6,52%, comparándolo con los que no presentan cargos, su porcentaje es del 23,91. Esto sucede también con los que si presentan cargos por encima del promedio, los que si presentan cargos tienen un 11,96% de riesgo por encima del promedio y los que no un 20,11%.
#3. Calcular la matriz de correlación y graficar los dispersogramas (en un sólo gráfico) para describir las relaciones entre: activos, relación de gastos, retorno en 2009, retorno anualizado a tres años, y el retorno anualizado a cinco años. Teniendo en cuenta las correlaciones y los dispersogramas, ¿qué puede decir acerca de las relaciones entre estas variables?
Bond_Funds = data.frame(activos,relacion,retorno09,retorno3,retorno5 )
head(Bond_Funds)
## activos relacion retorno09 retorno3 retorno5
## 1 7268.1 0.45 6.9 6.9 5.5
## 2 475.1 0.50 9.8 7.5 6.1
## 3 193.0 0.71 6.3 7.0 5.6
## 4 18603.5 0.13 5.4 6.6 5.5
## 5 142.6 0.60 5.9 6.7 5.4
## 6 1401.6 0.54 5.7 6.4 6.2
Bond_Funds.cor = cor(Bond_Funds, method = "pearson")
round(Bond_Funds.cor, 2)
## activos relacion retorno09 retorno3 retorno5
## activos 1.00 -0.32 0.05 0.12 0.15
## relacion -0.32 1.00 0.07 0.05 0.00
## retorno09 0.05 0.07 1.00 0.06 0.09
## retorno3 0.12 0.05 0.06 1.00 0.99
## retorno5 0.15 0.00 0.09 0.99 1.00
| Activos | Relación | Retorno09 | Retorno3 | Retorno5 | |
|---|---|---|---|---|---|
| Activos | 1.00 | -0.32 | 0.05 | 0.12 | 0.15 |
| Relación | -0.32 | 1.00 | 0.07 | 0.5 | 0.00 |
| Retorno09 | 0.05 | 0.07 | 1.00 | 0.06 | 0.09 |
| Retorno3 | 0.12 | 0.05 | 0.06 | 1.00 | 0.99 |
| Retorno5 | 0.15 | 0.00 | 0.09 | 0.99 | 1.00 |
pairs(Bond_Funds,
labels = colnames(Bond_Funds),
pch = 21,
bg = rainbow(3),
col = rainbow(3),
main = "Matriz de correlación",
rowlattop = TRUE,
gap = 0)
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "rowlattop" is not
## a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "rowlattop" is not
## a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "rowlattop" is not
## a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "rowlattop" is not
## a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "rowlattop" is not
## a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "rowlattop" is not
## a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "rowlattop" is not
## a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "rowlattop" is not
## a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "rowlattop" is not a
## graphical parameter
## Warning in plot.window(...): "rowlattop" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "rowlattop" is not a graphical parameter
## Warning in title(...): "rowlattop" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "rowlattop" is not
## a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "rowlattop" is not
## a graphical parameter
Respecto al análisis de datos, las variables activos y los gasto tienen un coeficiente de correlación negativo de -32.5 % , lo que significa que los fondos de inversiones con mayores activos y menores activos presentan una relacion inversamente proporcional de gastos y activos netos. Ademas, las variables retorno a tres años y retorno a cinco años tienen un coeficiente de correlación del 98.62%, esto quiere decir una simimitud en los datos evidente como lo muestra el dispersograma.Respecto a las demas variables el coeficiente de correlación de pearson esta muy cerca del cero.
boxplot(formula = retorno09 ~ riesgo, horizontal = TRUE, boxwex = 0.9, cex = 0.9, border = "red", col = "orange",
main = "Comparación retorno en 2009 y el riesgo", xlab = "Relación", ylab = "Nivel del riesgo",
names = c("Encima del promedio", "Promedio", "Debajo del promedio"))
tabla1 = data.frame(riesgo, retorno09)
Filtro.a = filter(tabla1, riesgo == "Above average",)
summary(Filtro.a)
## V1 V2
## Min. :131 Min. :460.3
## 1st Qu.:131 1st Qu.:460.3
## Median :131 Median :460.3
## Mean :131 Mean :460.3
## 3rd Qu.:131 3rd Qu.:460.3
## Max. :131 Max. :460.3
## NA's :183 NA's :183
Filtro.b = filter(tabla1, riesgo == "Average",)
summary(Filtro.b)
## V1 V2
## Min. :129 Min. :411.1
## 1st Qu.:129 1st Qu.:411.1
## Median :129 Median :411.1
## Mean :129 Mean :411.1
## 3rd Qu.:129 3rd Qu.:411.1
## Max. :129 Max. :411.1
## NA's :183 NA's :183
Filtro.c = filter(tabla1, riesgo == "Below average",)
summary(Filtro.c)
## V1 V2
## Min. :105 Min. :446.8
## 1st Qu.:105 1st Qu.:446.8
## Median :105 Median :446.8
## Mean :105 Mean :446.8
## 3rd Qu.:105 3rd Qu.:446.8
## Max. :105 Max. :446.8
## NA's :183 NA's :183
| Min. | Max. | Media. | Mediana. | |
|---|---|---|---|---|
| Por encima del promedio. | -8,8 | 32 | 8,31 | 7,9 |
| Promedio. | -1,1 | 16,4 | 6,87 | 6,0 |
| Por debajo del promedio. | 0,2 | 13,0 | 6,31 | 6,1 |
## Calculo de probabilidades.
#1. Calcular todas las probabilidades condicionales para comparar los niveles de riesgo en función de:
#A.El tipo de fondo de inversión.
t4a = table(riesgo, tipo)
cond4 = prop.table(t4a, margin = 2)
cond4*100
## tipo
## riesgo Intermediate Government Short Term Corporate
## Above average 33.33333 30.92784
## Average 36.78161 38.14433
## Below average 29.88506 30.92784
| Intermediado por el gob. | Corporativo a corto plazo. | |
|---|---|---|
| Encima del promedio. | 33,33 | 30,92 |
| Promedio. | 36,78 | 38,14 |
| Debajo del promedio. | 29,88 | 30,92 |
| Total. | 100 | 100 |
t1 = barplot(height = (cond4*100), beside = TRUE,
names.arg = c("Intermediado por el gobierno","Corporativo a corto plazo"), legend.text = c("Por encima del promedio","Promedio", "Por debajo del promedio"),
xlab = "Tipo", ylab = "Porcentaje",
main = "Riesgo de perdida, según el tipo de fondo", ylim = c(0,130),
args.legend = list(x = "topright"),
col=c("lightblue","lightgreen", "lightyellow"))
text(t1,0,round(cond4*100, 2), cex = 1, pos = 3, col = "black", font = 3)
#B.los cargos de venta.
t4b = table(riesgo, cargos)
cond5= prop.table(t4b, margin = 2)
cond5*100
## cargos
## riesgo No Yes
## Above average 28.46154 40.74074
## Average 37.69231 37.03704
## Below average 33.84615 22.22222
| No. | Si. | |
|---|---|---|
| Por encima del promedio. | 28,46 | 40,74 |
| Promedio. | 37,69 | 37,03 |
| Por debajo del promedio. | 33,84 | 22,22 |
| Total. | 100 | 100 |
t2 = barplot(height = (cond5*100), beside = TRUE,
names.arg = c("No","Si"), legend.text = c("Por encima del promedio","Promedio", "Por debajo del promedio"),
xlab = "Tipo", ylab = "Porcentaje",
main = "Riesgo de perdida, según el tipo de fondo", ylim = c(0,130),
args.legend = list(x = "topright"),
col=c("lightblue","lightgreen", "lightyellow"))
text(t2,0,round(cond5*100, 2), cex = 1, pos = 3, col = "black", font = 3)
##SI existe una diferencia sustancial entre los diferentes niveles de riesgo divido en por encima del promedio, promedio y por debajo del promedio. Para mostrar un diferencia de lo tipo de inversión y cargos de venta fue necesario calcular la probabilidad de cada uno. Estas probabilidades condicionales mostraron que en el tipo de inversión las probabilidades fueron en su mayoria superiores en corporativo a corto plazo, Por otro lado en el cargo de venta, en la variable NO las probabilidades fueron superiores en mayoria en promedio y por encima del promedio. Comprando la informacion no hay un patron que muestra una relacion entre los datos de ambas tablas y no hay una relacion de datos relevante que muestra que en efecto no hay diferencia.
#2. Categorizar (construir intervalos) la variable retorno09 usando los siguientes intervalos: menos de 0, e 0 y 10, más de 10. Otorgar nombres significativos a las categorías resultantes. Calcular todas las probabilidades condicionales para comparar los niveles de riesgo en función de las categorías delrendimiento de los fondos en 2009. Presentar estas probabilidades tabular y gráficamente.
retorno09.cat = cut(retorno09, breaks = c(-Inf, 0, 10, 35))
ta2 = table(riesgo, retorno09.cat)
colnames(ta2) = c("rendimiento bajo(-Inf,0)","rendimiento promedio(0-10)","rendimiento alto(0-35)")
ta2 = round(prop.table(ta2, margin = 2),3)
ta2*100
## retorno09.cat
## riesgo rendimiento bajo(-Inf,0) rendimiento promedio(0-10)
## Above average 81.2 17.1
## Average 18.8 39.3
## Below average 0.0 43.6
## retorno09.cat
## riesgo rendimiento alto(0-35)
## Above average 51.0
## Average 39.2
## Below average 9.8
| -Inf - 0 | 0 - 10 | 10 - 35 | |
|---|---|---|---|
| Por encima del promedio. | 81,2 | 17,1 | 51,0 |
| Promedio. | 18,8 | 39,3 | 39,2 |
| Por debajo del promedio. | 0,0 | 43,6 | 9,8 |
t41 = barplot(height = (ta2*100), beside = TRUE,
names.arg = c("-Inf - o","0 - 10", "10 - 35"), legend.text = c("Por encima del promedio","Promedio", "Por debajo del promedio"),
xlab = "Tipo", ylab = "Porcentaje",
main = "Niveles de riesgo en función de rendimiento de fondos en 09", ylim = c(0,140),
args.legend = list(x = "topright"),
col=c("blue","green", "yellow"))
text(t41,0,round(ta2*100, 2), cex = 1, pos = 3, col = "black", font = 3)
### Teorema de bayes
H1<-quantile (activos, probs = 0.25)
H2<-quantile (activos, probs = 0.50)
H3<-quantile(activos, probs = 0.75)
H4<-quantile(activos, probs = 1)
PHn=H1<H2 & H2<H3 & H3<H4 & H2<H3
TB1= round (100* quantile(activos)/184)
p = round ( 100* table (riesgo) / 184, 1)
#1. Sea E el evento “el riesgo de la inversión del fondo está por encima del promedio”. Usando la base de datos, calcular e interpretar las siguientes probabilidades: Pr(E | H1), Pr(E | H2), Pr(E | H3) y Pr(E | H4). ¿Estas probabilidades deben sumar 1? ¿Por qué?
Pr1=(((0.25)*(0.321))/(0.25))
Pr2=(((0.25)*(0.321))/(0.25))
Pr3=(((0.25)*(0.321))/(0.25))
Pr4=(((0.25)*(0.321))/(0.25))
Pr=sum(Pr1,Pr2,Pr3,Pr4)
#La suma no da 1, ya que son eventos independientes.
#2.
Prh1=(((0.321)*(0.25))/(0.321))
Prh2=(((0.321)*(0.25))/(0.321))
Prh3=(((0.321)*(0.25))/(0.321))
Prh4=(((0.321)*(0.25))/(0.321))
Prh=sum(Prh1,Prh2,Prh3,Prh4)
#La suma de este si da 1, pues al sumar se calcula la probabilidad total, la cual debe dar 1 en este caso.
##Conclusiones
#Con base en los resultados de las secciones anteriores proporcione algunas conclusiones de forma puntual y concisa, teniendo en cuenta las siguientes preguntas: # ¿Los fondos intermediados por el gobierno tienden a ser inversiones menos riesgosas que los fondos corporativos a corto plazo? #No, de hecho, como lo podemos ver en el punto b de la sección de probabilidad condicional, los que tienen más alto riesgo son los intermediados por el gobierno. #¿Los fondos con menores rendimientos tienden a ser inversiones menos riesgosas que los fondos con mayores rendimientos? # Si, en el punto 4 de la sección 1 podemos ver que los fondos que están por debajo del promedio no presentan perdidas, más los que están por encima del promedio, sí. #¿Existe una relación entre los activos, la relación de gastos y los rendimientos de los fondos? # Si, lo podemos ver en el dispersograma, donde vemos que tan relacionadas están estas variables. #¿Hay una diferencia en los rendimientos de los fondos intermediados por el gobierno y los fondos corporativos a corto plazo?