Skip to content

sfareg-methods.Rd: a method table up front, and correct what vcov and nobs do (issue #3) - #49

Merged
davidhbernstein merged 1 commit into
mainfrom
docs/sfareg-methods-rd
Oct 1, 2026
Merged

davidhbernstein merged 1 commit into
mainfrom
docs/sfareg-methods-rd

Conversation

@davidhbernstein

Copy link
Copy Markdown
Owner

This continues the issue #3 readability pass with sfareg-methods.Rd (coef, vcov, logLik, nobs, estfun, bread). Three statements on the page were stale; each was checked against R/sfareg_methods.R and R/sandwich_methods.R.

Corrected facts

the page said the code does
vcov() "is solve(object$opt$hessian)" .sfa_solve_equilibrated() scales the Hessian to unit diagonal (when that diagonal is positive) before inverting. .sfa_map_vcov() then maps the inverse onto the reported scale. The diagonal fallback warns only when inversion or mapping fails. A fit with no Hessian falls back to the diagonal silently, or, with no SEs either, returns NA with a warning (checked on an optHessian = FALSE fit).
nobs() reads object$data, or else re-evaluates the call's data it takes the stored count (object$nobs) first, then object$data, then a per-observation vector, and only then re-evaluates data. Re-evaluated data must pass the A47 data check. Checked: an sfm fit with one NA row reports 299 of 300.
"sfareg" is returned by psfm, sfm, zsfm, ttsfm also by lcsfm, copsfm, ivsfm, selsfm and esfm (class c("esfm", "sfareg")). npsfm returns "npsfareg", so it is not listed.

Layout

  • \description now has a method / returns table.
  • \details opens with "What each method returns", which moved from the bottom of the page.
  • The rest is under titled subsections: four covariances, BHHH, sandwich, which fits supply scores, the scale the scores live on, two easily-confused quantities, and estimators with no log-likelihood.

No technical content was removed. \usage is byte-identical, tools::checkRd() is clean, and the rendered text was checked with Rdconv -t txt.

🤖 Generated with Claude Code

https://claude.ai/code/session_014oJL17ewiahA8pWbemnqNp


Generated by Claude Code

… nobs do (issue #3)

The page said vcov() returns solve(opt$hessian); it inverts an equilibrated
Hessian and maps the result to the reported scale. It said nobs() reads
object$data or re-evaluates the call; it reads the stored count first, then
the data, then a per-observation vector, and validates any re-evaluated data.
It listed four of the nine entry points that return "sfareg". The long
discussion now sits under titled subsections. \usage is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014oJL17ewiahA8pWbemnqNp
@davidhbernstein
davidhbernstein merged commit 7dfb237 into main Oct 1, 2026
5 checks passed
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.

2 participants