[R] Help with dudi.pca

Mark Difford mark_difford at yahoo.co.uk
Sat Jan 24 08:53:44 CET 2009


Hi Michael,

>>  > coinertia(op.dudi, em3.dudi) 
>>     Error in paste("COCA", 1:n.axes, sep = " ") : element 2 is empty;

Something makes me think that this is not the full error message, or the
correct error message, or that you have something else in your call to
coinertia?

Why? Because you also list this:

 > coinertia(op.dudi, em3.dudi, n.axes = 2)
Error in sqrt(Dp) : Non-numeric argument to mathematical function

Fact is, coinertia does not accept "n.axes" as an argument, it uses "nf ="
to specify the number of axes.

The function paste(), which is generating the error message, is used in
coinertia(). All I can say from what you have given is do it again with a
clean environment, and make sure that you are using the correct arguments to
coinertia.

Are you able to debug? If not send me your data and I will fix/find the
problem.

Regards, Mark.


Michael Kubovy wrote:
> 
> Dear R-helpers,
> 
> I have two data frames, op and em4:
>  > str(op)
> 'data.frame':	37 obs. of  5 variables:
>   $ m    : num  0.202 0.336 0.122 0.139 0.14 ...
>   $ lln  : num  0.798 0.643 0.863 0.835 0.823 ...
>   $ rrn  : num  0.789 0.702 0.894 0.895 0.923 ...
>   $ asym2: num  0.177 0.304 0.108 0.187 0.274 ...
>   $ asym3: num  0.0755 0.0975 0.0818 0.0651 0.13 ...
>  > str(rownames(op))
>   chr [1:37] "abov-belw" "ampl-rstr" "angl-rndd" "ascn-dscn" ...
> 
>  > str(em3)
> 'data.frame':	37 obs. of  9 variables:
>   $ B--: int  4 1 12 14 0 3 2 15 3 5 ...
>   $ P--: int  4 1 2 3 5 15 1 0 3 1 ...
>   $ U--: int  10 16 4 1 13 0 15 3 12 12 ...
>   $ --B: int  5 13 10 15 6 1 5 16 5 8 ...
>   $ --P: int  6 2 5 2 12 16 5 0 13 10 ...
>   $ --U: int  7 3 3 1 0 1 8 2 0 0 ...
>   $ -N-: int  0 2 11 0 17 0 1 0 14 3 ...
>   $ -P-: int  15 0 2 16 0 2 2 16 0 0 ...
>   $ -R-: int  3 16 5 2 1 16 15 2 4 15 ...
>  > str(rownames(em3))
>   chr [1:37] "abov-belw" "ampl-rstr" "angl-rndd" "ascn-dscn" "asym- 
> symm" "end-bgnn" ...
> 
> Thus the 37 rownames in both are the same.
> 
> Now I do a pca of op:
>  > (op.dudi <- dudi.pca(op, scale = F, scan = F))
> Duality diagramm
> class: pca dudi
> $call: dudi.pca(df = op, scale = F, scannf = F)
> 
> $nf: 2 axis-components saved
> $rank: 5
> eigen values: 0.09233 0.03109 0.01322 0.002024 0.0001017
>    vector length mode    content
> 1 $cw    5      numeric column weights
> 2 $lw    37     numeric row weights
> 3 $eig   5      numeric eigen values
> 
>    data.frame nrow ncol content
> 1 $tab       37   5    modified array
> 2 $li        37   2    row coordinates
> 3 $l1        37   2    row normed scores
> 4 $co        5    2    column coordinates
> 5 $c1        5    2    column normed scores
> other elements: cent norm
> 
> and of em3
>  > (em3.dudi <- dudi.pca(em3, scale = F, scan = F))
> Duality diagramm
> class: pca dudi
> $call: dudi.pca(df = em3, scale = F, scannf = F)
> 
> $nf: 2 axis-components saved
> $rank: 6
> eigen values: 105.5 80.73 55.08 24.06 8.83 ...
>    vector length mode    content
> 1 $cw    9      numeric column weights
> 2 $lw    37     numeric row weights
> 3 $eig   6      numeric eigen values
> 
>    data.frame nrow ncol content
> 1 $tab       37   9    modified array
> 2 $li        37   2    row coordinates
> 3 $l1        37   2    row normed scores
> 4 $co        9    2    column coordinates
> 5 $c1        9    2    column normed scores
> other elements: cent norm
> 
> 
> I would like to do a coinertia analysis between the two results.
> 
>  > coinertia(op.dudi, em3.dudi)
> Error in paste("COCA", 1:n.axes, sep = " ") : element 2 is empty;
>     the part of the args list of ':' being evaluated was:
>     (1, n.axes)
>  > coinertia(op.dudi, em3.dudi, n.axes = 2)
> Error in sqrt(Dp) : Non-numeric argument to mathematical function
> 
> Can anyone tell me why the coinertia fails, and how to fix it? I would  
> be happy to send the two data files, if you were willing to help.
> 
> Thanks,
> 
> MK
> _____________________________
> Professor Michael Kubovy
> University of Virginia
> Department of Psychology
> Postal Address:
> 	P.O.Box 400400, Charlottesville, VA 22904-4400
> Express Parcels Address:
> 	Gilmer Hall, Room 102, McCormick Road, Charlottesville, VA 22903
> Office:    B011;		Phone: +1-434-982-4729
> Lab:        B019;		Phone: +1-434-982-4751
> WWW:    http://www.people.virginia.edu/~mk9y/
> Skype name: polyurinsane
> 
> 
> 
> 
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Help-with-dudi.pca-tp21637152p21638090.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list