g l
2018-Apr-05 10:44 UTC
[R] Obtain gradient at multiple values for exponetial decay model
Readers, Data set: t,c 0,100 40,78 80,59 120,38 160,25 200,21 240,16 280,12 320,10 360,9 400,7 graphdata<-read.csv('~/tmp/data.csv') graphmodeld<-lm(log(graphdata[,2])~graphdata[,1]) graphmodelp<-exp(predict(graphmodeld)) plot(graphdata[,2]~graphdata[,1]) lines(graphdata[,1],graphmodelp) Please what is the function and syntax to obtain gradient values for the model curve at various requested values, e.g.: when graphdata[,1] at values = 100, 250, 350 ?
Jeff Newmiller
2018-Apr-05 14:40 UTC
[R] Obtain gradient at multiple values for exponetial decay model
This smells like homework, which the Posting Guide indicates is off topic. I am not aware of "the function" that will solve this, but if you know what a gradient is analytically then you should be able to put together a solution very similar to the code you already have with the addition of using the coef function. -- Sent from my phone. Please excuse my brevity. On April 5, 2018 3:44:03 AM PDT, g l <gnulinux at gmx.com> wrote:>Readers, > >Data set: > >t,c >0,100 >40,78 >80,59 >120,38 >160,25 >200,21 >240,16 >280,12 >320,10 >360,9 >400,7 > >graphdata<-read.csv('~/tmp/data.csv') >graphmodeld<-lm(log(graphdata[,2])~graphdata[,1]) >graphmodelp<-exp(predict(graphmodeld)) >plot(graphdata[,2]~graphdata[,1]) >lines(graphdata[,1],graphmodelp) > >Please what is the function and syntax to obtain gradient values for >the model curve at various requested values, e.g.: > >when graphdata[,1] at values = 100, 250, 350 ? > >______________________________________________ >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.
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?
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 exponential decay model
- Obtain gradient at multiple values for exponetial decay model
- Obtain gradient at multiple values for exponential decay model