Two questions about GLM

  1. Categorical outcome responses lead to a multinomial distribution (multinomial or ordinal depending on whether isordered assuming the LogitLink). Distributions.jl has the multinomial distribution and StatsFuns.jl has the softmax function. However, GLM has does not support multinomial or categorical models yet (except for Binomial / logit). It is currently a feature request #206.
  2. For specifying contrasts,
using DataFrames, GLM
rand(0)
data = DataFrame(y = rand(10), x1 = rand(1:3, 10))
categorical!(data, :x1)
glm(@formula(y ~ x1), data, Normal(), IdentityLink()) # Uses default level
glm(@formula(y ~ x1), data, Normal(), IdentityLink(), contrasts = Dict(:x1 => DummyCoding(base = 2))) # Uses 2 as the base level
3 Likes