Giter VIP home page Giter VIP logo

Comments (3)

mcaceresb avatar mcaceresb commented on July 21, 2024 1

@erciomunoz I've decided to leave this issue up in case others have a similar question about how gegen and gcollapse weights are meant to work. I've changed the title to one I think is more precise but LMK if you disagree. Cheers.

from stata-gtools.

mcaceresb avatar mcaceresb commented on July 21, 2024

@erciomunoz This is not a gtools bug per se, so to the extent it's a bug at all it would be on Stata. As documented in the help files, weights in gegen and gcollapse are meant to mimic collapse (see weights section of the collapse help pdf). You can see

clear
set obs 5
g units=1
g weight=5
collapse (sum) units [w = weight]
disp units

Gives 5 as the answer. The reason is that aweights are normalized to sum to the number of observations. Try fweight, pweight, or iweight to see the difference. Also

clear
set obs 5
g units=_n
g weight=_n
gegen total =total(units) [w=weight]
gegen totalu=total(units)
sum total*

Gives a different answer, showing weights are not being ignored (they just work different than how you might intuit). Cheers.

from stata-gtools.

erciomunoz avatar erciomunoz commented on July 21, 2024

Thanks for the quick reply.

This makes total sense, now I regret a little bit that I did not spend more time thinking about it before posting.

from stata-gtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.