Untitled

library(markovchain)
Cargando paquete requerido: Matrix
Package:  markovchain
Version:  0.10.0
Date:     2024-11-14 00:00:02 UTC
BugReport: https://github.com/spedygiorgio/markovchain/issues
# Definimos los estados
estados <- c("Feliz", "Neutral", "Insatisfecho")

# Creamos la matriz de transición
matriz <- matrix(c(
  0.7, 0.2, 0.1,  # De Feliz
  0.3, 0.4, 0.3,  # De Neutral
  0.2, 0.3, 0.5   # De Insatisfecho
), 
nrow = 3, byrow = TRUE,
dimnames = list(estados, estados))
cadena_cliente <- new("markovchain", states = estados,
                      transitionMatrix = matriz,
                      name = "Comportamiento del Cliente")
print(cadena_cliente)
             Feliz Neutral Insatisfecho
Feliz          0.7     0.2          0.1
Neutral        0.3     0.4          0.3
Insatisfecho   0.2     0.3          0.5
plot(cadena_cliente)

distribucion_estacionaria <- steadyStates(cadena_cliente)
print(distribucion_estacionaria)
         Feliz   Neutral Insatisfecho
[1,] 0.4565217 0.2826087    0.2608696