Comments (11)
Strange, are you sure you're using the current version? This works fine for me using either the current CRAN version or the current github version:
Q <- rbind(c(0, 0, 0.25, 0, 0.25), c(0, 0, 0.25, 0, 0.25), c(0.125, 0.125, 0, 0.125, 0.125), c(0, 0, 0.25, 0, 0.25), c(0, 0, 0, 0, 0))
data_test <- read.csv("data_test.txt")
library(msm)
model1 <- msm(state ~ time, subject = id, data = data_test, qmatrix = Q, gen.inits = T)
set.seed(1)
pmatrix.msm(model1, ci="boot", B=3)
Are you using more bootstrap iterations? If it still breaks, can you set the seed and post a reproducible example?
I notice in your fitted model, the 1-5 transition rate has an implausibly wide confidence interval - there's essentially no information about this parameter - so I'd expect problems working with this model.
from msm.
Thank you for your prompt reply.
I have now discovered that the function will work on some types of data frames and not others. I saved my original data frame 'data' using write.csv and re-read into R as new data frame 'data_test'. Both are of class data.frame. Bootstrapping was possible for the model built from data_test, but not data
The original data frame has POSIXct and Date variables, which seems to affect whether the blue filter arrow is present in the environment pane and perhaps is also affecting something else behind the scenes.
I also appreciate you noting the implausible CIs for some transition rates. Now the code is working fine I will add more data and hopefully resolve this issue too. Thanks again!
from msm.
Hello,
I am having the same problem with the current version of msm: I am trying to run a model with one covariate.
The model works fine (fine-ish: there is one CI that goes from 0 to Inf that I have to look into), but when I ask for:
pmatrix.msm(msm.mod.cov, t=1200, covariates=list(cluster.grouped="2"), ci="boot", B=100)
I get the same error:
Error in msm.check.times(time, subject, state) :
Observations within subjects 1324, 1452, 1576 and others are not ordered by time
with numers changing at each bootstrap iteration.
The dataframe does not contain any Date or POSIXct objects, only numeric (from 1 to 6, the code for the state), integer (time), character (subject id) and factor (covariate), and it's ordered by subject and time.
What this could come from? Could this be due to the (0,Inf) CI?
Let me know if you need the dataframe to reproduce the error (it's a pretty big one, ~270k lines).
Thank you!
from msm.
Hi Stefano - any data and code (with seed set) that reproduces the error (with the seed set) would be good if possible. Perhaps a subset of the data would be sufficient?
from msm.
Hello, and thanks for your quick answer.
I tried to make both dataset and script as agile as possible: you'll find them both in a zip file at the end.
The data are a series of trials on animal behaviour (6 possible behaviours: 1 is the starting state - in the cage at the beginning of the trial, while 6 is the absorbing state: whenever it was observed, the trial was immediately concluded).
Each test lasted ~20 minutes (or less, if the target behaviour was spotted earlier), and the behaviour of the subject was recorded every second, for a total of ~1200 entries per trial.
The 4 variables are behaviorN (numeric; code of the observed behaviour at that time), second (numeric), id_trial (character, unique for each trial) and cluster.grouped (factor with 3 levels; the origin site of each individual, that I want to use as covariate in the analysis).
Attached you find the dataset and a script, including my sessionInfo for reference; the model converges after 58 iterations, there are two CIs that go (0-Inf) which I have to look into, and lastly you have the pmatrix() call that produces the error.
Thank you for your help!
from msm.
That looks like the wrong data, it is called "df.leptidea.RDS" in the zip file, while the code refers to "df.run.rds" and the variable names are different.
from msm.
Apologies. Now it should be correct
from msm.
OK I think this was already fixed in the development version (b5681a3). To install this, see the instructions at https://github.com/chjackson/msm , for the moment, but I'll also put a CRAN release together shortly because it has been a while.
from msm.
By using the development version it seems to work.
Thank you a lot for your help!
from msm.
I had this problem too, but it dissappeared after I sorted the data on subject and time.
(MSM version 1.7)
from msm.
Bugfix now included in CRAN version 1.7.
from msm.
Related Issues (20)
- HMM censoring and obstrue HOT 7
- HMM censoring, initprobs, and viterbi.msm pstates HOT 3
- MSM with covariates : HOT 3
- For HMM, viterbi pstate probabilities ignore obstrue HOT 3
- simmulti.msm fails with hmmMV in hmodel HOT 1
- Issue with bootstrap: "state variable is character"? HOT 2
- Using inverse probability weight in MSM models HOT 5
- Markov property HOT 1
- Comparing a multivariate HMM and univariate HMM for binary classification HOT 4
- R msm package does not generate estimates HOT 6
- log(hazard ratios) and standard errors? HOT 2
- Interpretation of transition intensity HOT 2
- Error in Pmat[x[1], x[2]] : out of bounds HOT 3
- continuous-time vs. discrete-time models HOT 4
- Add electronic health records to panel data? HOT 6
- Estimating a physical exercise model HOT 2
- Dear Dr. Jackson , I have a problem I need your help with HOT 14
- Model assessment in the case of censored states and different observation times HOT 6
- I need help with msm model HOT 2
- Questions about using weights in msm package HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from msm.