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 !).

library(car)
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(...)
  return(par$t1/par$t2)
}

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 !

Thanks

Marc

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

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to