As in the title of topic I'd like to check this assumption. I have already read the topic:
How to test if "previous state" has influence on "subsequent state" in R
but it regards to categorical variable.
So let's say I have record of time spent in state 1 and its consecutive state 2. Moreover the the subject will not always move to state 2, hence I have more records for state 1.
Should I go for testing correlation significance? What if the data would perform nonlinearity, GAMs would be useful? But as in my proposition below I think it will only regard to magnitude of the effect while moving between states.
Data example:
ID State Time
1 S_1 10
1 S_2 30
2 S_1 15
3 S_1 59
3 S_2 65
4 S_1 20
model <- mgcv::gam(time ~ as.factor(state), data=data)
My best idea is to subset the data that has only those two states and test it so I can use subsequent state as the dependet variable.
Data example:
ID State Time
1 S_1 10
1 S_2 30
3 S_1 59
3 S_2 65
model <- mgcv::gam(S_1_time ~ s(S_2_time), data=data)
Is that a valid approach? How should I tackle the diagnostic of the model then?