[R-sig-ME] singular convergence warning
romunov
romunov at gmail.com
Mon Oct 13 09:53:51 CEST 2014
This isn't exactly mixed-mo list material (try
http://stackoverflow.com/questions/tagged/r), but here goes.
R uses a mechanism to catch warnings and lets you print whatever you want
when this happens. For your convenience function `tryCatch` may be used.
With it, you evaluate an expression and should an error or a warning occur,
do something with it.
Here's an example of `tryCatch` in action. Notice the structure of `x` and
`y`, which you can use to extract the desired elements and handle the
situation further.
FWIW, you can have both, warning and error, in the same `tryCatch` call.
> x <- tryCatch(simpleError("this is a simple error"), error = function(e)
e)
> y <- tryCatch(simpleWarning("this is a simple warning"), warning =
function(w) w)
> x
<simpleError: this is a simple error>
> y
<simpleWarning: this is a simple warning>
> str(x)
List of 2
$ message: chr "this is a simple error"
$ call : NULL
- attr(*, "class")= chr [1:3] "simpleError" "error" "condition"
> str(y)
List of 2
$ message: chr "this is a simple warning"
$ call : NULL
- attr(*, "class")= chr [1:3] "simpleWarning" "warning" "condition"
HTH,
Roman
On Sun, Oct 12, 2014 at 10:08 PM, Price, Emily <ep311508 at ohio.edu> wrote:
> Dear R mixed models users,
>
> I'm running a Monte Carlo simulation with 16 cells using four loops to
> determine how sample size influences treatment effectiveness in single case
> design. I'm running 1,000 replications for each cell so I have a total of
> 16,000 simulated datasets. In 50 of the 16,000 datasets I'm getting the
> following warning message: In mer_finalize(ans) : singular convergence
> (7). I would like to determine where the errors are occurring (i.e., which
> cells) so that I can do some follow up analyses but I don't know how to
> program a statement to tell me. To let me know when each sample is
> finished within a cell I'm using the command:
> cat("Iteration",i1,i2,i3,i4,t,"successful","\n") where i1, i2, i3, and i4
> are the counters for each for loop and t is the value for the replication
> number within each cell. Therefore, does anyone know how to use command
> cat to print the values of the specific cell when the warning message
> occurs? Or alternatively if there is a different way I would welcom!
> e that as well. If you would like additional information about the code
> I can supply that as well.
>
> Thanks!
> Emily
>
> Emily A. Price, PhD
> Educational Research and Evaluation
> Patton College of Education
> Ohio University
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
--
In God we trust, all others bring data.
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list