Hello. I am running a linear mixed model with imputed data. Here is the code in generalized form:
There are N=555 participants in this particular sample.
The output Group variable table shows fewer participants, probably due to missingness somewhere.
The table shows 551 children are included in the estimation.
I want to know the N of children in the control group versus the treatment group. Everything I have tried returns the statistics from the full sample, not the estimation sample. I need these values because I am trying to calculate the 95% CI around the effect size using the calculator from Campbell Collaboration.
Here are some things I have tried (this is a little embarrassing but you can see I am sort of working blind here):
I then called these macros as part of outreg2, e.g.:
The above code just includes one of my attempts "`s(nObs_treat)')". None worked.
I then tried returning the e(N_g) matrix after the estimation, but that only tells me the numbers I already know. I do not know how to manipulate matrices to get the estimation sample size by treatment group.
Unfortunately I cannot share my data here, but I appreciate any input if available. Thank you.
Code:
**##### Linear Mixed Model ~~~~ ~~~~ mi estimate, dots: xtmixed outcome i.treatment##i.timepoint i.sex c.age i.district i.other_programs c.covid1 c.covid2 c.covid3 || cluster_id: || child_id: , reml cov(unstructured)
The output Group variable table shows fewer participants, probably due to missingness somewhere.
Code:
Multiple-imputation estimates Imputations = 20 Mixed-effects REML regression Number of obs = 1,042 Grouping information ------------------------------------------------------------- | No. of Observations per group Group variable | groups Minimum Average Maximum ----------------+-------------------------------------------- cluster_id~r | 183 1 5.7 20 child_id | 551 1 1.9 2 -------------------------------------------------------------
I want to know the N of children in the control group versus the treatment group. Everything I have tried returns the statistics from the full sample, not the estimation sample. I need these values because I am trying to calculate the 95% CI around the effect size using the calculator from Campbell Collaboration.
Here are some things I have tried (this is a little embarrassing but you can see I am sort of working blind here):
Code:
*** Compute quantities of interest local nCols: colsof e(N_g) local nObs = e(N_g)[1,`nCols'] *** Treatment levels levelsof `treatment', local(treatLevs) local nObs_treat "" foreach lev of local treatLevs {qui count if `treatment' == `lev' local nObs_treat "`nObs_treat', N at Treatment=`lev', `nObs'" local ntreat`lev' "`nObs'"}
Code:
*** Treatment levels levelsof `treatment', local(treatLevs) local dvNew_tx "" foreach lev of local treatLevs { sum `dv' if `treatment' == `lev' local dvN_tx = r(N) if `treatment'==1 local dvN_ct = r(N) if `treatment'==0 local dvNew_tx "`dvNew_tx', dvN_tx at treatment==1, `dvN_tx', dvN_ct at treatment==0, `dvN_ct'" }
Code:
local nObs_treat "" foreach lev of local treatLevs {local nObs_treat "`nObs_treat', N at Treatment=`lev', `e(N_g)'" local nObs`lev' "` e(N_g)'"}
I then called these macros as part of outreg2, e.g.:
Code:
*** Extracting Model Interaction Coefficient outreg2 using "${tables}/outcome_1105", dta replace sideway keep(1.treatment#1.timepoint) stats(coef ci pval) eform /// eqkeep(`e(depvar)') ctitle("Model Interaction"; "CI"; "pvalue") /// noaster nocon nonotes noobs noni paren(ci) /// adds(dvMean, `s(dvMean)', dvSDev, `s(dvSDev)' `s(dvStats_tp)', N obs, `s(nObs)' `s(treatList)' `s(nObs_treat)')
I then tried returning the e(N_g) matrix after the estimation, but that only tells me the numbers I already know. I do not know how to manipulate matrices to get the estimation sample size by treatment group.
Unfortunately I cannot share my data here, but I appreciate any input if available. Thank you.
Comment