36-462/662, Spring 2022
25 January 2022
linear.classifier = function(x, coefficients, offset) {
# The following is actually a (multiple of) the directed distance
distance.from.plane = function(z) { offset + z %*% coefficients }
directed.distances = apply(x, 1, directed.distance.from.plane)
return(ifelse(directed.distances >= 0, 1, 0))
}
lm
faraway
library implements these as the logit()
and ilogit()
functionsglm(y ~ x1 + x2, data = df, family = "binomial")
## Warning: glm.fit: algorithm did not converge
## Warning: glm.fit: fitted probabilities numerically 0 or 1 occurred
##
## Call: glm(formula = y ~ x1 + x2, family = "binomial", data = df)
##
## Coefficients:
## (Intercept) x1 x2
## 1.462 2.852 3.747
##
## Degrees of Freedom: 199 Total (i.e. Null); 197 Residual
## Null Deviance: 277.3
## Residual Deviance: 2.16e-09 AIC: 6
family="binomial"
option tells glm()
that we’re trying to estimate the probability that y
\(==1\), and the default “link function” is the logistic
Butler, Ronald W. 1986. “Predictive Likelihood Inference with Applications.” Journal of the Royal Statistical Society B 48:1–38. http://www.jstor.org/stable/2345635.