[R] Semi Markov warnings ( for dummies)

Rolf Turner r.turner at auckland.ac.nz
Mon Jul 21 23:51:54 CEST 2014


If you are going to drive a car you should learn to drive.  Read the 
basic intro material for R.

Where does the function "readdata" come from?  The syntax you use 
(having an assignment inside the function call) is let us say unorthodox 
and highly inadvisable.

Since you got an error reading in your data, where did the data that you 
are trying to analyse come from?

Don't call your data "data".  See fortune(77).

You don't say where the function semiMarkov() comes from; presumably 
from the package "semiMarkov".  Say so.  Do not expect your readers to 
be telepathic.

Don't use Excel to do *anything* (except store data, if you *must*).

I certainly can't help you to debug your errors/warnings without seeing 
your data.  I doubt that anyone else can either.  (I *could* be wrong 
about that; there are some *very* clever and intuitive people on this list.)

cheers,

Rolf Turner

On 22/07/14 02:04, M.A. Pet wrote:
> *Hello,*
>
> I never worked with R before my supervisor asks me to run a semiMarkov
> analysis a month ago. After a long struggle, to date, the code works, but I
> still get some warnings. However, because of my lack of knowledge in R I am
> not possible to figure out the problems or say anything about the influence
> of these warnings on my outcome. Hopefully, someone would help me with
> these ( I think basic) questions.
>
>
> What is the case? I want to do a semiMarkov analysis with 3 states (state
> n, state s and state e). Wherefore I want to run the analysis to see
> whether there is a difference in Hazard Ratio between transitions nà e and sà e.
> Therefore, I’ve got data of nearly 60 persons. In excel, every worksheet
> reflects a person.  To answer my research question I tried to run the
> script for one person.
>
> Unfortunately, I get the following error:
>
>> # read data and convert to correct format (and print tail).
>
>> data <- readdata( input <- 'E1_tijd_stress.csv' )
>
> Error in `$<-.data.frame`(`*tmp*`, "state", value = "s") :
>
>    replacement has 1 row, data has 0
>
> Called from: `$<-`(`*tmp*`, "state", value = "s")
>
>
>
> Furthermore, I used a macro in excel to merge these worksheets into one
> worksheet ( all persons in one file) . However, after running the script I
> saw the following warnings:
>
>> # semi-Markov model without covariates.
>
>> fit.semi.markov <- semiMarkov( data = data, states = states.semi.markov, mtrans = mtrans.semi.markov )
>
>
>
> Iter: 1 fn: 11224.5658  Pars:  1000.00000 412.24725 261.14293
> 66.30789   1.67507   5.59420   0.55746   1.37715   0.59734   0.48604
> 0.73281   0.74205
>
> Iter: 2 fn: 11224.5658  Pars:  1000.00000 412.24425 261.14508
> 66.30635   1.67506   5.59420   0.55746   1.37716   0.59734   0.48604
> 0.73281   0.74206
>
> solnp--> Completed in 2 iterations
>
> Warning messages:
>
> 1: In .safefunx(tmpv, .solnp_fun, .env, ...) :
>
> solnp-->warning: Inf detected in function call...check your function
>
>
> These repeated for 7 times. Or the following warning:
>
>> fit.semi.markov <- semiMarkov( data = data, states = states.semi.markov, mtrans = mtrans.semi.markov )
>
> Iter: 1 fn: 444562.8860         Pars:  1.00000 1.00000 1.00000 1.00000
> 1.00000 1.00000 1.00000 1.00000 1.00000 0.47882 0.72691 0.74627
>
> solnp--> Completed in 1 iterations
>
> Error in svd(X) : infinite or missing values in 'x'
>
> In addition: There were 29 warnings (use warnings() to see them)
>
> 29: In .safefunx(tmpv, .solnp_fun, .env, ...) :
>
> solnp-->warning: NaN detected in function call...check your function
>
>
> Furthermore, I want to control the analysis for some covariates.
>
>> # semi-Markov model with covariates
>
>> fit2 <- semiMarkov( data = data,cov= as.data.frame(data$stress.score), states = states, mtrans = mtrans )
>
> Error in mtrans[as.numeric(substring(trans.hh[i], first = 1, last = 1)),  :
>
>    subscript out of bounds
>
>
> Is someone able to tell me what these warnings exactly mean? Or someone I
> can contact to discuss about this? I understand inf and NaN for example but
> I am not able to figure out what to change in my data format of script (
> the problem is, some of my data run without problems, some does not).
> Hopefully I give enough information, otherwise let me know.
>
> Thank you!
>
> 	[[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


-- 
Rolf Turner
Technical Editor ANZJS



More information about the R-help mailing list