From: Ravi Varadhan <rvaradhan_at_jhmi.edu>

Date: Mon, 23 May 2011 09:58:19 -0400

Iteration 10---distance^2: 13.02867

Iteration 11---distance^2: 13.03867

*>
*

*>
*

From: r-help-bounces_at_r-project.org [r-help-bounces_at_r-project.org] On Behalf Of Gavin Simpson [gavin.simpson_at_ucl.ac.uk] Sent: Monday, May 23, 2011 8:27 AM

To: guy33

Cc: r-help_at_r-project.org

Subject: Re: [R] Problem with Princurve

Date: Mon, 23 May 2011 09:58:19 -0400

Why does this not find a better solution?

*> 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))))
Starting curve---distance^2: 1499.5

Iteration 1---distance^2: 3.114789 Iteration 2---distance^2: 10.04492 Iteration 3---distance^2: 11.89215 Iteration 4---distance^2: 12.43235 Iteration 5---distance^2: 12.68524 Iteration 6---distance^2: 12.84443 Iteration 7---distance^2: 12.93624 Iteration 8---distance^2: 12.99118 Iteration 9---distance^2: 13.01280

Iteration 10---distance^2: 13.02867

Iteration 11---distance^2: 13.03867

You see that the projection distance is minimal at iteration 1, but the algorithm settles for an inferior projection (i..e. a greater projection distance).

If I do not provide any starting values, I get this:

> fit1 <- principal.curve(x, plot = TRUE, trace = TRUE, maxit = 100)

Starting curve---distance^2: 29692.03

Iteration 1---distance^2: 20.31220 Iteration 2---distance^2: 19.45939 Iteration 3---distance^2: 19.26387 Iteration 4---distance^2: 19.20626 Iteration 5---distance^2: 19.18666 Iteration 6---distance^2: 19.18059

This is even worse. It seems like the algorithm is quite sensitive to starting values. Is this behavior expected or is there some flaw in the algorithm?

Ravi.

From: r-help-bounces_at_r-project.org [r-help-bounces_at_r-project.org] On Behalf Of Gavin Simpson [gavin.simpson_at_ucl.ac.uk] Sent: Monday, May 23, 2011 8:27 AM

To: guy33

Cc: r-help_at_r-project.org

Subject: Re: [R] Problem with Princurve

On Thu, 2011-05-19 at 06:43 -0700, guy33 wrote:

> Hey all,

*>
**> I can't seem to get the princurve package to produce correct results, even
**> in the simplest cases. For example, if you just generate a 1 period
**> noiseless sine wave, and ask for the principal curve and plot, the returned
**> curve is clearly wrong (doesn't follow the sine wave). Here's my code:
**>
**> library(princurve)
**> x <- runif(1000,0,2*pi); x <- cbind(x/(2*pi), sin(x))
**> fit1 <- principal.curve(x, plot = TRUE)
**>
**> Anyone have any suggestions? If you run this code, do you get the correct
**> principal curve?
*

How about specifying some useful starting points?

fit1 <- principal.curve(x, plot = TRUE, trace = TRUE, maxit = 100,

start = cbind(sort(x[,1]), rep(1, nrow(x))))

And we need a few more iterations before convergence here. Starting from the first principal component for example might give useful starting points.

**HTH
**
G

> Any help would be really appreciated!

*> -guy33
**>
**> --
**> View this message in context: http://r.789695.n4.nabble.com/Problem-with-Princurve-tp3535721p3535721.html
**> Sent from the R help mailing list archive at Nabble.com.
**>
**> ______________________________________________
**> 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.
*

-- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% ______________________________________________ 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.Received on Mon 23 May 2011 - 14:02:28 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Mon 23 May 2011 - 18:40:09 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*