A confused beginner.

- Thread starter Pinky1111
- Start date
- Tags linear regression logistic regression matlab

A confused beginner.

A confused beginner.

What is being plotted on the Y axis in each case? for the logistic regression, the log odds

I second @ondansetron inquiries. Please post the plots.

If you just look at the plot for y between .25 and .75 a linear fit is pretty darn good. So if it's turns out that what you're modeling has predicted probabilities mainly in that region then a linear fit won't be too bad. Trying to use the linear fit if you plan on going beyond the input range you fit the model with could be problematic though.

C-like:

```
# Create the data for a logistic curve
xs <- seq(-5, 5, by = .01)
ys <- plogis(xs)
# Let's do some plotting and save to a png
png("LogisticVsLinear.png")
# Create plot area with labels but no points
# basegraphics4life
plot(xs,
ys,
type = "n",
ylim = c(-.2,1.2),
main = "Logistic vs Linear - Midrange",
ylab = "y",
xlab = "x")
# Add in the logistic curve
lines(xs, ys, col = "blue")
# Plot the asymptotic boundaries
abline(h = 0)
abline(h = 1)
# you can define the area you want the line
# to 'best fit' for. In this case it was
# for -1 <= x <= 1
id <- which(abs(xs) <= 1)
xs_red <- xs[id]
ys_red <- ys[id]
o <- lm(ys_red ~ xs_red)
# Plot the best fit line
abline(o, lty = 2)
# Add a legend.
legend("topleft",
c("Logistic", "Linear"),
col = c("blue", "black"),
lty = c(1,2))
dev.off()
```