[R] How to use a matrix in pcurve?

Jari Oksanen jari.oksanen at oulu.fi
Sun Oct 24 09:49:18 CEST 2004


Sun,
On 24 Oct 2004, at 10:24, XP Sun wrote:

> Hi, Everyone,
>
> I want to calculate the principal curve of a points set.
> First I read the points'coordinate with function "scan",
> then converted it to matrix with the function "matrix",
> and fit the curve with function "principal.curve".
>
> Here is my data in the file "bmn007.data":
> 0.023603	 -0.086540	 -0.001533
> 0.024349	 -0.083877	 -0.001454
> ..
> ..
> 0.025004	 -0.083690	 -0.001829
> 0.025562	 -0.083877	 -0.001857
> 0.026100	 -0.083877	 0.000090
> 0.025965	 -0.083877	 0.002574
>
> and the code as follow:
>
> pp <- scan("bmn007.data", quiet= TRUE)
> x <- matrix(pp, nc=2, byrow=TRUE)
> fit <- principal.curve(x, plot = TRUE)
> points(fit,col="red")
>
> By now, I got a right result.
> But when i changed to use pcurve with matrix x as "pcurve(x)",
> an error was thrown as following:
>
> Estimating starting configuration using : CA
> Error in h %*% diag(sqrt(d)) : non-conformable arguments
>
> How to convert a matrix to the format could be accepted by "pcurve"?
> Any help appreciated!
>
Sun,

The canonical answer is "ask De'ath" (the author of the package). The 
rest is guessing. It seems that pcurve uses correspondence analysis 
("CA") to estimate the starting configuration. CA doesn't handle cases 
where any of the marginal sums (row or column sums) are negative or 
zero. Do you have this kind of cases? If so, can you get rid of them? 
Does pcurve have another option than CA for getting the starting 
configuration?

cheers, jari oksanen
--
Jari Oksanen, Oulu, Finland




More information about the R-help mailing list