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]]

______________________________________________
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