1

I have a dataset with a handful of variables. The first variable ("player") is a bunch of people's names, but the same player will come up many times in this column, as there are multiple observations for each user. I want to run a series of regressions - each only using the data from an individual player. And then output all of the betas/other regression details in a spreadsheet format. Is this possible?

I have been using

statsby, by(player): logit depvar indepvar1 indepvar2

and this runs the regressions, but does not give me any details beyond the betas. In particular, I need to get a list of the sums of the residuals that result from each of these regressions.

2
  • 1
    Hey there, welcome to stack overflow! It is generally advisable to provide a data example to get a comprehensive answer. If you are using logit regressions, are you sure you want to store the sum of residuals (or squared residuals) and not the Log likelihood? Commented Apr 19, 2021 at 21:12
  • 2
    You can write a custom program and execute the program for each player with runby from SSC. Commented Apr 19, 2021 at 21:16

1 Answer 1

1

I would recommend using the eststo package and a foreach loop. First, install the ssc package by running the command findit eststo and clicking the first link and clicking install. Then create a do file with the following code,

levelsof player
foreach lev in `r(levels)' {
    eststo `lev'store : logit depvar indepvar1 indepvar2
}

Note the use of local variables. This means that this code block must be run together and not separately as the local variables disappear once the operation is complete (more on local variables). Then you can simply run the following assuming you have only two names (name1 and name2),

esttab name1store name2store using filename.csv, stats(ll)

Where you will want to put whatever identifiers you want in the stats option here (I've chosen to include the log-likelihood). To see the possibilities, run a simply logit and type ereturn list after it. Let me know if you have any questions or if something doesn't work. I've tested this on sample data of mine and it works so hopefully it does for you as well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.