Error with family in geom_smooth

2,273 views
Skip to first unread message

Manuel Spínola

unread,
Nov 8, 2015, 8:21:33 AM11/8/15
to ggplot2
Dear group members,

I am trying to use geom_smooth with a logistc regression and I got the following error:

library(ggplot2)

data(mtcars)
dat <- subset(mtcars, select=c(mpg, am, vs))
logr_vm <- glm(vs ~ mpg, data=dat, family=binomial(link="logit"))
ggplot(dat, aes(x=mpg, y=vs)) + geom_point() +
stat_smooth(method="glm", family="binomial", se=FALSE)
Error: Unknown parameters: family

Any idea what I am doing wrong?

Best,

Manuel

Ben Bolker

unread,
Nov 8, 2015, 9:27:18 AM11/8/15
to ggp...@googlegroups.com
I'm guessing that you're using the development version of ggplot; try
using method.args=list(family="binomial") ?


Manuel Spínola

unread,
Nov 8, 2015, 9:41:43 AM11/8/15
to Ben Bolker, ggplot2
Thank you very much Ben.  That was the problem.

Manuel



--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Manuel Spínola, Ph.D.
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspi...@una.ac.cr
mspin...@gmail.com
Teléfono: (506) 2277-3598
Fax: (506) 2237-7036
Personal website: Lobito de río
Institutional website: ICOMVIS

u112...@tuks.co.za

unread,
Sep 13, 2016, 8:56:37 AM9/13/16
to ggplot2
Hi, I still get an error when I use method.args. Perhaps I am using it wrong?

Here is my code:

g + geom_smooth(data = df, aes(x=a,y=s_bc), method = "glm", formula = s_bc~a, family = binomial(link="log"))

How would I use it with this line of script?

Thanks

This message and attachments are subject to a disclaimer. Please refer to http://www.it.up.ac.za/documentation/governance/disclaimer/ for full details.
Reply all
Reply to author
Forward
0 new messages