Skip to content

Updated to pixi and multi-response stats flag bugfix#21

Merged
jnschmid merged 33 commits into
nasa:mainfrom
jnschmid:multi-response-stats
Jun 25, 2026
Merged

Updated to pixi and multi-response stats flag bugfix#21
jnschmid merged 33 commits into
nasa:mainfrom
jnschmid:multi-response-stats

Conversation

@jnschmid

Copy link
Copy Markdown
Contributor

Changes

  • bugfix for multiple responses with the stats=True option
  • updated the pyproject.toml to include information for using pixi and limit the scipy version

bdphilli and others added 30 commits April 1, 2026 09:56
Three bugs when fitting PCE with multiple response columns
(e.g., results file with >1 column):

1. model.py get_press_stats(): np.delete(responses, idx) without
   axis flattens the 2D array. Added axis=0 to delete rows, matching
   the var_basis delete on the preceding line.

2. statistics.py calc_R_sq(): scalar comparison 'if R_sq > 1' fails
   when R_sq is an array. Use np.atleast_1d, np.any, and np.clip for
   element-wise handling. Returns scalar for single response.

3. pce.py check_fit(): press_stat[m] and R_sq[m] index into arrays
   whose shape depends on atleast_2d wrapping. Use .flat[m] to
   reliably extract the m-th scalar regardless of shape.

Single-response behavior is unchanged.
calc_error_sum_of_sq and calc_total_sum_of_sq used matrix algebra
forms (y'y - β'X'y and y'y - (Σy)²/n) that produce (m×m) matrices
for m responses. R² was then computed from the full matrix instead
of just the diagonal, giving incorrect values (always ~1.0).

Additionally, calc_total_sum_of_sq had np.sum(responses)**2 which
sums ALL elements across responses into one scalar instead of summing
each column independently.

Replaced both with direct residual-based computation:
  SSE = Σ(y - ŷ)² per column
  SST = Σ(y - ȳ)² per column

Returns 1D arrays for multi-response, scalars for single-response.
Equivalent to the matrix form for single response; correct for both.
@jnschmid jnschmid merged commit 8048c63 into nasa:main Jun 25, 2026
7 of 8 checks passed
@jnschmid jnschmid deleted the multi-response-stats branch June 25, 2026 19:55
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 this pull request may close these issues.

3 participants