Re: [R] discriminant analysis lda under MASS
Thank you for your answer. Please let me provide additional information: You have a pooled variance covariance matrix S (2x2). The matrix needs to be inverted: S^-1. The calculation of the coeffcients is done by S^-1 (average (x1) - average (x2)). average (x1) is the vector of means (2x1) in group 1, average (x2) is the vector of means (2x1) in group 2. S is as follows [1,1]: 2267168.12; [1,2]: 49088.07 [2,2]: 8381.77 average (x1) is as follows [1,1]: 3510.4; [2,1]: 390.2 average (x2) is as follows [1,1]: 7975.2; [2,1]: 577.5 Means that having the above mentioned formula in mind it is very easy to calculate. However, my problem is, that I am not able to find any way to get this result by using R. Or in another way: What estimates R and is there any possibility to link the both results? Thanks. Gesendet: Donnerstag, 03. März 2016 um 15:08 Uhr Von: "David L Carlson" An: "Jens Koch" , "r-help@r-project.org" Betreff: RE: [R] discriminant analysis lda under MASS If the textbook provides the equations, you can work through them directly. But without knowing more, it is hard to say. You could also contact the author of the textbook. - David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jens Koch Sent: Wednesday, March 2, 2016 9:19 AM To: r-help@r-project.org Subject: [R] discriminant analysis lda under MASS Hello all, I'd like to run a simple discriminant analysis to jump into the topic with the following dataset provided by a textbook: Gruppe Einwohner Kosten 1 1642 478,2 1 2418 247,3 1 1417 223,6 1 2761 505,6 1 3991 399,3 1 2500 276 1 6261 542,5 1 3260 308,9 1 2516 453,6 1 4451 430,2 1 3504 413,8 1 5431 379,7 1 3523 400,5 1 5471 404,1 2 7172 499,4 2 9419 674,9 2 8780 468,6 2 5070 601,5 2 5780 578,8 2 8630 641,5 The coefficients according to the textbook need to be -0.00170 and -0.01237. If I put the data into the lda function under MASS, my result is: Call: lda(Gruppe ~ Einwohner + Kosten, data = data) Prior probabilities of groups: 1 2 0.7 0.3 Group means: Einwohner Kosten 1 3510.429 390.2357 2 7475.167 577.4500 Coefficients of linear discriminants: LD1 Einwohner 0.0004751092 Kosten 0.0050994964 I also tried to solve it by an another software package, but there is also not the result I have expected. I know now, that the solution for the coefficients is standardized by R and the discrimination power is not different at the end of the day. But: How can I get (calculate) the results printed in the textbook with R? Thanks in advance, Jens. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html[http://www.R-project.org/posting-guide.html] and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] discriminant analysis lda under MASS
If the textbook provides the equations, you can work through them directly. But without knowing more, it is hard to say. You could also contact the author of the textbook. - David L Carlson Department of Anthropology Texas A&M University College Station, TX 77840-4352 -Original Message- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Jens Koch Sent: Wednesday, March 2, 2016 9:19 AM To: r-help@r-project.org Subject: [R] discriminant analysis lda under MASS Hello all, I'd like to run a simple discriminant analysis to jump into the topic with the following dataset provided by a textbook: Gruppe Einwohner Kosten 1 1642 478,2 1 2418 247,3 1 1417 223,6 1 2761 505,6 1 3991 399,3 1 2500 276 1 6261 542,5 1 3260 308,9 1 2516 453,6 1 4451 430,2 1 3504 413,8 1 5431 379,7 1 3523 400,5 1 5471 404,1 2 7172 499,4 2 9419 674,9 2 8780 468,6 2 5070 601,5 2 5780 578,8 2 8630 641,5 The coefficients according to the textbook need to be -0.00170 and -0.01237. If I put the data into the lda function under MASS, my result is: Call: lda(Gruppe ~ Einwohner + Kosten, data = data) Prior probabilities of groups: 1 2 0.7 0.3 Group means: Einwohner Kosten 1 3510.429 390.2357 2 7475.167 577.4500 Coefficients of linear discriminants: LD1 Einwohner 0.0004751092 Kosten 0.0050994964 I also tried to solve it by an another software package, but there is also not the result I have expected. I know now, that the solution for the coefficients is standardized by R and the discrimination power is not different at the end of the day. But: How can I get (calculate) the results printed in the textbook with R? Thanks in advance, Jens. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] discriminant analysis lda under MASS
Hello all, I'd like to run a simple discriminant analysis to jump into the topic with the following dataset provided by a textbook: Gruppe Einwohner Kosten 1 1642 478,2 1 2418 247,3 1 1417 223,6 1 2761 505,6 1 3991 399,3 1 2500 276 1 6261 542,5 1 3260 308,9 1 2516 453,6 1 4451 430,2 1 3504 413,8 1 5431 379,7 1 3523 400,5 1 5471 404,1 2 7172 499,4 2 9419 674,9 2 8780 468,6 2 5070 601,5 2 5780 578,8 2 8630 641,5 The coefficients according to the textbook need to be -0.00170 and -0.01237. If I put the data into the lda function under MASS, my result is: Call: lda(Gruppe ~ Einwohner + Kosten, data = data) Prior probabilities of groups: 1 2 0.7 0.3 Group means: Einwohner Kosten 1 3510.429 390.2357 2 7475.167 577.4500 Coefficients of linear discriminants: LD1 Einwohner 0.0004751092 Kosten 0.0050994964 I also tried to solve it by an another software package, but there is also not the result I have expected. I know now, that the solution for the coefficients is standardized by R and the discrimination power is not different at the end of the day. But: How can I get (calculate) the results printed in the textbook with R? Thanks in advance, Jens. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] discriminant analysis
There is a good tutorial here: http://www.statsoft.com/textbook/discriminant-function-analysis/ I doubt your question is appropriate for this list ... good luck! David Cross d.cr...@tcu.edu www.davidcross.us On May 8, 2011, at 7:28 PM, Sylvia Rocha wrote: > I am a student of ecology from Brazil and I need a tutorial on discriminant > analysis, can someone help me? > > sylvia > > [[alternative HTML version deleted]] > > __ > 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. __ 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.
[R] discriminant analysis
I am a student of ecology from Brazil and I need a tutorial on discriminant analysis, can someone help me? sylvia [[alternative HTML version deleted]] __ 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.
Re: [R] Discriminant analysis
Please do not double post. See my answer to your other message from today. Uwe Ligges On 30.12.2010 14:31, Yemi Oyeyemi wrote: Dear R-helpers I am having problem or reservation analyzing my data using discrminant analysis. The problem is that all my dependent variables are categorical which means that the normalty assumption is no longer valid. Can one still use discrminant analysis for such data? Is there non-parametric technique of doing discrminant analysis in R. Thanks OYEYEMI, Gafar Matanmi Department of Statistics University of Ilorin P.M.B 1515 Ilorin, Kwara State Nigeria Tel: +2348052278655 Tel: +2348068241885 [[alternative HTML version deleted]] __ 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. __ 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.
[R] Discriminant analysis
Dear R-helpers I am having problem or reservation analyzing my data using discrminant analysis. The problem is that all my dependent variables are categorical which means that the normalty assumption is no longer valid. Can one still use discrminant analysis for such data? Is there non-parametric technique of doing discrminant analysis in R. Thanks OYEYEMI, Gafar Matanmi Department of Statistics University of Ilorin P.M.B 1515 Ilorin, Kwara State Nigeria Tel: +2348052278655 Tel: +2348068241885 [[alternative HTML version deleted]] __ 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.
Re: [R] discriminant analysis
Which kind of discriminant analysis? If you mean LDA, use lda() in package MASS and read the correpsonding book "Modern Applied Statistics with S" by Venables and Ripley published by Springer. Uwe Ligges On 01.06.2010 09:24, suman dhara wrote: Sir, Can you suggest some function for discriminant analysis for Binary response having continuous as well as categorical regressors. Thanks, Suman Dhara [[alternative HTML version deleted]] __ 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. __ 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.
[R] discriminant analysis
Sir, Can you suggest some function for discriminant analysis for Binary response having continuous as well as categorical regressors. Thanks, Suman Dhara [[alternative HTML version deleted]] __ 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.
Re: [R] discriminant analysis
Beatriz Yannicelli wrote: Dear all: Is it possible to conduct a discriminant analysis in R with categorical and continuous variables as predictors? Beatriz Beatriz, Simply doing this in the R console: RSiteSearch("discriminant") yields many promising links. In particular, check documentation of package mda. HTH Rubén __ 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.
[R] discriminant analysis
Dear all: Is it possible to conduct a discriminant analysis in R with categorical and continuous variables as predictors? Beatriz [[alternative HTML version deleted]] __ 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.
[R] Discriminant Analysis Ellipse
Hi listers, I am working on a program in order to create an ellipse as a limit of my observations there are well classified. I have two independent variables for an quadratic discriminant function between 2 groups where my mean is zero and my covariance matrix is proportional. Q=y'Ay+c My program follows below with unreal data... My ellipse it's not surrounding the correct number of classified observations... I am getting more misclassification than I should... ellipse<-function(mu,sigma){ p<-2 priori1<-.55 priori2<-.45 gamma<-3 spectral<-eigen(sigma,symmetric=T) value<-spectral$values vector<-spectral$vectors angle<-seq(0,2*pi,length=100) c<-log(priori1/priori2)+(p/2)*log(gamma) #gamma=proportional constant y<-c*rbind(sqrt(value[1])*cos(angle),sqrt(value[2])*sin(angle)) t(mu+(vector%*%y)) } mu=c(0,0) sigma=matrix(c(6,2,2,7),nrow=2,ncol=2,byrow=TRUE) x=ellipse(mu,sigma) par(pty="s") plot(x[,1],x[,2],xlab="y1",ylab="y2",type="l",main="Graphic",xlim=c(-10,10),ylim=c(-10,10)) data<-cbind(c(1,2,4,6),c(1,3,5,4)) points(data[,1],data[,2],pch="+") Thanks in advance, Marcio -- View this message in context: http://www.nabble.com/Discriminant-Analysis-Ellipse-tp22978984p22978984.html Sent from the R help mailing list archive at Nabble.com. __ 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.
[R] Discriminant analysis - posterior prob
Hi listers, I have a statistical question corcerning the posteriori probability of a discriminant analysis. I am calculating the probabilities under R using the formula. posteriori_j=exp(q_j(y))/sum(q_j(y)) qj(y) is my quadratic discriminant function for the case where my covariance matrix are proportional with y=(y1,y2) et j=1,2 groups My doubt is how I could calculate this ratio when my dimension (number of observations) is different for each j group. Thanks in advance, Marcio -- View this message in context: http://www.nabble.com/Discriminant-analysis---posterior-prob-tp22874222p22874222.html Sent from the R help mailing list archive at Nabble.com. __ 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.
Re: [R] Discriminant Analysis - Obtaining Classification Functions
reauire(MASS) ; ?predict.lda should enlighten you. Glancing at V&R4 might be a bit more illuminating... HTH Emmanuel Charpentier Le vendredi 03 avril 2009 à 22:29 +0200, Pavel Kúr a écrit : > Hello! > > I need some help with the linear discriminant analysis in R. > I have some plant samples (divided into several groups) on which I > measured a few quantitative characteristics. Now, I need to infer some > classification rules usable for identifying new samples. > I have used the function lda from the MASS library in a usual fashion: > > lda.1 <- lda(groups~char1+char2+char3, data=xxx) > > I'd like to obtain the classification functions for the particular > groups, with the aid of which I could classify unknown samples. I know > I can use predict.lda to classify such samples, but I need to obtain > some equations into which I could simply put the measured values of an > unknown sample manually and the result would predict which group the > sample most probably belongs to (like in eg. STATISTICA). > I haven't found out how to extract these functions from the lda output. > Could somebody give me some advice? > > Thank you in advance, > > Pavel Kur > > __ > 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. > __ 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.
[R] Discriminant Analysis - Obtaining Classification Functions
Hello! I need some help with the linear discriminant analysis in R. I have some plant samples (divided into several groups) on which I measured a few quantitative characteristics. Now, I need to infer some classification rules usable for identifying new samples. I have used the function lda from the MASS library in a usual fashion: lda.1 <- lda(groups~char1+char2+char3, data=xxx) I'd like to obtain the classification functions for the particular groups, with the aid of which I could classify unknown samples. I know I can use predict.lda to classify such samples, but I need to obtain some equations into which I could simply put the measured values of an unknown sample manually and the result would predict which group the sample most probably belongs to (like in eg. STATISTICA). I haven't found out how to extract these functions from the lda output. Could somebody give me some advice? Thank you in advance, Pavel Kur __ 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.
Re: [R] Discriminant analysis - stepwise procedure
Jose Antonio wrote: Dear R users, I have some environmental variables and I need to find the best combination of them in order to separate two main groups (coded 1 and 2). I have performed a discriminant analysis using the stepclass function as a method for selecting the most relevant environmental variables. The problem is that this function includes a parameter (start.vars) and my results change a lot when I change this variable...Oh my God!!! Then, one possible functionl is not the best for my data... grupo<-stepclass(GROUP~W1+W2+W3+W4+W5+W6+W7+W8+W9+W10, data=BD, method="lda", start.vars = "W1", criterion = "AS", direction = "forward") > I have performed a redundancy analysis first, then there is not highly correlated variables in the variables that I include in the stepclass function. Can anybody help me??? Not sure if you really want criterion = "AS". Anyway, if your variables are almost equally good (or bad) to improve the criterion and you have not very much data, then it might happen that the criterion works equally well for different variables and the one that is first on your list gets selected first (we do not break "ties"). And hence, after a different variable is selected at first, this influences the variables chosen in the second step. Hence it is not that surprising what you observed. Uwe Ligges Thank you very much [[alternative HTML version deleted]] __ 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. __ 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.
[R] Discriminant analysis - stepwise procedure
Dear R users, I have some environmental variables and I need to find the best combination of them in order to separate two main groups (coded 1 and 2). I have performed a discriminant analysis using the stepclass function as a method for selecting the most relevant environmental variables. The problem is that this function includes a parameter (start.vars) and my results change a lot when I change this variable...Oh my God!!! Then, one possible functionl is not the best for my data... grupo<-stepclass(GROUP~W1+W2+W3+W4+W5+W6+W7+W8+W9+W10, data=BD, method="lda", start.vars = "W1", criterion = "AS", direction = "forward") I have performed a redundancy analysis first, then there is not highly correlated variables in the variables that I include in the stepclass function. Can anybody help me??? Thank you very much [[alternative HTML version deleted]] __ 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.