Dear all,
I try to plot a logstic regression model as follows:
Valkror<- read.table("Valkror.txt", header=T)
np.bark<- glm(Npinc~bark, family=binomial, data=Valkror)
plot.formula(np.bark$fitted.values~ Valkror$bark)
The above looks nice but I want to connect the points with a line so I try:
plot.formula(np.bark$fitted.values~ Valkror$bark, type="b")
but it gives a somewhat! unexpected figure. :(
Could someone please give a clue....
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
------------------------------------------------------------------------
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Tord Snall <tord.snall at ebc.uu.se> writes:> Dear all, > I try to plot a logstic regression model as follows: > > Valkror<- read.table("Valkror.txt", header=T) > np.bark<- glm(Npinc~bark, family=binomial, data=Valkror) > plot.formula(np.bark$fitted.values~ Valkror$bark) > > The above looks nice but I want to connect the points with a line so I try: > > plot.formula(np.bark$fitted.values~ Valkror$bark, type="b") > > but it gives a somewhat! unexpected figure. :( > > Could someone please give a clue....Not having your data, I can't see what is wrong with your plot, but I'd wager that it is because the x values are out of sequence. You could try Valkror2<-Valkror[order(Valkror$bark),] and then plot(predict(np.bark,Valkror2,type="response")~Valkror2$bark,type="b") which is also safer than your strategy in case there are missing values in your data. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._