[Rd] Strange error

Terry Therneau therneau at mayo.edu
Tue Apr 6 17:44:27 CEST 2010


Someone just sent me a data set that causes the lmekin function, part of
the kinship package, to fail.  In chasing it down I get an error I have
never seen before.

fit <- lmekin(icam1 ~ factor(center) + age + factor(sex),
              random= ~1|iid, data=chaidata, varlist=kmat)
Error in Y - fitted : non-numeric argument to binary operator

Add the recover option, and the offending lines are
    fitted <- c(X %*% lfit$coef)  #fitted, on the original scale
    residuals <- Y - fitted

> options(error=recover)
> fit <- lmekin(icam1 ~ factor(center) + age + factor(sex),
+               random= ~1|iid, data=chaidata, varlist=kmat)
Error in Y - fitted : non-numeric argument to binary operator

Enter a frame number, or 0 to exit   

1: lmekin(icam1 ~ factor(center) + age + factor(sex), random = ~1 | iid,
data 

Selection: 
Enter an item from the menu, or 0 to exit
Selection: 1
Called from: eval(expr, envir, enclos)
Browse[1]> dim(X)
[1] 2601    6
Browse[1]> lfit$coef
    (Intercept) factor(center)2 factor(center)3 factor(center)4
age 
    217.9110997      -2.9079576      -0.2147915      -7.8141818
0.5210394 
   factor(sex)2 
      5.1384741 
Browse[1]>  X %*% lfit$coef
`__Deferred_Default_Marker__`

----------------------------------------------

  X is a model.matrix.  If I save the two objects and reload them into a
fresh R session the multiplication works just fine. 

  I haven't modified this code in several years, and it is widely used.
All the C code is shared with coxme. Subsetting the data, or modifing
the fixed effects has no impact on the error.  The same code runs in
Splus.  At the point of error the computations have finished and it is
putting together a result list: all of the results are correct.
Nevertheless, my best (only) guess is memory corruption.

Questions:
  Is this a rational guess?  Any others?
  Can you give any further insight on the error message?

Terry Therneau

sessionInfo()
R version 2.10.0 (2009-10-26) 
x86_64-unknown-linux-gnu 

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
 [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] grDevices datasets  splines   graphics  utils     stats
methods  
[8] base     

other attached packages:
[1] survival_2.35-9 rlocal_1.5.3   
>



More information about the R-devel mailing list