bugGNU Octave - Bugs: bug #52417, [octave forge] (statistics) size...


bug #52417: [octave forge] (statistics) size not match in logistic_regression docstring

Submitter:  None
Submitted:  Thu 16 Nov 2017 06:58:20 AM UTC
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Wed 10 Aug 2022 05:57:48 PM UTC, comment #4: 

adding a note that there is more than just a docstring issue here. despite help and some code text, it appears to follow -theta + beta *x. moving discussion and other fixes over to bug #60348, since some discussion already over there and all of these logistic_regression reports are related.

Nicholas Jankowski <nrjank>
Group Member
Sun 07 Aug 2022 08:04:52 PM UTC, comment #3: 

Thanks Nicholas for the patch.
Patch pushed at https://github.com/gnu-octave/statistics/commit/9b806da0d79246c5f4eed3d228dfe7b306f9244b
This can be closed.

Andreas Bertsatos <pr0m1th3as>
Sat 06 Aug 2022 05:46:11 PM UTC, comment #2: 

looking at the code, when undefined beta initializes to zeros(columns(x),1) as per the comment #0 suggestion. theta is required to have the same number of columns as beta (line 119, they are assembled as tb = [theta; beta], which would error otherwise. So the orientation is suggestive of needing x beta to avoid the error.  Confirming this, the last optional output calculates gamma, and does so using (x beta) + theta in line 183.

i've attached a simple gif patch making that change.

(file #53539)

Nicholas Jankowski <nrjank>
Group Member
Wed 22 Nov 2017 07:01:11 PM UTC, comment #1: 

I don't know enough about the logitistic regression to be able to tell which version of the equation is correct.  Unfortunately, we need someone with either statistics expertise, or who can read the m-file, to determine the correct phrasing.

Rik <rik5>
Group administrator
Thu 16 Nov 2017 06:58:20 AM UTC, original submission:  

In the docstring of "logistic_regression.m", it seems that

logit (gamma_i (x)) = theta_i - beta' * x,   i = 1 ... k-1

should be

logit (gamma_i (x)) = theta_i - x * beta,   i = 1 ... k-1

Because of unmatched matrix sizes,

beta' * x

would raise the error "nonconformant arguments", while

x * beta

would not.

The parameters X and BETA of "logistic_regression.m" have the same convention as "ols.m" (linear regression), where rows(X) equals the number of training samples, and rows(BETA)==columns(X) equals the number of input features.

The docstring of "ols.m" says

y = x*b + e

which is correct (where BETA is just the estimator for b).

But I'm not familiar with logistic regression in the case of K > 2, so I'm not very sure whether this change is correct.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files


   bug dependencies.

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by pr0m1th3as (Posted a comment)
  • -email is unavailable- added by nrjank (Updated the item)
  • -email is unavailable- added by nrjank
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.


    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-10 nrjank Dependencies- Depends on bugs #60348
    2022-08-08 nrjank StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2022-08-06 nrjank Attached File- Added doc-logistic_regression-formula-fix-bug-52417.patch, #53539
        StatusNeed Info Patch Submitted
        Carbon-Copy- Added pr0m1th3as
    2018-06-19 mtmiller CategoryDocumentation Octave Forge Package
        Release4.2.1 dev
        Summarysize not match in logistic_regression docstring [octave forge] (statistics) size not match in logistic_regression docstring
    2017-11-22 rik5 StatusNone Need Info

    Back to the top

    Powered by Savane 3.12