Add observation-level sample weights to poLCA#29
Open
tingjhenjiang wants to merge 1 commit into
Open
Conversation
Adds a weights argument to poLCA() (numeric vector or column name of data) implementing weighted pseudo-maximum-likelihood estimation: - weighted log-likelihood sum_i w_i log f(y_i) - weighted M-step response probabilities via row-scaled posteriors passed to the existing probhat C routine - weighted mixing proportions (no-covariate case) and a weighted pure-R Newton step poLCA.dLL2dBeta.w for latent class regression, matching the C layout of d2lldbeta2 exactly at unit weights - pseudo-ML sandwich standard errors in poLCA.se (A^-1 B A^-1 with A = sum w s s', B = sum w^2 s s'), reducing to the original ginv(t(s) s) at unit weights - weighted cell frequencies in poLCA.compress for Chisq/Gsq weights=NULL or all-1 weights reproduce the original estimator exactly; integer weights match row-replicated data to fp accumulation error. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
shermanlo77
reviewed
Jul 13, 2026
| # weighted estimator of the response probabilities | ||
| vp$vecprobs <- poLCA.probHat.C(w*rgivy,y,vp) | ||
| } else { | ||
| vp$vecprobs <- poLCA.probHat.C(rgivy,y,vp) # update probs |
There was a problem hiding this comment.
For the majority of the code, you've re-used w well in both the unweighted and weighted versions. Why do you need an if statement here?
|
Have you written this commit yourself? |
Is there a chance you could instead modify the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a weights argument to poLCA() (numeric vector or column name of data) implementing weighted pseudo-maximum-likelihood estimation:
weights=NULL or all-1 weights reproduce the original estimator exactly; integer weights match row-replicated data to fp accumulation error.