g l
2018-Apr-05 21:00 UTC
[R] Obtain gradient at multiple values for exponetial decay model
> Sent: Thursday, April 05, 2018 at 4:40 PM > From: "Jeff Newmiller" <jdnewmil at dcn.davis.ca.us> > > the coef function. >For the benefit of other novices, used the following command to read the documentation: ?coef Then tried and obtained:> cvalue100<-coef(graphmodelp~100) > cvalue100NULL Then looked at the model values which of course correspond to original non-modelled values. graphmodelp 1 2 3 4 5 6 7 8 91.244636 69.457794 52.873083 40.248368 30.638107 23.322525 17.753714 13.514590 9 10 11 10.287658 7.831233 5.961339 This prompted to think that interpolation is required, but the function 'approx' only seems to perform constant interpolation. Is the correct thinking to find a function to perform interpolation, then find/write a function to differentiate the model at a specific value of x, to find gradient at that point?
Jeff Newmiller
2018-Apr-06 02:53 UTC
[R] Obtain gradient at multiple values for exponetial decay model
Try coef( graphmodeld ) And you don't need to approximate if you use the newdata argument to the predict function. I think reading the "Introduction to R" that comes with R would help. -- Sent from my phone. Please excuse my brevity. On April 5, 2018 2:00:45 PM PDT, g l <gnulinux at gmx.com> wrote:>> Sent: Thursday, April 05, 2018 at 4:40 PM >> From: "Jeff Newmiller" <jdnewmil at dcn.davis.ca.us> >> >> the coef function. >> > >For the benefit of other novices, used the following command to read >the documentation: > >?coef > >Then tried and obtained: > >> cvalue100<-coef(graphmodelp~100) >> cvalue100 >NULL > >Then looked at the model values which of course correspond to original >non-modelled values. > >graphmodelp >1 2 3 4 5 6 7 8 > >91.244636 69.457794 52.873083 40.248368 30.638107 23.322525 17.753714 >13.514590 > 9 10 11 >10.287658 7.831233 5.961339 > >This prompted to think that interpolation is required, but the function >'approx' only seems to perform constant interpolation. > >Is the correct thinking to find a function to perform interpolation, >then find/write a function to differentiate the model at a specific >value of x, to find gradient at that point?
David Winsemius
2018-Apr-06 03:55 UTC
[R] Obtain gradient at multiple values for exponetial decay model
> On Apr 5, 2018, at 2:00 PM, g l <gnulinux at gmx.com> wrote: > >> Sent: Thursday, April 05, 2018 at 4:40 PM >> From: "Jeff Newmiller" <jdnewmil at dcn.davis.ca.us> >> >> the coef function. >> > > For the benefit of other novices, used the following command to read the documentation: > > ?coef > > Then tried and obtained: > >> cvalue100<-coef(graphmodelp~100) >> cvalue100 > NULLShould have been: coef(graphmodelp)> > Then looked at the model values which of course correspond to original non-modelled values. > > graphmodelp > 1 2 3 4 5 6 7 8 > 91.244636 69.457794 52.873083 40.248368 30.638107 23.322525 17.753714 13.514590 > 9 10 11 > 10.287658 7.831233 5.961339Read up on ?predict and what it delivers when only a model is offered as input.> > This prompted to think that interpolation is required, but the function 'approx' only seems to perform constant interpolation. > > Is the correct thinking to find a function to perform interpolation, then find/write a function to differentiate the model at a specific value of x, to find gradient at that point?Not correct. You already have `predict`. It is capale of using the `newdata` values to do interpolation with the values of the coefficients in the model. See: ?predict The original question asked for a derivative (i.e. a "gradient"), but so far it's not clear that you understand the mathematical definiton of that term. We also remain unclear whether this is homework.> > ______________________________________________ > R-help at 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.David Winsemius Alameda, CA, USA 'Any technology distinguishable from magic is insufficiently advanced.' -Gehm's Corollary to Clarke's Third Law
g l
2018-Apr-06 10:30 UTC
[R] Obtain gradient at multiple values for exponential decay model
> Sent: Friday, April 06, 2018 at 4:53 AM > From: "Jeff Newmiller" <jdnewmil at dcn.davis.ca.us> > To: "g l" <gnulinux at gmx.com> > coef( graphmodeld ) >coef(graphmodelp) Error: $ operator is invalid for atomic vectors A quick search engine query revealed primarily references to the dollar sign ($) operator which does not seem relevant to this question.
g l
2018-Apr-06 10:43 UTC
[R] Obtain gradient at multiple values for exponential decay model
> Sent: Friday, April 06, 2018 at 5:55 AM > From: "David Winsemius" <dwinsemius at comcast.net> > > > Not correct. You already have `predict`. It is capale of using the `newdata` values to do interpolation with the values of the coefficients in the model. See: > > ?predict >The ? details did not mention interpolation explicity; thanks.> The original question asked for a derivative (i.e. a "gradient"), but so far it's not clear that you understand the mathematical definiton of that term. We also remain unclear whether this is homework. >The motivation of this post was simple differentiation of a tangent point (dy/dx) manually, then wondering how to re-think in modern-day computing terms. Hence the original question about asking the appropriate functions/syntax to read further ("curiosity"), not the answer (indeed, "homework"). :) Personal curiosity should be considered "homework".
Apparently Analagous Threads
- Obtain gradient at multiple values for exponetial decay model
- Obtain gradient at multiple values for exponetial decay model
- Obtain gradient at multiple values for exponetial decay model
- Obtain gradient at multiple values for exponetial decay model
- Obtain gradient at multiple values for exponential decay model