Dear all, I get an error message when I use polr() in MASS. These are my data: skugg grupp frekv 4 1 gr3 0 5 2 gr3 3 6 3 gr3 6 10 1 gr5 1 11 2 gr5 12 12 3 gr5 1> > summary(polr(skugg ~ grupp, weights=frekv, data= skugg.cpy1.dat))Error in optim(start, fmin, gmin, method = "BFGS", hessian = Hess, ...) : non-finite value supplied by optim Does this depend on the very few observations in skugg 1 - the proportional-odds assumption doesn't hold (p 231, MASS 3ed)? If so, I would be happy for a recommendation on another approach. And I also have a similar data set where only the skugg classes 2 and 3 are observed. Would you recommend glm, family= binomial for that analysis? I use R 1.6.2, MASS 7.0-10, Win 2000. Thanks in advance! Please reply also to me because I'm on the once a day-list Sincerely, Tord ----------------------------------------------------------------------- Tord Sn?ll Avd. f v?xtekologi, Evolutionsbiologiskt centrum, Uppsala universitet Dept. of Plant Ecology, Evolutionary Biology Centre, Uppsala University Villav?gen 14 SE-752 36 Uppsala, Sweden Tel: 018-471 28 82 (int +46 18 471 28 82) (work) Tel: 018-25 71 33 (int +46 18 25 71 33) (home) Fax: 018-55 34 19 (int +46 18 55 34 19) (work) E-mail: Tord.Snall at ebc.uu.se Check this: http://www.vaxtbio.uu.se/resfold/snall.htm! ------------------------------------------------------------------------
On 22 Jan 2003 at 9:56, Tord Snall wrote: You can also try the nordr() function in Jim Lindsay's package gnlm. Kjetil Halvorsen> Dear all, > > I get an error message when I use polr() in MASS. These are my data: > > skugg grupp frekv > 4 1 gr3 0 > 5 2 gr3 3 > 6 3 gr3 6 > 10 1 gr5 1 > 11 2 gr5 12 > 12 3 gr5 1 > > > > summary(polr(skugg ~ grupp, weights=frekv, data= skugg.cpy1.dat)) > Error in optim(start, fmin, gmin, method = "BFGS", hessian = Hess, ...) : > non-finite value supplied by optim > > Does this depend on the very few observations in skugg 1 - the > proportional-odds assumption doesn't hold (p 231, MASS 3ed)? If so, I would > be happy for a recommendation on another approach. > > And I also have a similar data set where only the skugg classes 2 and 3 are > observed. Would you recommend glm, family= binomial for that analysis? > > I use R 1.6.2, MASS 7.0-10, Win 2000. > > > Thanks in advance! > > Please reply also to me because I'm on the once a day-list > > > Sincerely, > Tord > > ----------------------------------------------------------------------- > Tord Sn?ll > Avd. f v?xtekologi, Evolutionsbiologiskt centrum, Uppsala universitet > Dept. of Plant Ecology, Evolutionary Biology Centre, Uppsala University > Villav?gen 14 > SE-752 36 Uppsala, Sweden > Tel: 018-471 28 82 (int +46 18 471 28 82) (work) > Tel: 018-25 71 33 (int +46 18 25 71 33) (home) > Fax: 018-55 34 19 (int +46 18 55 34 19) (work) > E-mail: Tord.Snall at ebc.uu.se > Check this: http://www.vaxtbio.uu.se/resfold/snall.htm! > ------------------------------------------------------------------------ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help
That example works here (once I make skugg an ordered factor): Call: polr(formula = skugg ~ grupp, data = dat, weights = frekv) Coefficients: Value Std. Error t value -3.287802 1.252344 -2.625318 Intercepts: Value Std. Error t value 1|2 -5.8783 1.5565 -3.7765 2|3 -0.6973 0.7062 -0.9875 Residual Deviance: 25.76504 AIC: 31.76504 BTW, there is no point in including points with zero weight. On Wed, 22 Jan 2003, Tord Snall wrote:> Dear all, > > I get an error message when I use polr() in MASS. These are my data: > > skugg grupp frekv > 4 1 gr3 0 > 5 2 gr3 3 > 6 3 gr3 6 > 10 1 gr5 1 > 11 2 gr5 12 > 12 3 gr5 1 > > > > summary(polr(skugg ~ grupp, weights=frekv, data= skugg.cpy1.dat)) > Error in optim(start, fmin, gmin, method = "BFGS", hessian = Hess, ...) : > non-finite value supplied by optim > > Does this depend on the very few observations in skugg 1 - the > proportional-odds assumption doesn't hold (p 231, MASS 3ed)? If so, I would > be happy for a recommendation on another approach. > > And I also have a similar data set where only the skugg classes 2 and 3 are > observed. Would you recommend glm, family= binomial for that analysis? > > I use R 1.6.2, MASS 7.0-10, Win 2000. > > > Thanks in advance! > > Please reply also to me because I'm on the once a day-list > > > Sincerely, > Tord > > ----------------------------------------------------------------------- > Tord Sn?ll > Avd. f v?xtekologi, Evolutionsbiologiskt centrum, Uppsala universitet > Dept. of Plant Ecology, Evolutionary Biology Centre, Uppsala University > Villav?gen 14 > SE-752 36 Uppsala, Sweden > Tel: 018-471 28 82 (int +46 18 471 28 82) (work) > Tel: 018-25 71 33 (int +46 18 25 71 33) (home) > Fax: 018-55 34 19 (int +46 18 55 34 19) (work) > E-mail: Tord.Snall at ebc.uu.se > Check this: http://www.vaxtbio.uu.se/resfold/snall.htm! > ------------------------------------------------------------------------ > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Dear Prof. Ripley, Thanks for your replies! I just want to add this below, which might be helpful to others who get a similar problem in the future. Tord> skuggor<- dat[!is.na(dat$skugg), ] > skugg.cpy1<- subset(skuggor, cpy==1) > skugg.cpy1.dat<- as.data.frame(table(skugg.cpy1$skugg, skugg.cpy1$grupp)) > names(skugg.cpy1.dat)<- c("skugg", "grupp", "frekv") > skugg.cpy1.dat<- subset(skugg.cpy1.dat, grupp == "gr3" | grupp == "gr5") > skugg.cpy1.datskugg grupp frekv 4 1 gr3 0 5 2 gr3 3 6 3 gr3 6 10 1 gr5 1 11 2 gr5 12 12 3 gr5 1> summary(polr(as.ordered(skugg) ~ as.factor(grupp),weights=as.numeric(frekv), data= as.data.frame(skugg.cpy1.dat))) Error in optim(start, fmin, gmin, method = "BFGS", hessian = Hess, ...) : non-finite value supplied by optim I guess it is a matter of data format It seem to be, because the following works:> > s<- skugg.cpy1.dat[,1] > g<- skugg.cpy1.dat[,2] > f<- skugg.cpy1.dat[,3] > sgf<- as.data.frame(cbind(s,g,f)) > sgfs g f 1 1 2 0 2 2 2 3 3 3 2 6 4 1 4 1 5 2 4 12 6 3 4 1> summary(polr(as.ordered(s) ~ as.factor(g), weights=as.numeric(f), datasgf))Re-fitting to get Hessian Call: polr(formula = as.ordered(s) ~ as.factor(g), data = sgf, weights as.numeric(f)) Coefficients: Value Std. Error t value -3.287802 1.252344 -2.625318 Intercepts: Value Std. Error t value 1|2 -5.8783 1.5565 -3.7765 2|3 -0.6973 0.7062 -0.9875 Residual Deviance: 25.76504 AIC: 31.76504> >That example works here (once I make skugg an ordered factor): > >Call: >polr(formula = skugg ~ grupp, data = dat, weights = frekv) > >Coefficients: > Value Std. Error t value > -3.287802 1.252344 -2.625318 > >Intercepts: > Value Std. Error t value >1|2 -5.8783 1.5565 -3.7765 >2|3 -0.6973 0.7062 -0.9875 > >Residual Deviance: 25.76504 >AIC: 31.76504 > >BTW, there is no point in including points with zero weight. > > >On Wed, 22 Jan 2003, Tord Snall wrote: > >> Dear all, >> >> I get an error message when I use polr() in MASS. These are my data: >> >> skugg grupp frekv >> 4 1 gr3 0 >> 5 2 gr3 3 >> 6 3 gr3 6 >> 10 1 gr5 1 >> 11 2 gr5 12 >> 12 3 gr5 1 >> > >> > summary(polr(skugg ~ grupp, weights=frekv, data= skugg.cpy1.dat)) >> Error in optim(start, fmin, gmin, method = "BFGS", hessian = Hess, ...) : >> non-finite value supplied by optim >> >> Does this depend on the very few observations in skugg 1 - the >> proportional-odds assumption doesn't hold (p 231, MASS 3ed)? If so, I would >> be happy for a recommendation on another approach. >> >> And I also have a similar data set where only the skugg classes 2 and 3 are >> observed. Would you recommend glm, family= binomial for that analysis? >> >> I use R 1.6.2, MASS 7.0-10, Win 2000. >> >> >> Thanks in advance! >> >> Please reply also to me because I'm on the once a day-list >> >> >> Sincerely, >> Tord >> >> ----------------------------------------------------------------------- >> Tord Sn?ll >> Avd. f v?xtekologi, Evolutionsbiologiskt centrum, Uppsala universitet >> Dept. of Plant Ecology, Evolutionary Biology Centre, Uppsala University >> Villav?gen 14 >> SE-752 36 Uppsala, Sweden >> Tel: 018-471 28 82 (int +46 18 471 28 82) (work) >> Tel: 018-25 71 33 (int +46 18 25 71 33) (home) >> Fax: 018-55 34 19 (int +46 18 55 34 19) (work) >> E-mail: Tord.Snall at ebc.uu.se >> Check this: http://www.vaxtbio.uu.se/resfold/snall.htm! >> ------------------------------------------------------------------------ >> >> ______________________________________________ >> R-help at stat.math.ethz.ch mailing list >> http://www.stat.math.ethz.ch/mailman/listinfo/r-help >> > >-- >Brian D. Ripley, ripley at stats.ox.ac.uk >Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ >University of Oxford, Tel: +44 1865 272861 (self) >1 South Parks Road, +44 1865 272866 (PA) >Oxford OX1 3TG, UK Fax: +44 1865 272595 > >----------------------------------------------------------------------- Tord Sn?ll Avd. f v?xtekologi, Evolutionsbiologiskt centrum, Uppsala universitet Dept. of Plant Ecology, Evolutionary Biology Centre, Uppsala University Villav?gen 14 SE-752 36 Uppsala, Sweden Tel: 018-471 28 82 (int +46 18 471 28 82) (work) Tel: 018-25 71 33 (int +46 18 25 71 33) (home) Fax: 018-55 34 19 (int +46 18 55 34 19) (work) E-mail: Tord.Snall at ebc.uu.se Check this: http://www.vaxtbio.uu.se/resfold/snall.htm! ------------------------------------------------------------------------