Plotting the mean value for each group

What we could attempt however is to plot the mean value for each group.

agegroupmean = np.array([0.1, 0.133, 0.250, 0.333, 0.462, 0.625, 0.765, 0.800])
group = np.array([1, 2, 3, 4, 5, 6, 7, 8])
plt.plot(group, agegroupmean, "r-")
plt.axis([0,9,0, 1.0])
plt.xlabel(r'Age group')
plt.ylabel(r'CHD mean values')
plt.title(r'Mean values for each age group')
plt.show()

We are now trying to find a function \( f(y\vert x) \), that is a function which gives us an expected value for the output \( y \) with a given input \( x \). In standard linear regression with a linear dependence on \( x \), we would write this in terms of our model

$$ f(y_i\vert x_i)=\beta_0+\beta_1 x_i. $$

This expression implies however that \( f(y_i\vert x_i) \) could take any value from minus infinity to plus infinity. If we however let \( f(y\vert y) \) be represented by the mean value, the above example shows us that we can constrain the function to take values between zero and one, that is we have \( 0 \le f(y_i\vert x_i) \le 1 \). Looking at our last curve we see also that it has an S-shaped form. This leads us to a very popular model for the function \( f \), namely the so-called Sigmoid function or logistic model. We will consider this function as representing the probability for finding a value of \( y_i \) with a given \( x_i \).