Skip to content

Relax Distributions compat requirement - #14

Open
meibujun wants to merge 1 commit into
masterfrom
codex/fix-unsatisfiable-requirements-for-distributions-package-wdilcp
Open

Relax Distributions compat requirement#14
meibujun wants to merge 1 commit into
masterfrom
codex/fix-unsatisfiable-requirements-for-distributions-package-wdilcp

Conversation

@meibujun

@meibujun meibujun commented Oct 2, 2025

Copy link
Copy Markdown
Owner

Summary

  • narrow the Distributions compat entry to the published 0.25 series so the package can resolve without hitting empty version ranges

Testing

  • not run (Julia executable is not available in this environment)

https://chatgpt.com/codex/tasks/task_e_68de4933440c8321821480b658d82ad6

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +102 to +106
current_pos = n_fixed
for effect in model.random_effects
name = effect.name
Z = Z_dict[name]
dim = size(Z, 2)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard against missing design matrices for unsupported random effects

Random effects marked as “ignored” in build_design_matrices are not inserted into Z_dict, yet the MME builder still iterates over every entry in model.random_effects and unconditionally accesses Z_dict[name]. When the model includes an unimplemented type (e.g. RandomEffect("herd", :iid)), this line throws a KeyError before the evaluation even begins, contrary to the warning that the effect will be skipped. The loop should skip or stub out unsupported effects so setup_mme remains executable.

Useful? React with 👍 / 👎.

Comment on lines +79 to +95
# 更新残差方差
residuals = y - X * solutions[1:n_fixed] - sum(Z * solutions[n_fixed+1:end] for (name, Z) in Z_dict)
s_y = dot(residuals, residuals)
tr_term = tr(C_inv[1:n_fixed, 1:n_fixed] * (X' * X)) # 简化
variances_new["residual"] = (s_y + tr_term) / n_obs

# 更新随机效应方差
current_pos = n_fixed
for effect in model.random_effects
name = effect.name
dim = size(Z_dict[name], 2)
u = solutions[current_pos+1 : current_pos+dim]

if effect.type == :additive && !isnothing(dm.A_inv_matrix)
u_Ainv_u = dot(u, dm.A_inv_matrix * u)
tr_term_u = tr(C_inv[current_pos+1:end, current_pos+1:end] * dm.A_inv_matrix) # 简化
variances_new[name] = (u_Ainv_u + tr_term_u) / dim

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge REML update uses full random vector for each effect

In the REML iteration, each random-effect design matrix is multiplied by solutions[n_fixed+1:end] and the trace term slices C_inv[current_pos+1:end, current_pos+1:end]. These expressions assume only one random effect: with two or more effects, solutions[n_fixed+1:end] stacks all effects so Z * … has mismatched dimensions and the trace calculation mixes unrelated blocks, causing dimension errors or incorrect variance updates. The residual and trace calculations need to use the segment of the solution and inverse matrix corresponding to the current effect (current_pos+1:current_pos+dim).

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant