Re: [R] deriv - accessing numeric output listed under gradient attribute

From: Sundar Dorai-Raj <sundar.dorai-raj_at_pdf.com>
Date: Wed 20 Jul 2005 - 09:57:33 EST

Jay Rotella wrote:
> Hi,
> I am interested in using the numeric output from the "gradient" attribute of
> deriv's output in subsequent analyses.
> But, I have so far been unable to determine how to do so.
>
> I will use the example from the deriv help to illustrate.
>
>

>>## function with defaulted arguments:
>>   (fx <- deriv(y ~ b0 + b1 * 2^(-x/th), c("b0", "b1", "th"),

>
> function(b0, b1, th, x = 1:7){} ) )
>
>>    fx(2,3,4)

>
>
> This yields
> [1] 4.522689 4.121320 3.783811 3.500000 3.261345 3.060660 2.891905
> attr(,"gradient")
> b0 b1 th
> [1,] 1 0.8408964 0.1092872
> [2,] 1 0.7071068 0.1837984
> [3,] 1 0.5946036 0.2318331
> [4,] 1 0.5000000 0.2599302
> [5,] 1 0.4204482 0.2732180
> [6,] 1 0.3535534 0.2756976
> [7,] 1 0.2973018 0.2704720
>
> I would greatly appreciate it if anyone could tell me how to convert the
> numbers listed under "b0", "b1", and "th" into a matrix.
>
> Thanks!
>
> Jay Rotella
> Ecology Department
> Montana State University
> Bozeman, MT 59717
>

Try:

attr(fx(2, 3, 4), "gradient")

--sundar



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jul 20 10:00:39 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:50 EST