I have a series of xyz data in a unit cube. It forms a sort of tapered & curved cylinder. It will begin and end at 0,0,0 and 1,1,1. I want some sort of best fit curve down the 'axis' of this shape. And I need to take a new xyz point and map/project it onto this best fit curve. If I was expecting a straight line, I'd use the first principal component, but in this case I'm almost certain that I want some kind of 3d spline. I'm not after a fit to the surface. To be clear, there is no response variable; it's just xyz data points, so a model is not what I need.

Can someone give me some suggestions for the name of what I want to do? I need some keywords to get me going. I'm working in R so if you can suggest a package even better. Alternatively, perhaps something in Matlab would work. But mostly I need to know what this process is called. Thanks.


1 Answer 1


Sounds like a job for a principal curve. In R try the princurve package based on Trevor Hastie's original code. The cems package would be worth a look too as it fits principal curves via a different approach, but it has been archived on CRAN (or was last time I looked) because it was failing checks there. cems is still there but you need to build it yourself.

You can look at a description of principal curves in Hastie et al (2010) Elements of Statistical Learning on page 541. The PDF is freely available.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.