You might try something like
do.can <- candisc(do.mod, data=do)
plot(do.can)
But, in your example there is only one canonical dimension there are
only two levels of the
factor.
In any case, do.can$scores has the scores, so you can try to plot them
however you like.
For a 1-D plot in a case where it makes more sense, try
iris.mod <- lm(cbind(Petal.Length, Sepal.Length, Petal.Width,
Sepal.Width) ~ Species, data=iris)
iris.can <- candisc(iris.mod, data=iris, ndim=1)
plot(iris.can)
-Michael
Pete Shepard wrote:
Dear Michael,
You haven't told us what your data is, and we can only surmise -- not
very helpful for you and annoying for those who try to help.
Apologies, I am brand new to R and this mailing list. Will try to be
more concise.
Here is my data a NEW verion of my data:
Curvature Diameter Quality
1 2.95 6.63 Passed
2 2.53 7.79 Passed
3 3.57 5.65 Passed
4 3.16 5.47 Passed
5 2.58 4.46 NotPassed
6 2.16 6.22 NotPassed
7 3.27 3.52 NotPassed
What I am trying to get from the candisc method is a 1 dimensional
scatterplot that separates my two groups Passed and NotPassed
On this data I do a "do.mod <- lm(cbind(Diameter, Curvature) ~
Quality, data=do)"
>do.mod produces
Coefficients:
Diameter Curvature
(Intercept) 4.7333 2.6700
QualityPassed 1.6517 0.3825
I then run the "candisc" method: "do.can <- candisc(do.mod, data=do)"
this produces:
Canonical Discriminant Analysis for Quality:
CanRsq Eigenvalue Difference Percent Cumulative
1 0.91354 10.566 100 100
Test of H0: The canonical correlations in the
current row and all that follow are zero
LR test stat approx F num Df den Df Pr(> F)
1 0.086 52.831 1 5 0.0007706 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
What "I think" I would like to plot is the discriminant function of
each sample 1-7.
Here is an example of what I am trying to do with candisc.
http://people.revoledu.com/kardi/tutorial/LDA/Numerical%20Example.html
Thanks
On Thu, Dec 11, 2008 at 3:36 PM, Michael Friendly <frien...@yorku.ca
<mailto:frien...@yorku.ca>> wrote:
Dear Pete,
You haven't told us what your data is, and we can only surmise --
not very helpful for you and annoying for those who try to help.
Pete Shepard wrote:
Hello,
I have a file with two dependent variables (three and five)
and one
independent variable. I do i.mod <- lm(cbind(three, five) ~
species,
data=i.txt) and get the following output:
Coefficients:
three five
(Intercept) 9.949 9.586
species -1.166 -1.156
From this, it seems that species is numeric variable, not a factor.
If so, canonical discriminant analysis in not appropriate, so
all following bets are off.
That's likely why you end up with only one canonical dimension.
I do a" i.can<-candisc(i.mod,data=i):
Is data=i the same as data=i.txt?
and get the following output:
Canonical Discriminant Analysis for species:
CanRsq Eigenvalue Difference Percent Cumulative
1 0.096506 0.10681 100 100
Test of H0: The canonical correlations in the
current row and all that follow are zero
LR test stat approx F num Df den Df Pr(> F)
1 0.903 63.875 1 598 6.859e-15 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
this is different than the output I get with SAS:
What was your SAS code? Was the data the same?
Eigenvalue Difference Proportion Cumulative Ratio
F Value
Num DF Den DF Pr > F
1 0.1068 1.0000 1.0000 0.90349416
31.88 2 597 <.0001
I am also wondering how to plot the can1*can1 like it is done
in SAS.
proc plot;
plot can1*can1=species;
format species spechar.;
title2 'Plot of Constits_vs_cassettes';
run;
If you want to compare plots for canonical analysis in SAS and R,
see my macros, canplot and hecan at
http://www.math.yorku.ca/SCS/sasmac/
But in general, if all you have is 1 canonical dimension, a dotplot or
boxplot of the canonical scores would be more useful than a
scatterplot plot of can1 * can1.
The plot method for candisc objects in the candisc package has some
code to handle the 1 can-D case.
hope this helps
-Michael
Thanks
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org <mailto: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.
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT M3J 1P3 CANADA
--
Michael Friendly Email: frien...@yorku.ca
Professor, Psychology Dept.
York University Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT M3J 1P3 CANADA
______________________________________________
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.