What Is the R Equivalent to the E(Sample) Command in Stata?

I'm running conditional logistic regression models in R as part of a discordant sibling pair analysis and I need to isolate the total n for each model. Also, I need to isolate the number and % of cases of the disease in the exposed and unexposed groups.

In Stata the e(sample) == 1 command gives this info. Is there an equivalent function for accomplishing this in R?

2

1 Answer

In R, if you run a regression you create a regression object.

RegOb <- lm(y ~ x1 + x2, data)

Often people call "RegOb" which uses the internal "print" method of this type of object. Alternative "summary(RegOb)" is popular (and often people would assign this).

However, RegOb contains many information about the regression. So in Stata you could use -ereturn list- to see what is saved. In R I would recommend to use "str(RegOb)" or "View(RegOb)" you will see everything that is saved. I have forgotten the correct syntax atm, but it will be something like: RegOb$data

And since you have the original data, you can simply use a logical statement based on the original and the used data which will give you the estimation sample.

Your Answer

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

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest