-
Notifications
You must be signed in to change notification settings - Fork 2
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
issue transferring GLMM to R #72
Comments
Can you provide the code block that caused this error? |
Yes, with my own data:
and with the example in the JellyMe4 readme:
I just tried running the example and my own data in a terminal instead of within RStudio and both worked. I checked the data type for my results and it is reported the same in the terminal and RStudio. |
Since you're embedding this in a primarily R document, I suspect that the general execution environment is being treated as R and the Julia blocks are being executed via JuliaCall. The precise error and stack trace backs this up. I suspect at some point, there's an implicit call to JuliaCall when you have just the model and not the tuple and that that is the source of the error. (JuliaCall works by starting a Julia session and then loading RCall within that session.) So how to solve this? Is the model run in a a separate code chunk from begin
machines = rcopy(R"nlme::Machines")
m = fit(MixedModel, @formula(score ~ 1 + Machine + (1 + Machine|Worker)), machines)
m_machines = (m, machines);
@rput m_machines
end |
Unfortunately both suggestions cause the same error. Here's the chunk I ran
and the output
I tried running without loading JellyMe4 to see what format m_machines has after rput, but I'm not sure if this has any useful information.
|
🤔 It looks like the Tuple is being brought wholesale into R as an R-list with two elements and then it's trying to convert each element individually. Which is really, really weird. I suspect this might be the problem in JuliaCall: function sexp(x ::Tuple)
r = sexp(Array{Any}([x...]))
setattrib!(r, :class, sexp("JuliaTuple"))
r
end That's grabbing the tuple and converting it to an array. I think that's wrong. Realistically, RCall should define a conversion for tuple, but even with taking that into consideration, the you shouldn't define function sexp(::Type{RClass{:list}}, x ::Tuple)
r = protect(sexp(Array{Any}([x...])))
setattrib!(r, :class, sexp("JuliaTuple"))
unprotect(1)
r
end
sexpclass(::Tuple) = RClass{:list} I can try to get that upstreamed to RCall when I get a chance, but then JuliaCall would have to be updated to remove the current method. In the meantime, I think you can get around this by using RCall.Const.GlobalEnv[:m_machines] = robject(:lmerMod, m_machines) instead of |
Oh if you're using a GLMM, then you'll need |
|
I am having a similar issue. The following code produces the same
i.e. Trying the following instead Is this solution no longer working? Or is it an issue with generalized vs. linear models? |
Can you provide JellyMe4, RCall and Julia versions? @dhalpern |
Apologies for the delay, here is the output of
|
RCall.Const.GlobalEnv is still working for me. I have the same versions of
the relevant packages, but I'm using 1.10.6 not 1.11. I had a lot of
trouble with 1.11 running from RStudio in quarto markdown, so I reverted
back to 1.10.
--
Joseph M. Orr, Ph.D.
Associate Professor | Associate Department Head
Department of Psychological and Brain Sciences
https://tamu.zoom.us/my/josephorr
…On Wed, Nov 6, 2024 at 12:02 PM dhalpern ***@***.***> wrote:
Apologies for the delay, here is the output of Pkg. status() Status `~/.
julia/environments/v1. 11/Project. toml` [cbdf2221] AlgebraOfGraphics v0.
8. 13 [336ed68f] CSV v0. 10. 15 [13f3f980] CairoMakie v0. 12. 15 [a93c6f00]
DataFrames v1. 7. 0 [8f03c58b]
ZjQcmQRYFpfptBannerStart
This Message Is From an External Sender
This message came from outside your organization.
ZjQcmQRYFpfptBannerEnd
Apologies for the delay, here is the output of Pkg.status()
Status `~/.julia/environments/v1.11/Project.toml`
[cbdf2221] AlgebraOfGraphics v0.8.13
[336ed68f] CSV v0.10.15
[13f3f980] CairoMakie v0.12.15
[a93c6f00] DataFrames v1.7.0
[8f03c58b] Effects v1.3.0
[5789e2e9] FileIO v1.16.4
[7073ff75] IJulia v1.25.0
⌅ [033835bb] JLD2 v0.4.53
[19ac8677] JellyMe4 v1.2.2
[ff71e718] MixedModels v4.26.1
[b32ace64] MixedModelsSerialization v0.1.1
[6f49c342] RCall v0.14.6
—
Reply to this email directly, view it on GitHub
<https://urldefense.com/v3/__https://github.com/palday/JellyMe4.jl/issues/72*issuecomment-2460441909__;Iw!!KwNVnqRv!A48LshghNaSQfDFgyYW2_N1-8LpD4cH_9n5S7sQOYdnHnHx6X3Jyt7j40o7r_wfhleYh6SMl8yAA0j9IRSkElLdkpx0$>,
or unsubscribe
<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ACBNSL337HQ4FBJ6ABAKXMLZ7JKUBAVCNFSM6AAAAABRFIYI7GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRQGQ2DCOJQHE__;!!KwNVnqRv!A48LshghNaSQfDFgyYW2_N1-8LpD4cH_9n5S7sQOYdnHnHx6X3Jyt7j40o7r_wfhleYh6SMl8yAA0j9IRSkE5h8ZFJk$>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
I'm having an issue getting model fits to R. I'm running a Generalized Linear Mixed Model with Bernoulli family. I get the following error from rput:
I also tried with the example from the JellyMe4 readme (m_machines and I get the same issue:
I'm running julia from a quarto document mostly written in R in case that matters.
The text was updated successfully, but these errors were encountered: