QuantLab

QuantLab

Share

Contact information, map and directions, contact form, opening hours, services, ratings, photos, videos and announcements from QuantLab, Educational Research Center, Khulna.

01/05/2026

๐Ÿ“Š Endogeneity Testing Across Multiple Outcome Variables (Stata)

Iโ€™ve recently run a systematic endogeneity check across all my key dependent variables using IV regression. The idea is to test whether fertility_rate is endogenous in explaining different wellbeing outcomes.

๐Ÿ” Outcome variables used:
dv_phy
dv_sex
Emotional_Index
dv_overall_index_pct
โš™๏ธ Stata Code:
*========================================
* ENDOGENEITY TESTS FOR ALL DEPENDENT VARIABLES
*========================================

global outcomes dv_phy dv_sex Emotional_Index dv_overall_index_pct

foreach y of global outcomes {

ivreg2 `y' $controls (fertility_rate = $IV_both), ///
endog(fertility_rate) cluster(cluster)

outreg2 using "$Results/Endogeneity_All_Outcomes.xls", ///
append ctitle("Endogeneity Test: `y'")

}
๐Ÿ“Œ What this does:
Runs IV regression for each outcome variable in a loop
Tests whether fertility_rate is endogenous
Uses clustered standard errors
Stores results in a single Excel file for comparison

This approach keeps the analysis clean, scalable, and consistent across multiple outcomes.

If anyone is doing similar multi-outcome IV work, this loop-based structure is very efficient.

01/05/2026

๐‹๐จ๐จ๐ค๐ข๐ง๐  ๐ญ๐จ ๐ฅ๐ž๐ฏ๐ž๐ฅ ๐ฎ๐ฉ ๐ฒ๐จ๐ฎ๐ซ ๐œ๐š๐ซ๐ž๐ž๐ซ?โฃ
โฃ
๐Ÿš€ Join our Hands-on Stata Training and learn data analysis the easy way! โฃ
โฃ
This intensive course focuses on the practical essentials: data cleaning, visualization, and analysis to help you in shaping real-world data for report writing. Limited seats only, so don't miss out! โฃ
โฃ
๐Ÿ”— ๐€๐ฉ๐ฉ๐ฅ๐ฒ ๐๐จ๐ฐ: https://forms.gle/aaJPUqeYpcJqGLHc6

Photos from QuantLab's post 25/12/2025

Glad to share that I have received two reviewer certificates from Springer Nature for evaluating manuscripts in Humanities and Social Sciences Communications and Discover Sustainability in 2025. Grateful for the opportunity to contribute to high-quality, impactful research through the peer-review process.

02/11/2025

๐Ÿ“Š Just discovered a neat trick in Stata!

If you want your graphs to look clean, simple, and publication-ready, try this:

grstyle init
grstyle set plain

This removes all the extra colors, grids, and decorations, giving your graphs a plain and professional look. Perfect for presentations or reports! โœ…

29/10/2025

๐Ÿ”น Stata Tip of the Day: floor() Command ๐Ÿ”น

Ever needed to round numbers down to the nearest whole number in Stata?
The floor() function is what you need! ๐Ÿงฎ

โœ… Syntax:

generate newvar = floor(oldvar)

๐Ÿ‘‰ Example:
If oldvar = 12.8 โ†’ floor(oldvar) = 12
If oldvar = -3.2 โ†’ floor(oldvar) = -4

๐Ÿ’ก Use this when dealing with age grouping, income brackets, or intervals where you need consistent rounding down.

Collapse command in stata 19/10/2025

1) Short & friendly (quick share)
Want quick summary stats in Stata? โœจ Use collapse. It converts your dataset to aggregated values (means, sums, counts) โ€” e.g. collapse (mean) income, by(village) gives village-level average income.
Tip: preserve + restore if you donโ€™t want to lose the original data. ๐Ÿ’พ


2) Technical post for researchers (copy-paste ready)
Stata quick-tip: collapse aggregates your dataset into summary-level observations โ€” very handy for moving from household to village or individual to group-level analysis.

