The data used is available here (the file is called "figshare.txt").
I estimated the transition probabilities for a Markov model where the observations were grouped by location (group_by(km)
).
data <- data %>% group_by(km) %>% summarize(pp_chain=list(pp)) %>% as.data.frame
pp_chains <- data$pp_chain; names(pp_chains) <- data$km
fit <- markovchainFit(pp_chains)
The output (summarized here) shows the probability estimates for the model overall:
print(fit$estimate)
0 1
0 0.9116832 0.08831677
1 0.5250852 0.47491476
Hypothetically, the output I am after would be more specific and would provide me with probabilities for each location (km
).
It would look something like this:
km = 80
0 1
0 0.7116832 0.28831677
1 0.1250852 0.17491476
km = 81
0 1
0 0.8116832 0.18831677
1 0.4250852 0.37491476
km = 83
0 1
0 0.6116832 0.38831677
1 0.3250852 0.27491476
Does anyone know how to extract the Markov model estimates for each location (
km
) individually after the model is run?