similar to: interpolation and numerical differentiation in R ?

Displaying 20 results from an estimated 2000 matches similar to: "interpolation and numerical differentiation in R ?"

2001 Dec 15
1
fit to spike with exponential decay : optim() question
I finally got (mostly) what I wanted. In an attempt to figure out how to get nls to deal with a non-differentiable function, I had (stupidly) 'simplified' the problem until it became singular. Can I do something to make optim() less sensitive to my initial guess? For this example, I get a lousy solution if I make the initial guess for t0 = min(t) = 0.05. Thanks again, -- Robert Merithew
2001 Oct 05
1
nls() fit to a lorentzian - can I specify partials?
First, thanks to all who helped me with my question about rescaling axes on the fly. Using unlist() and range() to set the axis ranges in advance worked well. I've since plotted about 300 datasets with relative ease. Now I'm trying to fit a lossy oscillator resonance to (the square root of) a lorentzian (testframe$y is oscillator amplitude, testframe$x is drive frequency): lorentz
2002 Nov 04
2
interpolation
Hello, I have 15 data points (weight at birth) by age which I want to interpolate back in time (to 5 more age points). There are many functions in R to do this and I wonder if anyone has experience in using these -- any preference/caveat etc? I am trying to find an alternative to linear interpolation. Using R 1.6.0 under windows TIA Marwan
2009 Jan 08
2
interpolation to abscissa
Readers, I have looked at various documents hosted on the web site; I couldn't find anything on interpolation. So I started r and accessed the help (help.start()). (by the way is it possible to configure r to open help in opera instead of firefox?) Initially I read the help for the akima package but couldn't understand it. Next I tried the asplines package help. I tried to copy the
2016 Mar 04
2
R 3.2.4 rc issue
I generally run 'make; make check' (with more settings) when building the Debian package. Running 3.2.4 rc from last night, I see a lot of package loading issues during 'make check'. Here is splines as one examples: checking package 'splines' * using log directory '/build/r-base-3.2.3.20160303/tests/splines.Rcheck' * using R version 3.2.4 RC (2016-03-02 r70270) *
2009 Feb 26
2
interpSpline with dates?
Dear R-helpers, can I use a POSIXct date as the x variable in interpSpline? The help page says x and y need to be numeric... is there a workaround? example: library(splines) testdfr <- data.frame(Date=seq(as.POSIXct("2008-08-01"),as.POSIXct("2008-09-01"), length=10)) testdfr$yvar <- rnorm(10) sp <- interpSpline(yvar ~ Date, testdfr) preddfr <-
2010 Sep 14
1
predict(backSpline(x)): losing my marbles?
I'm sure I'm doing something completely boneheaded here, but I've used this idiom (constructing an interpolation spline and using prediction from a backSpline to find an approximation profile confidence interval) many times before and haven't hit this particular problem: r2 <- c(1.04409027570601, 1.09953936543359, 1.15498845516117, 1.21043754488875,
2008 Sep 27
3
Double integration - Gauss Quadrature
Hi, I would like to solve a double integral of the form \int_0^1 \int_0^1 x*y dx dy using Gauss Quadrature. I know that I can use R's integrate function to calculate it: integrate(function(y) { sapply(y, function(y) { integrate(function(x) x*y, 0, 1)$value }) }, 0, 1) but I would like to use Gauss Quadrature to do it. I have written the following code (using R's statmod package)
2000 Sep 04
2
bug in spline()? (PR#653)
BUG IN SPLINE()? Version R-1.0.1, system i486,linux If the spline(x,y,method="natural") function is given values outside the range of the data, it does not give a warning. Moreover, the extrapolated value reported is not the ordinate of the natural spline defined by (x,y). Example. Let x <- c(2,5,8,10) and y <- c(1.2266,-1.7606,-0.5051,1.0390). Then interpolate/extrapolate with
2001 Dec 14
1
nls fit to exponential decay with unknown time origin
I'm trying to use nls() to fit an exponential decay with an unknown offset in the time (independent variable). (Perhaps this is inherently very difficult?). > decay.pl <- nls (amp ~ expn(b0,b1,tau,t0,t), data = decay, + start = c(b0=1, b1=7.5, tau=3.5, t0=0.1), trace=T) Error in nlsModel(formula, mf, start) : singular gradient matrix at initial parameter estimates
2001 Oct 01
3
can I add to a plot and auto-re-scale axes?
(I'm new to R) Is there a way to add data to an existing plot, and have the plot axes rescaled automatically (i.e. if the new data lie outside the current axes) ? If not, how can I specify multiple datasets at once, so the axes are scaled to accomodate all sets? Details: (Am I using R's data structures in a reasonable way?) I have many small datasets taken under different
2002 Jun 04
4
par(xaxp)
I think this is a bug; at least this behavior is not documented in plot or plot.default. plot.default resets xaxp, and leaves xaxp reset when it exits: par(xaxp=c(0,1,4)) print(par("xaxp")) plot(c(0,1),c(0.2,0.3)) print(par("xaxp")) R. Woodrow Setzer, Jr. Phone: (919) 541-0128 Experimental Toxicology Division
2006 Jul 31
1
questions regarding spline functions
Greetings, A couple general questions regarding the use of splines to interpolate depth profile data. Here is an example of a set of depths, with associated attributes for a given soil profile, along with a function for calculating midpoints from a set of soil horizon boundaries: #calculate midpoints: mid <- function(x) { for( i in 1:length(x)) { if( i > 1) { a[i] = (x[i] -
1998 Apr 07
3
R-beta: spline problems(?)
Hi, I am a total beginner with this whole thing so please have patience! I am trying to run an S-plus program with a certain line: spline(1:nrow(y), y[,1],n=100); This crashes with: Error: NAs in foreign function call (arg 8) Apparently, this is caused by the last command of spline: u <- seq(xmin, xmax, length.out = n) .C("spline_eval", z$method, length(u), x = u, y =
2002 Aug 14
1
numerical differentiation
Hi, I would like like to compute first and second derivative from numerical data. I hoped I could compute a spline object from the data (that works), and then compute the derivative from that spline objects, but I couldn't find anything like that. Does somebody know how to get numerical derivatives? Oliver -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2003 Jul 16
2
numerical differentiation in R? (for optim "SANN" parscale)
Dear R users, I am running a maximum likelihood model with optim. I chose the simulated annealing method (method="SANN"). SANN is not performing bad, but I guess it would be much more effecive if I could set the `parscale' parameter. The help sais: `parscale' A vector of scaling values for the parameters. Optimization is performed on `par/parscale' and these
2005 May 05
2
Numerical Derivative / Numerical Differentiation of unkno wn funct ion
Ah... I searched for half an hour for this function... you know, the help function in R could really be a lot better... But wait a minute... looking at this, it appears you have to pass in an expression. What if it is an unknown function, where you only have a handle to the function, but you cannot see it's implementation ? Will this work then ? -----Original Message----- From: Berton Gunter
2005 May 05
2
Numerical Derivative / Numerical Differentiation of unknown funct ion
Hi, I have been trying to do numerical differentiation using R. I found some old S code using Richardson Extrapolation which I managed to get to work. I am posting it here in case anyone needs it. ######################################################################## richardson.grad <- function(func, x, d=0.01, eps=1e-4, r=6, show=F){ # This function calculates a numerical approximation
2001 Sep 05
2
Replacing NAs with interpolated values
Hi there, I've got this vector: -84 -87 -90 -90 -89 -86 NA NA NA NA NA NA NA NA NA NA NA NA -96 -99 -100 -99 -96 -92 -89 -87 -87 -88 -90 -92 -94 -95 -96 -97 -97 -97 -96 -95 Is there a function in R which replaces the NAs with "interpolated" values between -86 and -96? Thanks, Sven
2007 Sep 19
3
Smooth line in graph
Hi, I?m trying to get smooth curves connecting points in a plot using "spline" but I don?t get what I whant. Eg.: x<-1:5 y <- c(0.31, 0.45, 0.84, 0.43, 0.25) plot(x,y) lines(spline(x,y)) Creates a valley between the first and second points, then peaks at 3rd, and another valley between 4th and 5th. I?m trying to get a consistently growing curve up to the 3rth point and then a