[R] g parameter for deltaMethod() as a function

Marc Girondot marc_grt at yahoo.fr
Mon Jan 30 18:19:02 CET 2017

Hi everyone,

I try to use the Default S3 method DeltaMethod() from car package, but I 
have some problems when I try to use a function as the "g" parameter. I 
don't know if it is possible anyway. I hope that you could tell me:

Here an example from the help of deltaMethod(). It works and I 
understand well (I think at least !).

m1 <- lm(time ~ t1 + t2, data = Transact)
deltaMethod(coef(m1), "t1/t2", vcov.=vcov(m1))


I would like do the same with a function instead of "t1/t2":

try_g <- function(...) {
   par <- list(...)

try_g(t1=1, t2=2)
deltaMethod(coef(m1), "try_g", vcov.=vcov(m1))

But I get an error:

Error in as.data.frame.default(x[[i]], optional = TRUE) :
   cannot coerce class ""function"" to a data.frame

If someone could give me the solution... or tell me if it is impossible !



PS. In fine I would like using deltaMethod() to produce a confidence 
interval after fitting a model using ML with optim.

More information about the R-help mailing list