Generalized Linear Models

OptimizationProblems.GeneralizedLinearModelType
GeneralizedLinearModel{R, F, G<:GLMFamily} <: OptimizationProblem

Data for specifying the negative log-likelihood objective function for a generalized linear model.

Fields

  • name::String, the name of the problem
  • counters::Dict{Symbol, Counter}, a dictionary of symbols that identify a counter
  • num_param::Int64, dimension of the optimization parameter.
  • num_obs::Int64, the total number of observations.
  • resp::R, the responses of the data of type R, which will depend on the type of model being considered.
  • feat::F, the features or explanatory variables of type F, which will depend on the way features are stored.
  • family::G, specifies the GLM family being considered

Constructors

LogisticRegression

For details, see the docstrings for each function listed.

source

(Bernoulli) Logistic Regression Problem

OptimizationProblems.LogisticRegressionFunction
LogisticRegression(::Type{T}; num_param::Int64, num_obs::Int64, 
    name::String="Logistic Regression") where T <: Real

Constructs a Logistic Regression Problem where the given number of parameters is num_param and the number of observations is num_obs. The feature matrix is a matrix of type T. It has a column of ones followed by num_param-1 columns of independent random normal vectors with mean zero and variance 1/num_param. The response vector is a randomly generated BitVector corresponding to a logistic regression model. Returns a GeneralizedLinearModel{BitVector, Matrix{T}, Bernoulli}.

source
LogisticRegression(;resp::BitVector, feat::Matrix{T},
    name::String="Logistic Regression") where T <: Real

Constructs a Logistic Regression Problem with the user-supplied response vector, resp, and feature matrix, feat. Returns a GeneralizedLinearModel{BitVector, Matrix{T}, Bernoulli}.

source

Binomial Regression Problem

OptimizationProblems.BinomialRegressionFunction
BinomialRegression(::Type{T}; num_param::Int64, num_obs::Int64,
    max_trials::Int64=100, name::String="Binomial Regression") where T<:Real

Constructs a Binomial Regression problem where the given number of parameters is num_param and the number of observations is num_obs. The feature matrix is of type T. It has a column of ones followed by num_param-1 columns of independent random normal vectors wih mean zero and variance 1/num_param. The response is a vector of integer pairs. The first integer in the pair is a non-negative integer representing the number of successes. The second integer in the pair is positive integer representing the number of trials which is randomly selected from 1 to max_trials. Returns a GeneralizedLinearModel{Vector{Tuple{Int64, Int64}, Matrix{T}, Binomial}.

source
BinomialRegression(;resp::Vector{Tuple{Int64, Int64}}, feat::Matrix{T},
    name::String="Binomial Regression") where T<:Real

Constructs a Binomial Regression problem with the user-supplied response vector, resp, and feature matrix, feat. Each entry of resp should be a pair with the first number indicating the number of successes and the second number indicating the number of trials. Returns a GeneralizedLinearModel{Vector{Tuple{Int64, Int64}, Matrix{T}, Binomial}.

source

Exponential Regression Problem

OptimizationProblems.ExponentialRegressionFunction
ExponentialRegression(::Type{T}; num_param::Int64, num_obs::Int64,
    name::String="Exponential Regression") where T<:Real

Constructs an Exponential Regression problem where the given number of parameters is num_param and the number of observations is num_obs. The feature matrix is a matrix of type T. It has a column of ones followed by num_param-1 columns of independent random vectors whose entries have uniform distirbution (0,1/num_param). The response vector is a randomly generated vector of type T corresponding to the exponential regression model. Returns a GeneralizedLinearModel{Vector{T}, Matrix{T}, Exponential}.

Warn

Under the GLM family, for a feature vector feat and parameter vector x, dot(feat, x) must be non-positive.

source
ExponentialRegression(; resp::Vector{T}, feat::Matrix{T},
    name::String="Exponential Regression") where T<:Real

Constructs an Exponential Regression problem witha user-supplied response vector, resp, and a feature matrix, feat. Returns a GeneralizedLinearModel{Vector{T}, Matrix{T}, Exponential}.

source

Linear Regression Problem

OptimizationProblems.LinearRegressionFunction
LinearRegression(::Type{T}; num_param::Int64, num_obs::Int64,
    σ::T=T(1), name::String="Linear Regression") where T<:Real

Constructs a Linear Regression problem where the given number of parameters num_params and the number of observations is num_obs. The feature matrix has elements of type T. The feature matrix is a column of ones followed by num_param-1 columns of independent normal vectors with mean zero and variance 1/(num_param-1). The response is a vector of type T. The value of σ specifies the standard deviation of the responses. Returns a GeneralizedLinearModel{Vector{T}, Matrix{T},Normal}.

source
LinearRegression(;resp::Vector{T}, feat::Matrix{T}, 
    name::String="Linear Regression") where T<:Real

Constructs a Linear Regression problem with a user-supplied response vector, resp, and feature matrix, feat. Returns a GeneralizedLinearModel{Vector{T}, Matrix{T}, Normal}.

source

Poisson Regression Problem

OptimizationProblems.PoissonRegressionFunction
PoissonRegression(::Type{T}; num_param::Int64, num_obs::Int64, 
    name::String="Poisson Regression") where T<:Real

Constructs a Poisson Regression problem with the num_param parameters and num_obs observations. The feature matrix has elements of type T. The feature matrix is a column of ones followed by num_param-1 columns of independent normal vectors with mean zero and variance 1/(num_param-1). The response is a vector of type Int64 with non-negative values. Returns a GeneralizedLinearModel{Vector{Int64}, Matrix{T}, Poisson}.

source
PoissonRegression(;resp::Vector{Int64}, feat::Matrix{T}, 
    name::String="Poisson Regression") where T<:Real

Constructs a Poisson Regression problem with a user-supplied response vector, resp, and feature matrix, feat. Returns a GeneralizedLinearModel{Vector{Int64}, Matrix{T}, Poisson}.

source