Hi Elizabeth, On Mon, Apr 11, 2011 at 9:59 AM, Elizabeth Pringle <eprin...@stanford.edu> wrote: > Hi, > > I have a dataset that I am trying to analyze and plot as an ordered logistic > regression (y = ordinal categories 1-3, x = continuous variable with values > 3-9). > > First is a problem with cdplot: > Produces a beautiful plot, with the "right" trend, but my independent factor > values are transformed. The factor has values from 3-9, but the plot > produces an x-axis with values from 20-140. When I force the xlim to be > 3-9, it produces a plot without the trend, which can't be correct.
This is difficult to really help with without some data (we do not have LogAntDensity). Certainly, if the graph shows values form 20 - 140, it makes sense that if you then force the range to be from 3 - 9, you do not see anything. The problem is not range, it is data/setup. > > Second is a problem with polr: > The output of the summary command of the model built with polr includes t > values for lots (if not all) of my independent factor values, but does not > produce a summary of the fit of the model or of the overall fit of the > factor. Also, intercepts are different from those produced with a logistic > fit in JMP... Does it not output the Residual Deviance and AIC? Those relate to model fit. Two models can be compared using anova(m1, m2), so to compare the overall effect of a factor or multiple factors, just fit and compare two separate models. > > Code below, any help much appreciated. > > Thanks > Beth > > LogAntDensityFactor<-as.factor(LogAntDensity) > > > ###order ordinal variable > > HammerCatOrd<-ordered(HammerCat) > > > ###set ordered ordinal dependent variable as factor > > HammerCatOrdFactor<-as.factor(HammerCatOrd) This is repetivie. ordered() makes a factor, and you could do the same with: factor(HammerCat, ordered = TRUE) Another note/commet, cdplot() and polr() have formula methods and can access data from a data frame elegantly. It would be better to keep all your data bundled together in a data frame, than have different variables in various stages of transformation but with similar names floating around. This may not be true, but wildly unexpected values almost sounds like a typo may have happened at some point either in using the name in cdplot OR in assigning data to the variable initially. > > ###density plot with three levels > > cdplot(HammerCatOrdFactor~LogAntDensityFactor,xlab="Log(Ant > Density)",ylab="Latency > of response to disturbance (1-3)") What does str(HammerCatOrdFactor) or summary(HammerCatOrdFactor) (and ditto for LogAntDensityFactor) give? My guess is you will find they are not quite what you thought they were. > > require(MASS) > > logordered<-polr(HammerCatOrdFactor~LogAntDensityFactor,Hess=TRUE) Side note, why is LogAntDensity a factor? or do you mean factor in a vernacular sense not in a technical is.factor(LogAntDensityFactor) sense? If LogAntDensityFactor is your only other term in the model, an example comparison could be: lognull <- polr(HammerCatOrdFactor ~ 1, Hess=TRUE) logordered <- polr(HammerCatOrdFactor ~ LogAntDensityFactor, Hess=TRUE) anova(lognull, logordered) Cheers, Josh > > summary(logordered,digits=3) > > [[alternative HTML version deleted]] Plain text emails are preferred. > ______________________________________________ > 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. -- Joshua Wiley Ph.D. Student, Health Psychology University of California, Los Angeles http://www.joshuawiley.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.