Errors Returned by R

Posted on
Picture of user. pdeboeck Joined: 08/04/2009

Several testers here at KU found the errors produced in R rather uninformative. It is clear when something goes wrong, but it seems to be frequently unclear what can be done to correct the problem. The general suggestion was made that having very informative error information, more like the old Mx, would be preferable. I'll leave it open to discussion --- but that was the feedback from several testers in the middle of the country.

Replied on Sat, 08/29/2009 - 01:08
Picture of user. Steve Joined: Jul 30, 2009

Agreed.

However, there is only so much we can do. If the error is generated by R itself, we can only pass the buck to the R developers.

If the error is one where we have control (an SEM error of some kind) we are very open to suggestions from the community about what would be useful as an error message.

Replied on Mon, 08/31/2009 - 17:09
Picture of user. neale Joined: Jul 31, 2009

In reply to by mspiegel

I'd love to help with error message authoring, with a view to injecting more information and hopefully a little humor to salve users' frustration with the software.

I heartily agree that compiling a list of error messages and their usual causes would be extremely valuable in this regard. This might go some way towards being able to output:

"Oh, bad luck you got a vanilla R error!" Even if this is your favorite ice-cream, you may not find it to be a very helpful flavor of error message, but here it is anyway:

In our experience, this kind of error crops up when users try to ... or ... or even ...

Replied on Tue, 09/01/2009 - 18:33
Picture of user. klang Joined: Aug 23, 2009

In reply to by neale

A couple of us here at KU were discussing this very issue, and we agree that it would be very useful to compile some sort of repository of R errors for the frustrated user to reference in their time of crisis.

Maybe this list could be added to a section in the documentation as an easy reference for looking up a new or unfamiliar error message?

Replied on Tue, 09/01/2009 - 18:41
Picture of user. tbates Joined: Jul 31, 2009

In reply to by klang

excellent :-)

We don't yet know what these errors are that people encounter, so compiling the list is what is needed:

Whenever you get an error that is confusing, just go here,

http://openmx.psyc.virginia.edu/wiki/errors

If the error is not already there (only one so far), just click "Edit" and add it to the page...

post a note here with some context code and soon the list will have answers.

Replied on Wed, 09/02/2009 - 02:27
Picture of user. klang Joined: Aug 23, 2009

Here's the pertinent excerpt of the code which lead to Vexing Error #1 on the wiki:

# factor loadings for a variables
mxPath(from="FA",
to=c("a1","a2","a3","a4","a5","a6","a7","a8","a9","a10"),
arrows=1,
free=c(TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE,TRUE),
values=c(.3,.3,.3,.3,.3,.3,.3,.3,.3,.3),
labels=c("l1","l2","l3","l4","l5","l6","l7","l8","l9","l10")
),
#Effects Coding

mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = "l1", labels = "aa", lbound = 0,
ubound = 2, name = "la"),
mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = "l2", labels = "bb", lbound = 0,
ubound = 2, name = "lb"),
mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = "l3", labels = "cc", lbound = 0,
ubound = 2, name = "lc"),
mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = "l4", labels = "dd", lbound = 0,
ubound = 2, name = "ld"),
mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = "l5", labels = "ee", lbound = 0,
ubound = 2, name = "le"),
mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = "l6", labels = "ff", lbound = 0,
ubound = 2, name = "lf"),
mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = "l7", labels = "gg", lbound = 0,
ubound = 2, name = "lg"),
mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = "l8", labels = "hh", lbound = 0,
ubound = 2, name = "lh"),
mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = "l9", labels = "ii", lbound = 0,
ubound = 2, name = "li"),
mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = "l10", labels = "jj", lbound = 0,
ubound = 2, name = "lj"),
mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = FALSE, values = 10, labels = "con", lbound = 9,
ubound = 10, name = "cona"),

mxAlgebra(name="sa",
la+lb+lc+ld+le+lf+lg+lh+li+lj
),
mxConstraint("sa","=","cona"),

I introduced these 11 new matrices in an attempt to set the scale for factor A using the effects coding method, but I hit a wall of errors that I can't figure out.

Replied on Wed, 09/02/2009 - 07:02
Picture of user. tbates Joined: Jul 31, 2009

In reply to by klang

You are trying to set the value of those matrices to a character label.

mxMatrix(type = "Full", nrow = 1, ncol = 1, free = FALSE, 
       values = "l1", labels = "aa", 
       lbound = 0, ubound = 2, name = "la"),

We try and convert the character to a numeric value, can't, return an NA... hence the error: NAs induced by coercion.

if you want matrix "la" to have its value equated to "l1", then make the label of matrix "la" be "l1"

Replied on Wed, 09/02/2009 - 07:26
Picture of user. tbates Joined: Jul 31, 2009

In reply to by klang

that's also setting the bounds on a fixed value, which is not necessary?

mxMatrix(type = "Full", nrow = 1, ncol = 1,free = FALSE, values = "l1", labels = "aa", lbound = 0, ubound = 2, name = "la")

-->
mxMatrix(type = "Full", nrow = 1, ncol = 1,free = FALSE, values = "1", labels = "l1", name = "la")
Replied on Wed, 09/02/2009 - 17:19
Picture of user. klang Joined: Aug 23, 2009

In reply to by tbates

Thanks a bunch! That did it, but I ended up having to free the elements of the 1X1 matrices to get them to equate with the lambdas. The code ended up looking like this:

mxMatrix(type = "Full", nrow = 1, ncol = 1,
free = TRUE, values = 1, labels = "l1", name = "la"),

Replied on Wed, 09/02/2009 - 19:41
Picture of user. mspiegel Joined: Jul 31, 2009

In reply to by klang

Several lines are of the form:

   mxMatrix(type = "Full", nrow = 1, ncol = 1,
   free = FALSE, values = "l1", labels = "aa", lbound = 0,
   ubound = 2, name = "la")

The 'values' argument expects a numeric argument. Looks like I need to add some error checking. At the moment, this character is being converted into an NA, and then the NA is thrown away and 0 is used.