[R] g parameter for deltaMethod() as a function
Marc Girondot
marc_grt at yahoo.fr
Mon Jan 30 19:30:43 CET 2017
Le 30/01/2017 à 19:04, Fox, John a écrit :
>> 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:
> I don't see how that would work. From ?deltaMethod: "g [the second argument]: A quoted string that is the function of the parameter estimates to be evaluated; see the details below."
>
> A possible solution would be to write a wrapper function that prepares a proper call to deltaMethod().
Hi John,
This is exactly what I try to do: a wrapper (I forget that name in
English !).
I have made some progress to do a wrapper function:
try_g <- function(...) {
par <- list(...)
return(par$t1/par$t2)
}
try_g(t1=1, t2=2)
deltaMethod(coef(m1), "try_g(t1, t2)", vcov.=vcov(m1))
The wrapper function try_g is accepted now, but I get an error because
deltaMethod() tried to do symbolic derivative:
> deltaMethod(coef(m1), "try_g(t1, t2)", vcov.=vcov(m1))
Error in D(g, names(para)[i]) :
La fonction 'try_g' n'est pas dans la table des dérivées
(translation: The function 'try_g' is not in the table of derivative
functions).
I was hopping that numeric approximation of derivative (example
numDeriv::grad() or deriv() ) could be used, but it is not the case.
Thanks
Marc
[[alternative HTML version deleted]]
More information about the R-help
mailing list