Logistic regression example by hand. I'm currently studying about Logistic Regression. But I'm getting stuck at calculating intercept ($\beta_0$) and coefficient ($\beta_1$). I've been looking for it through the internet, but only get tutorials using Microsoft Excel or built-in functions in R. I heard it can be solved by Maximum Likelihood, but I don't understand how to use it, because I don't have a statistical background. Can anyone can give me a brief explanation and simulation for calculating the coefficients manually? Unfortunately, unlike linear regression, there's no simple formula for the maximum likelihood estimate of logistic regression. You'll have to perform some kind of optimization algorithm, like gradient descent or iteratively reweighted least squares. I'd like to propose my method and hope it helps. To calculate the coefficients manually you must have some data, or say constraints. In logistic regression, actually it is how logistic function is defined via the maximum entropy and lagrange multipliers, this constraint must be met with other two: $E_p f_j = E_ f_j$. That is, the model's expectation should match the observed expectation , which has been illustrated in this paper. That's why logit-function as a link function in logistic regression is also termed mean function. Take for example, the crosstab bellow shows how many males/females are in the honor class. As mentioned above $\sum_i y_i x_ = \sum_i p_i x_ $ holds. The left hand side(LHS) is the expectation of the observations(y's in samples) and the right hand side(RHS) is the model's expectation. Assuming the function is $log(\frac )=\beta_0 + \beta_1x_i$ or equivalently $p=\frac >$($x_i$ represents the feature of the observation being a female, it is 1 if the observation is a female and 0 otherwise), obviously we know that the following two equations hold respectively when $X=1$ and when $X=0$ with the data shown above: So the intercept($\beta_0$) is -1.47 and the coefficient($\beta_1$) is 0.593. You can manually get it. Along the same lines, you can manually calculate coefficients of other logistic regression models(it applies also to softmax regression but it is out the scope of this question) if enough data are given. I hope I am right, if not please let me know. Thanks.
Комментариев нет:
Отправить комментарий