As suggested above, specifying useful starting points definitely helps in the case of:
x <- seq(0,2*pi, length=1000) x <- cbind(x/(2*pi), sin(x)) fit1 <- principal.curve(x, plot = TRUE, trace = TRUE, maxit = 100, start = cbind(sort(x[,1]), rep(1, nrow(x)))) Interestingly, I find that if you simply scale the X-axis from [0,1] to [0,2*pi], the algorithm converges without the starting points, as in: x <- seq(0,2*pi, length=1000) x <- cbind(x, sin(x)) fit1 <- principal.curve(x, plot = TRUE, trace = TRUE) I assume this is because scaling the data in this way changes the first principal component. However, this begs the question of what happens when you consider more than one sine wave (and what happens when you scale the x-axis). For example: x <- seq(0,10*pi, length=1000) x <- cbind(x, sin(x)) fit1 <- principal.curve(x, plot = TRUE, trace = TRUE) I can't seem to get a good curve for this, with or without starting conditions. Can anyone get a better fit somehow? -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-Princurve-tp3535721p3581363.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@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.