JuMP Error: "Unexpected object missing in nonlinear expression"


Hi, I’ve been trying to perform a MLE procedure with JuMP but constantly run into an error. A snippet of my code is as follows:

using Distributions
using JuMP

norm_cdf(x) = cdf(Normal(), x)  #where Normal() is from Distributions
norm_pdf(x) = exp(-(x^2)/2)/sqrt(2*pi)
norm_dpdf(x) = x*norm_pdf(x)

mod = Model()
JuMP.register(mod, :norm_dist, 1, norm_cdf, norm_pdf, norm_dpdf)
@variable( mod, α[i = 1:8] )
            log( norm_dist( 
                q[t]*( α[1] + sum(α[j+1]*x[t,j] for j in 1:7) )
            )) for t in (T[i]+1):T[i+1]
        ) for i in 1:I

where x is a DataFrame, T and q are Arrays.The error that I received after running @NLobjective is:

Unexpected object missing in nonlinear expression.

 [1] error(::String) at .\error.jl:33
 [2] parseNLExpr_runtime(::Model, ::Missing, ::Array{ReverseDiffSparse.NodeData,1}, ::Int64, ::Array{Float64,1}) at C:\Users\krenova\.julia\packages\JuMP\PbnIJ\src\parsenlp.jl:207
 [3] top-level scope at C:\Users\krenova\.julia\packages\JuMP\PbnIJ\src\parseExpr_staged.jl:508

Wonder what went wrong.


Hi @krenova

It’s a bit hard to tell because variables like α aren’t defined so I can’t run your code.

However, missing is very suspect. Do you have missing values in your dataframe?

Take a read of PSA: make it easier to help you, and then update your post to include a minimum working example.


hey @odow, thanks for your kind reply. I’ve verified that I do not have any missing in my data but you are right about providing a minimum working example. I was trying my luck and hoping that someone would recognize the source of the problem without me having to provide too much information. Laziness on my part. Will update the post soon. Cheers and Happy New Year!


Gosh, apologies everyone, as @odow suspected, it was indeed missing values in my data that led to the error. I had a bug in my code that checks for missing values, resulting in the error.