I have a dataset that consists of binary output variables (0 or 1) across a dependent variable range. I am trying to plot a probit regression model with that dataset using the stat_smooth function to plot a sigmoidal trendline. However, the stat_smooth function is not recognizing the arguments I am using to make the distribution binomial.
Data below:
structure(list(Status = c(0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1,
1, 1, 0, 0, 0, 0, 0), Conc = c(0, 0, 0, 0, 0, 0, 0, 0, 5, 5,
5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3,
3, 2, 2, 2, 2, 2, 2, 2, 2)), class = c(“tbl_df”, “tbl”, “data.frame”
), row.names = c(NA, -40L))
I tried this command to make the plot:
ggplot(HPro, aes(x=Conc,y=Status)) + geom_point() + stat_smooth(method=”glm”, methods.args=list(family=”binomial”),se=FALSE) + theme_light() + stat_regline_equation(aes(label = ..eq.label..)) + labs(x=”Log Viral Conc. (copies/mL)”)
However, I get a warning message as follows:
In stat_smooth(method = “glm”, methods.args = list(family = “binomial”), :
Ignoring unknown parameters: `methods.args
The resulting plot has a straight trendline that doesn’t fit the data well at all. I have seen this exact code used in various examples online, but no matter how I phrase it, it refuses to parse the binomial argument.
If anyone has a way of fixing this command or just outright improving it, I would appreciate it.
Joe Hardie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.