Fix package metadata and clarify installation instructions - #12
Fix package metadata and clarify installation instructions#12meibujun wants to merge 20 commits into
Conversation
There was a problem hiding this comment.
💡 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
| # 更新残差方差 | ||
| 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)) # 简化 |
There was a problem hiding this comment.
Slice random-effect coefficients per effect when forming residuals
In estimate_variances_reml the residual vector is built with sum(Z * solutions[n_fixed+1:end] for (name, Z) in Z_dict). This multiplies every random-effect design matrix by the entire concatenated random-effect solution vector. As soon as the model contains more than one random effect, the column count of each Z no longer matches the length of solutions[n_fixed+1:end], producing a DimensionMismatch before REML can iterate. Even if it did not error, each effect would be double-counted. Slice solutions for each effect instead of passing the whole tail on every multiplication.
Useful? React with 👍 / 👎.
| 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 | ||
| end |
There was a problem hiding this comment.
Use block of C⁻¹ matching each random effect when computing traces
Within the same REML loop the trace term for additive effects uses C_inv[current_pos+1:end, current_pos+1:end] together with dm.A_inv_matrix. When more than one random effect is present, that slice spans all remaining random-effect coefficients, so its dimensions exceed A_inv and the matrix product triggers a DimensionMismatch. The trace and u_Ainv_u calculations need to use the submatrix current_pos+1:current_pos+dim that corresponds to the current effect only.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68de39b3e1848321b88a1648ac49e777