guy33 wrote: > > 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 >
Out of curiosity, am I right about why scaling the data in this way seems to "fix" the problem? I meant that when the X-range = [0,1] and y-range = [-1,1], var(x) = 0.0835 and var(y) = 0.5, so the first principal component, which the algorithm uses, is vertical. However, when the x-range is scaled to [0,2*pi], var(x) becomes 3.299 > var(y) (=0.5 still), so now the first principal component is in the horizontal direction, which leads to expected behavior. > 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-tp3535721p3581380.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.