Displaying 20 results from an estimated 6000 matches similar to: "Smooth periodic splines"
2008 Oct 21
4
Multi matrix row-wise mapply?
Hi group!
Suppose I have 2 matrices A and B of equal dimensions.
I want to apply a function f to all corresponding pairs of rows from A
and B in an efficient manner.
Basically, I want
mapply(f, data.frame(A), data.frame(B))
but for rows.
How do I do it?
Thanks,
Andrey
2008 Jun 20
5
Programming Concepts and Philosophy
I am wondering if people on the list could recommend books that they
have found helpful about programming concepts and style? I often find
that students write R programs by copying existing code but could really
benefit from the understanding of more general programming ideas. An
example would be to avoid writing functions which attempt to modify
their parameters. Another principle would be
2009 Jan 17
2
DierckxSpline segfault
I've just encountered a segfault when using DierckxSpline::percur
function. Below is the minimal example which triggers the error:
---
library(DierckxSpline)
x <- 1:10
y <- rep(0, 10)
pspline <- percur(x, y)
---
*** caught segfault ***
address (nil), cause 'memory not mapped'
Traceback:
1: .Fortran("percur", iopt = as.integer(iopt), m = as.integer(m),
x =
2006 Mar 17
1
Derivative of a splinefun function.
Is there a way of calculating the derivative of a function returned
by splinefun()? Such a function is a cubic spline, whence it has a
calculable derivative, but is there a (simple) way of getting at it?
One workaround that I have thought of is to take a fine grid of
points, evaluate the function returned by splinefun() at these
points, put an interpolating spline through these points using
2007 Oct 05
2
Splines
I want to fit a cubic spline of x on y. where :
x
[1] 467 468 460 460 450 432 419 420 423 423
y
[1] 1 2 3 4 5 6 7 8 9 10
using the syntax
spline(y, x)
I got following output :
$x
[1] 1.000000 1.310345 1.620690 1.931034 2.241379 2.551724 2.862069
[8] 3.172414 3.482759 3.793103 4.103448 4.413793 4.724138 5.034483
[15] 5.344828 5.655172
2010 Dec 08
1
I want to get smoothed splines by using the class gam
Hi all,
I try to interpolate a data set in the form:
time Erg
0.000000 48.650000
1.500000 56.080000
3.000000 38.330000
4.500000 49.650000
6.000000 61.390000
7.500000 51.250000
9.000000 50.450000
10.500000 55.110000
12.000000 61.120000
18.000000 61.260000
24.000000 62.670000
36.000000 63.670000
48.000000 74.880000
I want to get smoothed splines by using the class gam
The first way I tried , was
2007 Dec 26
1
Cubic splines in package "mgcv"
R-users
E-mail: r-help@r-project.org
My understanding is that package "mgcv" is based on
"Generalized Additive Models: An Introduction with R (by Simon N. Wood)".
On the page 126 of this book, eq(3.4) looks a quartic equation with respect
to
"x", not a cubic equation. I am wondering if all routines which uses
cubic splines in mgcv are based on this quartic
2006 Jun 24
3
getting the smoother matrix from smooth.spline
Can anyone tell me the trick for obtaining the smoother matrix from smooth.spline when there are non-unique values for x. I have the following code but, of course, it only works when all values of x are unique.
## get the smoother matrix (x having unique values
smooth.matrix = function(x, df){
n = length(x);
A = matrix(0, n, n);
for(i in 1:n){
y = rep(0, n); y[i]=1;
yi =
2013 Mar 06
1
Constrained cubic smoothing spline
Hello everone,
Anyone who knows how to force a cubic smoothing spline to pass through a particular point?
I found on website someone said that we can use "cobs package" to force the spline pass through certain points or impose shape constraints (increasing, decreasing). However, this package is using B-spline and can only do linear and quadratic
2009 Mar 31
2
How to generate natural cubic spline in R?
Suppose I have two var x and y,now I want to fits a natural cubic
spline in x to y,at the same time create new var containing the
smoothed values of y. How can I get it?
2010 May 19
1
Displaying smooth bases - mgcv package
Dear all,
for demonstration purposes I want to display the basis functions used by a
thin plate regression spline in a gamm model. I've been searching the help
files, but I can't really figure out how to get the plots of the basis
functions. Anybody an idea?
Some toy code :
require(mgcv)
require(nlme)
x1 <- 1:1000
x2 <- runif(1000,10,500)
fx1 <- -4*sin(x1/50)
fx2 <-
2008 Jun 14
3
cbind'ing multivariate ts objects
I use R 2.7.0 on GNU/Linux. I have noticed a problem in cbind method
for multivariate time series (ts) objects. Consider the following
example:
> t <- ts(data.frame(a = 10:20, b = 20:30, c = 30:40, d = 40:50))
> t1 <- t[, c('a', 'b')]
> t2 <- t[, c('c', 'd')]
>
> colnames(t1)
[1] "a" "b"
> colnames(t2)
[1]
2011 Jul 19
2
Incorrect degrees of freedom for splines using GAMM4?
Hello,
I'm running mixed models in GAMM4 with 2 (non-nested) random intercepts and
I want to include a spline term for one of my exposure variables. However,
when I include a spline term, I always get reported degrees of freedom of
less than 1, even when I know that my spline is using more than 1 degree of
freedom. For example, here is the code for my model:
>
2009 Oct 13
2
How to choose a proper smoothing spline in GAM of mgcv package?
Hi, there,
I have 5 datasets. I would like to choose a basis spline with same knots in
GAM function in order to obtain same basis function for 5 datasets.
Moreover, the basis spline is used to for an interaction of two covarites.
I used "cr" in one covariate, but it can only smooth w.r.t 1 covariate. Can
anyone give me some suggestion about how to choose a proper smoothing spline
2012 May 08
2
mgcv: inclusion of random intercept in model - based on p-value of smooth or anova?
Dear useRs,
I am using mgcv version 1.7-16. When I create a model with a few
non-linear terms and a random intercept for (in my case) country using
s(Country,bs="re"), the representative line in my model (i.e.
approximate significance of smooth terms) for the random intercept
reads:
edf Ref.df F p-value
s(Country) 36.127 58.551 0.644
2011 Mar 30
3
Connect observed values by a smooth curve, is there any method to get coordinate value of arbitrary point on the curve?
Dear all,
I have the problem as the title shows. It is time series of measurements. I
want to estimate the value at time point when we have no actual measured
value (Only in the time range, not for prediction in future time).
Hope you could give me some suggestion or hint. Thank you so much.
Wang Zhipeng
[[alternative HTML version deleted]]
2006 Nov 07
1
gamm(): nested tensor product smooths
I'd like to compare tests based on the mixed model representation of additive models, testing among others
y=f(x1)+f(x2) vs y=f(x1)+f(x2)+f(x1,x2)
(testing for additivity)
In mixed model representation, where X represents the unpenalized part of the spline functions and Z the "wiggly" parts, this would be:
y=X%*%beta+ Z_1%*%b_1+ Z_2%*%b_2
vs
y=X%*%beta+ Z_1%*%b_1+ Z_2%*%b_2 + Z_12
2009 Apr 09
1
pdftex treats R pdf figures incorrectly
Hello!
I use R 2.8.1 under Debian GNU/Linux. I've run into a problem
including R pdf figures into LaTeX document. To reproduce:
1) Execute the following minimal R script:
pdf('fig.pdf', family = 'URWTimes', width = 5, height = 5)
plot(rnorm(10), main = '????', xlab = '????????', ylab = '????????')
dev.off()
embedFonts('fig.pdf')
2) Open
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
2008 Oct 06
1
splinefun gives incorrect derivs when extrapolating to the left (PR#13132)
This is a low priority bug that has been around for a while, but I came acr=
oss it again while alpha testing 2.8.
The resulting function for splinefun gives incorrect deriv values when x is=
less than the smallest x-value used to create the function (at least in on=
e circumstance), but does the correct thing for x greater than the largest =
x-value.
Here is an example:
> x <- 1:10
>