[R] qda(MASS) function error
Dear R user, I'm using qda (quadratic discriminant analysis) function (package MASS) to classify 58 explanatory variables (numeric type with different ranges) using a grouping variable (factor 2 levels 0 1). I'm using the qda method for class 'data.frame' (in this way I don't need to specify a formula). Using the function: result.qda-qda(explanatory.variables, grouping.variable, method=moment) I obtain the following error message: Error in qda.default(x, grouping, ...) : rank deficiency in group 0 I run the script excluding some variables and I've individuated 2 explanatory variables that give problems, but I don't understand why they give them. The two excluded variables are numeric with two possible values: 0 and 1, but in the rest of group of variables, some similar variables are considered. I don't have this problem using lda function for linear discriminant analysis. What does this error message mean? What types of variables does qda function consider? Thank in advance, Mauro Rossi -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel. +39 075 5014421 Fax +39 075 5014420 __ R-help@stat.math.ethz.ch 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] Zeta and Zipf distribution
Thank you David, I've followed you example and I found the parameters I need. I also write a script using zetaff distribution and also this works well. Thank you again, Mauro David Barron ha scritto: I don't claim to be a huge expert on this, but I think you are mistaken about what you are getting when you use the zipf family with the vglm function. From what I can tell from the documentation, this does indeed give you an estimate of the parameter of the zipf distribution. I've tried to test this using some random numbers (probably not strictly correct procedure, but I think it's a reasonable approximation): set.seed(1234) N - 5 y - (1:N) alpha - 2.5 # this is the parameter of the zipf distribution p - 1/(y^alpha) ; p - p/sum(p) n - 10 x - sample (y, n, replace=TRUE, prob=p) w - as.vector(table(x)) fit = vglm (y ~ 1, zipf(link=identity, init=2), tra=TRUE, weight=w) Coef(fit) s 2.501086 Is this not what you need? On 08/02/07, Mauro Rossi [EMAIL PROTECTED] wrote: Dear David, thank you for your reply. I tried to use the package VGAM, the function zipf and also the function zetaff, but these functions don't allow me to estimate parameters directly, I have to use a Gerneralized Linear Model or a Generalized Additive Model (vgam or vglm functions) and I don't want to use those. Don't you know a way to apply these tools to my data? At the end my PMF has to be Y=f(X) where f(X) is a zeta or a zipf distribution, while using VGAM the PMF is Y = b0 + b1*f(X1)+ ... +bn*f(Xn). Do you know how I can write the script using the VGAM function for the PMF I need? Thank you in advance, Mauro Rossi David Barron ha scritto: Does the zipf function in the VGAM package do what you want? On 08/02/07, *Mauro Rossi* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Dear R user, I want to estimate the parameter of ZETA or/and ZIPF distributions using R, given a series of integer values. Do you know a package (similar to MASS) or a function (similar to fitdistr) I can use to estimate the parameter of these distributions using MLE method? Otherwise do you know a function (which use MLE method to estimate distribution parameters) that allow me to specify a PDF or PMF? Thanks, Regards Mauro Rossi -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel. +39 075 5014421 Fax +39 075 5014420 __ R-help@stat.math.ethz.ch mailto:R-help@stat.math.ethz.ch mailing list 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. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel. +39 075 5014421 Fax +39 075 5014420 -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel. +39 075 5014421 Fax +39 075 5014420 __ R-help@stat.math.ethz.ch 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] Zeta and Zipf distribution
Dear R user, I want to estimate the parameter of ZETA or/and ZIPF distributions using R, given a series of integer values. Do you know a package (similar to MASS) or a function (similar to fitdistr) I can use to estimate the parameter of these distributions using MLE method? Otherwise do you know a function (which use MLE method to estimate distribution parameters) that allow me to specify a PDF or PMF? Thanks, Regards Mauro Rossi -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel. +39 075 5014421 Fax +39 075 5014420 __ R-help@stat.math.ethz.ch 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] Zeta and Zipf distribution
Dear David, thank you for your reply. I tried to use the package VGAM, the function zipf and also the function zetaff, but these functions don't allow me to estimate parameters directly, I have to use a Gerneralized Linear Model or a Generalized Additive Model (vgam or vglm functions) and I don't want to use those. Don't you know a way to apply these tools to my data? At the end my PMF has to be Y=f(X) where f(X) is a zeta or a zipf distribution, while using VGAM the PMF is Y = b0 + b1*f(X1)+ ... +bn*f(Xn). Do you know how I can write the script using the VGAM function for the PMF I need? Thank you in advance, Mauro Rossi David Barron ha scritto: Does the zipf function in the VGAM package do what you want? On 08/02/07, *Mauro Rossi* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Dear R user, I want to estimate the parameter of ZETA or/and ZIPF distributions using R, given a series of integer values. Do you know a package (similar to MASS) or a function (similar to fitdistr) I can use to estimate the parameter of these distributions using MLE method? Otherwise do you know a function (which use MLE method to estimate distribution parameters) that allow me to specify a PDF or PMF? Thanks, Regards Mauro Rossi -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel. +39 075 5014421 Fax +39 075 5014420 __ R-help@stat.math.ethz.ch mailto:R-help@stat.math.ethz.ch mailing list 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. -- = David Barron Said Business School University of Oxford Park End Street Oxford OX1 1HP -- Mauro Rossi Istituto di Ricerca per la Protezione Idrogeologica Consiglio Nazionale delle Ricerche Via della Madonna Alta, 126 06128 Perugia Italia Tel. +39 075 5014421 Fax +39 075 5014420 __ R-help@stat.math.ethz.ch 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.