Example (village-level averages & counts):

* keep original data (safe practice)
preserve

* village-level mean of income and mean of education,
* and count of households per village
collapse (mean) income education (count) household_id, by(village_id)

* now dataset contains one row per village with mean income, mean education, and household count

* restore the original dataset if needed
restore

Useful variants:

(sum) for totals, (median) for medians, (sd) for standard deviation.

Always preserve/restore or save to a new file โ€” collapse replaces your data in memory.

Sharing because small commands save so much time! ๐Ÿ’ก

3) Mini-tutorial (step-by-step for a post)
Want aggregated data fast? Use collapse in Stata โ€” it reduces rows by computing stats like means, sums, medians, counts.

Step example (create village-level totals & averages):

* 1) Save original (optional but recommended)
preserve

* 2) Aggregate: village totals for births and average income
collapse (sum) births (mean) income, by(village)

* 3) Work with aggregated data...
list in 1/10

* 4) Return to original data
restore

Reminder: collapse replaces your dataset in memory. Use preserve/restore or save the collapsed file with save collapsed_village.dta, replace. ๐Ÿ“

If anyone wants a short video or a do-nothing-but-try-it example with their own dataset, tell me which vars & Iโ€™ll craft it! ๐Ÿ’•

Collapse command in stata Learn how to use the collapse command in Stata to summarize your data efficiently. This tutorial covers the basics of collapsing datasets by mean, sum, count...

18/10/2025

๐ŸŽฏ Stata Tip: Difference between gen and egen

If youโ€™re new to Stata, you might wonder โ€” whatโ€™s the difference between gen and egen?

๐Ÿ‘‰ gen (generate)
Used to create a new variable based on simple expressions or calculations within each observation.
Example:

gen income_per_capita = income / household_size

๐Ÿ”น Works observation by observation.
๐Ÿ”น Great for arithmetic or logical operations.

๐Ÿ‘‰ egen (extensions of generate)
Used for more complex functions, especially those that require group-level calculations or summary statistics.
Example:

egen avg_income = mean(income), by(village)

๐Ÿ”น Works across observations (e.g., group means, ranks, counts).
๐Ÿ”น Comes with many built-in functions that gen canโ€™t do.

โœ… In short:

gen โ†’ simple calculations (row-wise)

egen โ†’ advanced calculations (group-wise or across data)

16/10/2025

๐Ÿ“Š STATA Quick Tip: Sorting Your Data Like a Pro!

Need to organize your dataset?
Hereโ€™s how to use sort and gsort in Stata ๐Ÿ‘‡

๐Ÿ”น Ascending Order (A โ†’ Z / Small โ†’ Large)

sort year

๐Ÿ”น Sort by Multiple Variables

sort country year

๐Ÿ”น Descending Order (Z โ†’ A / Large โ†’ Small)

gsort -year

๐Ÿ”น Mixed Order Sorting

gsort country -year

๐Ÿ’ก Tip:
Use gsort when you want full control โ€” like sorting newest years first or ranking by income highest to lowest.

clear
input str10 country year gdp
"Bangladesh" 2020 425
"Bangladesh" 2015 340
"Nepal" 2021 150
"Nepal" 2018 120
end

* Sort by country (asc) and year (desc)
gsort country -year

15/10/2025

๐Ÿ’ก Stata Tip of the Day!

Ever wanted to remove specific observations quickly without typing a long list of conditions?
Try using the inlist() function โ€” it makes your code short, clean, and powerful! โšก

๐Ÿ‘‰ Example:

drop if inlist(ID, 238, 239, 240, 241, 242)

โœ… What it does:
This command drops all observations where the variable ID matches any of those listed values.

No need to repeat ID == ... multiple times! Just wrap them in inlist(), and Stata does the rest.

Keep your code neat, readable, and efficient โ€” thatโ€™s the Stata way! ๐Ÿ’ปโœจ

Want your school to be the top-listed School/college in Khulna?

Click here to claim your Sponsored Listing.

Location

Website

Address

Khulna