Terry,

this happens since the ranef in coxme is a S3 generic and the one in lme4 is a S4 generic.

Of course, after loading lme4, you can still use the ranef from coxme:

coxme::ranef(fit)

and get the desired result.

If you write your own code, you might want to use that call explicitly (i.e. accessing from the correct namepsace). In your own package, you could simply import the generic from coxme.

Best wishes,
Uwe






On 05.03.2010 17:47, Terry Therneau wrote:
The coxme package has a ranef() method, as does lme4.  I'm having
trouble getting them to play together, as shown below.  (The particular
model in the example isn't defensible, but uses a standard data set.)

The problem is that most of the time only one of lme4 or coxme will be
loaded, so each needs to define the basic ranef function as well as a
method for it.  But when loaded together the last one wins.  The coxme
object is an S3 class BTW. (Suggestions to convert it to S4 will not be
well recieved -- but that's a different and unnecessary thread.)

Odds are that this has a simple solution which I have missed.
      Terry Therneau


tmt935% R --vanilla

R version 2.10.0 (2009-10-26)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

   Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

library(coxme)
Loading required package: survival
Loading required package: splines
Loading required package: bdsmatrix

fit<- coxme(Surv(time, status) ~ age + (1|ph.ecog), lung)
ranef(fit)
$ph.ecog
Intercept
0.1592346

library(lme4)
Loading required package: Matrix
Loading required package: lattice

Attaching package: 'lme4'


         The following object(s) are masked from package:coxme :

          fixef,
          ranef

ranef(fit)
Error in function (classes, fdef, mtable)  :
   unable to find an inherited method for function "ranef", for signature
"coxme"
q()

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to