How to test if "previous state" has influence on "subsequent state" in R Imagine a situation:
We have historical records (20 years) of three mines. Does the presence of silver increases the probability of finding gold in next year? How to test such question?


Here is example data:
mine_A <- c("silver","rock","gold","gold","gold","gold","gold",
            "rock","rock","rock","rock","silver","rock","rock",
            "rock","rock","rock","silver","rock","rock")
mine_B <- c("rock","rock","rock","rock","silver","rock","rock",
            "silver","gold","gold","gold","gold","gold","rock",
            "silver","rock","rock","rock","rock","rock")
mine_C <- c("rock","rock","silver","rock","rock","rock","rock",
            "rock","silver","rock","rock","rock","rock","silver",
            "gold","gold","gold","gold","gold","gold")
time <- seq(from = 1, to = 20, by = 1)


 A: My best try:
...usage of transition matrices suggested by @AndyW is probably not the solution I am looking for (based on @Tim's comment). So I've tried a different approach.
I found this link which deals with how to do logistic regression where response variable y and a predictor variable x are both binary.
According to example I should create 2 × 2 table based on my data:
               gold (yes)  gold (no)
silver (yes)       2           7
silver (no)       14          34

How I extracted the values:

And construct a model:
response <- cbind(yes = c(2, 14), no = c(7, 34))

mine.logistic <- glm(response ~ as.factor(c(0,1)),
                      family = binomial(link=logit))

summary(mine.logistic)
# Coefficients:
#                     Estimate Std. Error z value Pr(>|z|)
# (Intercept)          -1.2528     0.8018  -1.562    0.118
# as.factor(c(0, 1))1   0.3655     0.8624   0.424    0.672

Is it a good solution? Does the p-value (0.673) mean that presence of silver no not increase the probability of finding gold?
