[R] Plotting Fitted vs Observed Values in Logistic Regression Model

Paul Bernal p@u|bern@|07 @end|ng |rom gm@||@com
Tue Aug 1 15:57:49 CEST 2023


Dear friends,

I hope  this email finds you all well. This is the dataset I am working
with:
dput(random_mod12_data2)
structure(list(Index = c(1L, 5L, 11L, 3L, 2L, 8L, 9L, 4L), x = c(5,
13, 25, 9, 7, 19, 21, 11), n = c(500, 500, 500, 500, 500, 500,
500, 500), r = c(100, 211, 391, 147, 122, 310, 343, 176), ratio = c(0.2,
0.422, 0.782, 0.294, 0.244, 0.62, 0.686, 0.352)), row.names = c(NA,
-8L), class = "data.frame")

A brief description of the dataset:
Index: is just a column that shows the ID of each observation (row)
x: is a column which gives information on the discount rate of the coupon
n: is the sample or number of observations
r: is the count of redeemed coupons
ratio: is just the ratio of redeemed coupons to n (total number of
observations)

#Fitting a logistic regression model to response variable y for problem 13.4
logistic_regmod2 <- glm(formula = ratio~x, family = binomial(logit), data =
random_mod12_data2)

I would like to plot the value of r (in the y-axis) vs x (the different
discount rates) and then superimpose the logistic regression fitted values
all in the same plot.

How could I accomplish this?

Any help and/or guidance will be greatly appreciated.

Kind regards,
Paul

	[[alternative HTML version deleted]]



More information about the R-help mailing list