Yes, I am using the MASS qda... How do I know which version is my MASS? I
should be using the latest one, since I constantly update my packages from
mirror site USA CA1.
Very weird!!!
-------------------------------
Here is my code:
rm(list=ls(all=TRUE))
library(MASS);
temp=as.matrix(read.table('spam.train'));
temp2=as.matrix(read.table('spam.test'));
#QDA Priors (0.5, 0.5)
lll <- qda((temp[, -58]), as.factor(temp[, 58]), prior=c(0.2, 0.8));
print('Priors (0.2, 0.8) QDA: Training ... ');
ttt=predict(lll, temp[, -58])$class;
cc1=table(temp[, 58], ttt);
print(cc1);
dd1=cc1 %*% matrix(1, 2, 1);
ee1=cc1 / as.vector(dd1);
print(ee1);
print('Priors (0.2, 0.8) QDA: Testing ... ');
ttt=predict(lll, temp2[, -58])$class;
cc2=table(temp2[, 58], ttt);
print(cc2);
dd2=cc2 %*% matrix(1, 2, 1);
ee2=cc2 / as.vector(dd2);
print(ee2);
#QDA Proportional Priors
lll <- qda((temp[, -58]), as.factor(temp[, 58]));
print('Proportional Priors QDA: Training ... ');
ttt=predict(lll, temp[, -58])$class;
cc1=table(temp[, 58], ttt);
print(cc1);
dd1=cc1 %*% matrix(1, 2, 1);
ee1=cc1 / as.vector(dd1);
print(ee1);
print('Proportional Priors QDA: Testing ... ');
ttt=predict(lll, temp2[, -58])$class;
cc2=table(temp2[, 58], ttt);
print(cc2);
dd2=cc2 %*% matrix(1, 2, 1);
ee2=cc2 / as.vector(dd2);
print(ee2);
--------------------------------------------------
Here is the result:
[1] "Priors (0.2, 0.8) QDA: Training ... "
0 1
0 1051 355
1 40 855
0 1
0 0.74751067 0.25248933
1 0.04469274 0.95530726
[1] "Priors (0.2, 0.8) QDA: Testing ... "
0 1
0 993 389
1 47 871
0 1
0 0.71852388 0.28147612
1 0.05119826 0.94880174
[1] "Proportional Priors QDA: Training ... "
0 1
0 1058 348
1 41 854
0 1
0 0.75248933 0.24751067
1 0.04581006 0.95418994
[1] "Proportional Priors QDA: Testing ... "
0 1
0 999 383
1 47 871
0 1
0 0.72286541 0.27713459
1 0.05119826 0.94880174
On 3/11/06, Uwe Ligges <[EMAIL PROTECTED]> wrote:
>
> Michael wrote:
>
> > Hi all,
> >
> > If I run LDA on the same data (2-class classification) with default(no
> > priors specified in the lda function) vs. "prior=c(0.5, 0.5)", the
> results
> > are different.
> >
> > The (0.5, 0.5) priors give better 1-classify-to-1 rate, and the
> proportional
> > priors(default, no priors specified in the lda function) give better
> > 0-classify-to-0 rate, for both training and testing data sets.
> >
> > However, if I run QDA on the same data (2-class classification) with
> > default(no priors specified in the lda function) vs. "prior=c(0.5, 0.5
> )",
> > the results are the same,
> >
> > i.e. the confusion tables are completely the same for two types of
> priors, I
> > even tried "qda" function with "prior=c(0.3, 0.7)" and other values, the
> > confusion tables are still the same...
> >
> > What might be the problem?
>
>
> Are we talking about the lda() and qda() implementations in package MASS?
> Which versions of R and MASS (?) are we talking about?
> Can you specify a reproducible example, please?
>
> The follwing example works for me:
> library(MASS)
> qdaObj <- qda(Species ~ ., data = iris, prior = c(1, 0, 0))
> predict(qdaObj)$class
>
> Uwe Ligges
>
>
>
>
> > Thanks a lot!
> >
> > [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > [email protected] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html