[R] DierckxSpline fitting with different sets of y-values in one time

spencerg spencer.graves at prodsyse.com
Sat Apr 11 16:38:11 CEST 2009


Dear Elisabeth:


      I got the following error from your call to "curfit.free.knot": 


 > splinefit<-with(DF, curfit.free.knot(Age, Connectivity, k=1, g=1, 
prior=NULL))
Error in xyw.coords(x, y, w) :
  Need at least 4 distinct x values.  Only 3 distinct values found 
(after combining observations equal to 6 significant digits starting 
from 5 observations)


      The problem here is that you have 3 subjects at the same age (25) 
with 3 distinct ages (23, 24, 25).  "curfit.free.knot" wants at least 4 
distinct ages, like 20, 23, 24, 25, 30. 


      Beyond this, it would still help to know more about what you are 
trying to do.  From your description, it's not clear to me that you 
necessarily even need splines, let alone free-knot splines. 


      Have you tried "RSiteSearch"?  I just got 58 hits from " 
RSiteSearch('fMRI')" and 48 from " RSiteSearch('fMRI', 'function')".  
Using the "RSiteSearch" package available via 
'install.packages("RSiteSearch",repos="http://r-forge.r-project.org")', 
I found that 20 of the 48 hits were for an "fmri" package, and another 
13 were for "AnalyzeFMRI".  Three of the remaining were for 
"brainwaver", whose description mentions "the camba project for 
brain-data preprocessing."  The remaining 7 were in 5 different 
packages.  Might any of those hits help you? 


      Hope this helps. 
      Spencer Graves


Jonckers Elisabeth wrote:
>
> Dear,
>
> So What I'm looking at is the effect of age on the functional 
> connectivity in a certain brain network. I have the ages of different 
> subjects as x-values and values representing this functional 
> connectivity with a region of intrest. This values are always for one 
> voxel. But I found a whole cluster with higher connectivity in younger 
> peoply so I wanted to use the values of different voxels of this 
> cluster except of only the values of the voxel with the biggest t-value.
> The script I used is described below (short version with only 5 
> subjects). The reason whe used DierckSpline is that when you just fit 
> a line it looks like a line with a "knot" would better fit the data.
>
> Age<-c(23,24,25,25,25)
> Connectivity<-c(0.453,0.628,0.518,-0.060,0.384)
>
> DF<-data.frame(cbind(Age,Connectivity))
> plot(Age,Connectivity)
> splinefit<-with(DF, curfit.free.knot(Age, Connectivity, k=1, g=1, 
> prior=NULL))
>
> splinefit
>
> xfit1<-c(Age[1],splinefit$knots[3])  
> xfit2<-c(splinefit$knots[3],Age[length(Age)])
>
> yfit1<-c(splinefit$coef[1],splinefit$coef[2])
> yfit2<-c(splinefit$coef[2],splinefit$coef[3])
>
> lines(xfit1,yfit1)
> lines(xfit2,yfit2)
>
> I already tried to add some sets of y-values in the script but I 
> always get errors. Such as "invalid plot type".
>  The problem is that I'm not at all familiar with the "language" used 
> for this scripts so it's very difficult to find the right sollution.
> I also looked at the information about thin plate splines but I don't 
> think that's what I need.
>
> Thank you already for helping me in the right direction, I hope is a 
> little easier to understand now what I'm doing.
>
> Elisabeth Jonckers
>
>  
>
>
>
>
>
> Dear Elisabeth:
>
>       Have you tried it?  I have not, but I suspect the answer is "no".
>
>       What problem are you trying to solve?  You might get more useful
> suggestions from this list if you provide commented, minimal,
> self-contained, reproducible code describing your problem and what
> you've tried to solve it, as suggested in the posting guide
> "www.R-project.org/posting-guide.html".
>
>       With fmri images, I might look first at the "fields" package,
> because it is explicitly designed for "curve, surface and function
> fitting with an emphasis on splines, spatial data and spatial
> statistics. The major methods include cubic, robust, and thin plate
> splines, multivariate Kriging and Kriging for large data sets."  I have
> not used it, but it sounds to me like you might want thin plate
> splines.  Paul Dierckx (1993) Curve and Surface Fitting with Splines
> (Oxford Science Publications) discusses thin plate splines, and Dierckx
> wrote Fortran to fit them.  However, the "DierckxSpline" package does
> not currently connect to those capabilities.
>
>       If univariate splines would do, I might start with the "fda"
> package.  The theory behind that is documented in two books by Ramsay
> and Silverman.
>
>       Hope this helps.
>       Spencer Graves
>
> Jonckers Elisabeth wrote:
> > Dear "R" users,
> >
> > I have a question about the Package DierckxSpline. I have tried to 
> find the answer by myself but it didn't worked out.
> >
> > I wondered if Dierckxspline can use different sets of y values in 
> one time to fit a line with knot. I have different sets of Y values 
> representing the same thing for different voxels (in an fmri image). I 
> have already fitted the data in different graphs and I know now that 
> the plots are comparable for the different data sets (so for the 
> different voxels) but I wanted to include all the information in one 
> plot, If it's possible. So I want to know the best fitting line for 
> the whole cluster of voxels except for one voxel.
> > If there is no possibility to do this I tought it would be an option 
> to take the mean of the different y-values and use those values but I 
> don't know if this is mathematical right to do.
> > I hope someone can help me with this.
> >
> > Thank you very much,
> > Elisabeth Jonckers
> > GIfMI
> > Ghent University Hospital
> > Belgium
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > 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.
> >
> >
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.
>
>
>
>
>




More information about the R-help mailing list