# Implementation of Univariate logistic regression

For Univariate Linear Regression I can calculate the parameters (And most everything else) from simple sum of squares. Is there a corresponding method for Logistic Regression? Any pointers to code (in any language) would be helpful.

(Yes there are many solvers, but I want to implement as a simple Map-Reduce algorithm, as I have for Univariate Linear Regression)

In general you would need a solver. One exception would be a fully saturated model, that is, a model with only categorical explanatory/right-hand-side/x-variables and one parameter for each combination of groups. In that case the coefficients are just a function of the group means. In case of a bivariate model, it would mean that your only explanatory/right-hand-side/x-variable is a binary variable. Below is an example of how to recreate the results obtained by a solver of a fully saturated bivariate model by just transforming means in Stata.

// load some example data
sysuse nlsw88, clear

// use a "solver"

// collect the means
tempname noncoll coll
sum union if e(sample) & collgrad == 0, meanonly
scalar noncoll' = r(mean)
sum union if e(sample) & collgrad == 1, meanonly
scalar coll' = r(mean)

// recreate the coefficients using just means
di as txt    "the constant"                   ///
as result logit(noncoll')

di as txt    "coefficient of collgrad: "      ///
as result logit(coll') - logit(noncoll')
`