[R] obtaining output from an evaluated expression
Jack Bowden
jack.bowden at mrc-bsu.cam.ac.uk
Fri Dec 19 11:09:33 CET 2008
Hi
I am trying to use the deriv and eval functions to obtain the value of a
function , say "xi-(alpha0+alpha1*gi)" , differentiated with respect to
alpha0 and alpha1, in the following way
# for gi = 0
> dU1dtheta <- deriv(~ xi-(alpha0+alpha1*gi), c("alpha0","alpha1"))
> eval(dU1dtheta)
(Intercept)
-0.2547153
attr(,"gradient")
alpha0 alpha1
[1,] -1 0
I want to extract the output gradient values of -1 and 0 but I don't
know how to access them. The only thing I can access is the intercept
term via.
> eval(dU1dtheta)[1].
I'm sorry if this is too basic a question for the list, but any help
would be greatly appreciated
Jack
--
Dr Jack Bowden
MRC Biostatistics Unit
Institute of Public Health
Forvie Site
Robinson Way
Cambridge
CB2 0SR
Tel: (01223) 330385
More information about the R-help
mailing list