JuliaInterop / JuliaInterop/JuliaCall

julia_eval scrambling parameter order when returning :glmerMod

Open
#236 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
287
Forks
43
PR merge metrics
No merged PRs in 30d

Description

When returning a GeneralizedLinearMixedModel result using julia_eval I get estimates in the subsequently saved .rds that are out of order with the labels in julia.

The data I am running is quite large and not easily shared. So I apologies for an incomplete example. The code:

julia_assign("m0form", formula(case ~ 0 + Analysisclass + (1|cropyear/individual_local_identifier)))
julia_command(sprintf('Jmodel = fit(GeneralizedLinearMixedModel, m0form, data, Bernoulli(), wts=float.(data.weights), contrasts= Dict(:Analysisclass => DummyCoding(base="aRice_Wet_day")))'))

produces:
image

But when I save it into R using:

juliamodel<- julia_eval("robject(:glmerMod, Tuple([Jmodel, data]));",need_return ="R") 

I get:
image

That is a pretty serious discrepancy! Any recommendation on how to prevent this or identify the correct parameter order from the rds alone?

I ran this code in a loop across different datasets and saving only the .rds and not retaining a log to see the original Julia output.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the julia_eval and robject calls shown in the report, then trace how a :glmerMod is converted and saved to .rds. Reproduce the parameter-order discrepancy with the provided julia_assign and julia_command flow; done when the saved result preserves the Julia labels and estimates in matching order.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.