Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coeftable on optimize output (MLE and MAP) throws error #2033

Closed
DominiqueMakowski opened this issue Jul 10, 2023 · 1 comment · Fixed by #2034
Closed

coeftable on optimize output (MLE and MAP) throws error #2033

DominiqueMakowski opened this issue Jul 10, 2023 · 1 comment · Fixed by #2034

Comments

@DominiqueMakowski
Copy link
Contributor

I am following the first example mentioned here https://discourse.julialang.org/t/ann-turing-0-13-0-mle-map-and-prediction/40033:

using Turing
using Optim
using StatsBase

@model function gdemo()
    s ~ InverseGamma(2,3)
    m ~ Normal(0, sqrt(s))

    1.5 ~ Normal(m, sqrt(s))
    2.0 ~ Normal(m, sqrt(s))

    return m, s
end

model = gdemo()

# Use the default optimizer, LBFGS.
mle1 = optimize(model, MLE())

coeftable(mle1)

But it throws an error. Am I doing something wrong?

ERROR: MethodError: Cannot `convert` an object of type Symbol to an object of type String

Closest candidates are:
  convert(::Type{T}, ::Union{InitialValues.SpecificInitialValue{typeof(*)}, InitialValues.SpecificInitialValue{typeof(Base.mul_prod)}}) where T<:Union{AbstractString, Number}
   @ InitialValues C:\Users\domma\.julia\packages\InitialValues\OWP8V\src\InitialValues.jl:258
  convert(::Type{T}, ::ProgressLogging.ProgressString) where T<:AbstractString
   @ ProgressLogging C:\Users\domma\.julia\packages\ProgressLogging\6KXlp\src\ProgressLogging.jl:211
  convert(::Type{String}, ::String)
   @ Base essentials.jl:298
  ...

Stacktrace:
  [1] StatsBase.NoQuote(s::Symbol)
    @ StatsBase C:\Users\domma\.julia\packages\StatsBase\XgjIN\src\statmodels.jl:111
  [2] (::StatsBase.var"#231#234"{CoefTable, Vector{AbstractVector{Float64}}})(::Tuple{Int64, Int64})
    @ StatsBase .\none:0
  [3] iterate
    @ .\generator.jl:47 [inlined]
  [4] collect(itr::Base.Generator{Base.Iterators.ProductIterator{Tuple{UnitRange{Int64}, UnitRange{Int64}}}, StatsBase.var"#231#234"{CoefTable, Vector{AbstractVector{Float64}}}})
    @ Base .\array.jl:782
  [5] show(io::IOContext{Base.TTY}, ct::CoefTable)
    @ StatsBase C:\Users\domma\.julia\packages\StatsBase\XgjIN\src\statmodels.jl:123
  [6] show(io::IOContext{Base.TTY}, #unused#::MIME{Symbol("text/plain")}, x::CoefTable)
    @ Base.Multimedia .\multimedia.jl:47
  [7] (::REPL.var"#55#56"{REPL.REPLDisplay{REPL.LineEditREPL}, MIME{Symbol("text/plain")}, Base.RefValue{Any}})(io::Any)
    @ REPL C:\Users\domma\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:276
  [8] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL C:\Users\domma\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:557
  [9] display(d::REPL.REPLDisplay, mime::MIME{Symbol("text/plain")}, x::Any)
    @ REPL C:\Users\domma\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:262
 [10] display(d::REPL.REPLDisplay, x::Any)
    @ REPL C:\Users\domma\AppData\Local\Programs\Julia-1.9.0\share\julia\stdlib\v1.9\REPL\src\REPL.jl:281
 [11] display(x::Any)
    @ Base.Multimedia .\multimedia.jl:340
 [12] #invokelatest#2
    @ .\essentials.jl:816 [inlined]
 [13] invokelatest
    @ .\essentials.jl:813 [inlined]
 [14] (::VSCodeServer.var"#66#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\domma\.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:199
 [15] withpath(f::VSCodeServer.var"#66#70"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams}, path::String)
    @ VSCodeServer c:\Users\domma\.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\repl.jl:249
 [16] (::VSCodeServer.var"#65#69"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\domma\.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:155
 [17] hideprompt(f::VSCodeServer.var"#65#69"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})
    @ VSCodeServer c:\Users\domma\.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\repl.jl:38
 [18] (::VSCodeServer.var"#64#68"{Bool, Bool, Bool, Module, String, Int64, Int64, String, VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\domma\.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:126
 [19] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging .\logging.jl:514
 [20] with_logger
    @ .\logging.jl:626 [inlined]
 [21] (::VSCodeServer.var"#63#67"{VSCodeServer.ReplRunCodeRequestParams})()
    @ VSCodeServer c:\Users\domma\.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:225
 [22] #invokelatest#2
    @ .\essentials.jl:816 [inlined]
 [23] invokelatest(::Any)
    @ Base .\essentials.jl:813
 [24] macro expansion
    @ c:\Users\domma\.vscode\extensions\julialang.language-julia-1.47.2\scripts\packages\VSCodeServer\src\eval.jl:34 [inlined]
 [25] (::VSCodeServer.var"#61#62")()
    @ VSCodeServer .\task.jl:514
@DominiqueMakowski
Copy link
Contributor Author

I found the source of the error. I'll make a PR to try to fix that

cpfiffer pushed a commit that referenced this issue Jul 12, 2023
* Fix #2033

* Propose additional columns

* Add other suggestions

* Update src/modes/OptimInterface.jl

Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

* Update src/modes/OptimInterface.jl

Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

* Update src/modes/OptimInterface.jl

Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

* bump version

* import SsStatsAPI

* Update Project.toml

* Update src/modes/OptimInterface.jl

Co-authored-by: David Widmann <devmotion@users.noreply.github.com>

---------

Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
Co-authored-by: Hong Ge <3279477+yebai@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant