0

Data consists of 4 variable, id, x1 and x2, continuous variables which are correlated with y, a binary variable. 0 and 1 in the binary variable represent different states. Is it possible to use Markov chain models to calculate and plot state transition probability along the gradient of covariate values for each id and subsequently for the pooled data?

set.seed(1)
id =rep(1, 100)
x1 = rnorm(100)           
x2 = rnorm(100)
z = 1 + 2*x1 + 3*x2      
pr = 1/(1+exp(-z))        
y = rbinom(100,1,pr)
a<-data.frame(id,x1,x2, y)


set.seed(2)
id =rep(2, 100)
x1 = rnorm(100)           
x2 = rnorm(100)
z = 1 + 2*x1 + 3*x2      
pr = 1/(1+exp(-z))        
y = rbinom(100,1,pr)
b<-data.frame(id,x1,x2, y)


set.seed(3)
id =rep(3, 100)
x1 = rnorm(100)           
x2 = rnorm(100)
z = 1 + 2*x1 + 3*x2      
pr = 1/(1+exp(-z))        
y = rbinom(100,1,pr)
c<-data.frame(id,x1,x2, y)


d<-rbind(a,b,c)
VFreguglia
  • 2,129
  • 4
  • 14
  • 35
procerus
  • 194
  • 8
  • 1
    What do you mean by along the gradient of covariate values? Can you add an example of expected output? – VFreguglia Aug 04 '20 at 16:26
  • @Freguglia, To see how probability of state switching changes at different covariate values. I can put link here to [some pictures](https://www.google.com/search?q=state+transition+probability+covariate&tbm=isch&ved=2ahUKEwiwzPvN_IHrAhVBM-wKHat0AtYQ2-cCegQIABAA&oq=state+transition+probability+covariate&gs_lcp=CgNpbWcQA1DBRViJXGC0XmgAcAB4AIABSIgB2AWSAQIxMZgBAKABAaoBC2d3cy13aXotaW1nwAEB&sclient=img&ei=ZI0pX7CKL8HmsAer6YmwDQ&bih=625&biw=1366&rlz=1C1CHBF_enCZ907CZ907#imgrc=AjiBtiQdm2s9-M) I have found? – procerus Aug 04 '20 at 16:32
  • Yes! That would help! – VFreguglia Aug 04 '20 at 16:33
  • You seem to be asking about modeling advice rather than a specific programming question. You should instead ask at [stast.se] where statistical questions are on topic. If you know what method/technique you should use but can't figure out how to do it in R, then you might consider asking here. – MrFlick Aug 04 '20 at 16:52
  • @MrFlick, thank you, will try, just to ask you, what is [stast.se]? Googling it doesn't do much. – procerus Aug 04 '20 at 16:56
  • Oops. Sorry. Typo. That was supposed to be stats.se which in brackets expands to Cross Validated’s url: [stats.se] When posting there I might leave out lengthy code chucks and describe the data and type of estimates you want to be able to make. – MrFlick Aug 04 '20 at 16:57

0 Answers0