Hi All,
I have 2 variables :
var1 continuous with missing values (100)
var2 unordered categorical with missing values (25)
I have imputed the missing values
now I am running the following programme:
xi: mi est, cmdok: runmlwin y cons var1t i.var2 , level2(area: cons,) level1(indiv: cons) nopause
And the result still have missing data corresponding to var2 (25)
How should I do to tell runmlwin to use the imputed values of the unordered categorical variable?
Many thanks
L
Unordered imputed variable
-
- Site Admin
- Posts: 432
- Joined: Fri Apr 01, 2011 2:14 pm
Re: Unordered imputed variable
Dear likestatistic,
Please will you provide an example which works with the regress command. We will then try to work out why the runmlwin command does not work when you substitute it for the regress command.
Best wishes
George
Please will you provide an example which works with the regress command. We will then try to work out why the runmlwin command does not work when you substitute it for the regress command.
Best wishes
George
-
- Posts: 39
- Joined: Fri Sep 12, 2014 4:11 pm
Re: Unordered imputed variable
I hope that you will be able to use this table.
It is a sample of my data.
Var1 and var2 had missing values and have been imputed
I want to use them in my multilevel model to predict y
using for example
xi: mi est, cmdok: runmlwin y cons var1 i.var2 , level2(area: cons,) level1(id: cons) nopause
Many Thanks
L
It is a sample of my data.
Var1 and var2 had missing values and have been imputed
I want to use them in my multilevel model to predict y
using for example
xi: mi est, cmdok: runmlwin y cons var1 i.var2 , level2(area: cons,) level1(id: cons) nopause
Many Thanks
L
- Attachments
-
- data.xls
- (16.75 KiB) Downloaded 566 times
-
- Site Admin
- Posts: 432
- Joined: Fri Apr 01, 2011 2:14 pm
Re: Unordered imputed variable
Hi Likestatistic,
Sorry perhaps I was not clear. In order to try to find out what might not be working with the rumlwin command, we really need you to provide us with a series of commands which work with your data with the regress command. If you are struggling to implement the single-level version of what you want with the regress command then I would suggest you email Stata support directly for help.
Best wishes
George
Sorry perhaps I was not clear. In order to try to find out what might not be working with the rumlwin command, we really need you to provide us with a series of commands which work with your data with the regress command. If you are struggling to implement the single-level version of what you want with the regress command then I would suggest you email Stata support directly for help.
Best wishes
George
-
- Posts: 39
- Joined: Fri Sep 12, 2014 4:11 pm
Re: Unordered imputed variable
Hi,
Thank you for the suggestion and sorry to have bothered you. My problem is sorted, a simple mistake in the command and a bug due to the fact that I' am working with more than 300thousand observations .
Here are the results with the data I provided
Regards
L
Thank you for the suggestion and sorry to have bothered you. My problem is sorted, a simple mistake in the command and a bug due to the fact that I' am working with more than 300thousand observations .
Here are the results with the data I provided
Code: Select all
*command
insheet using "N:\data.xls",clear
drop _mi_miss _1_var2 _2_var2 _3_var2 _4_var2 _5_var2 _6_var2 _7_var2 _8_var2 _9_var2 ///
_10_var2 _1_var1 _2_var1 _3_var1 _4_var1 _5_var1 _6_var1 _7_var1 _8_var1 _9_var1 _10_var1
mi set wide
mi describ
mi register imputed var1 var2
mi impute chained (mlogit) var1 (regress) var2= y, add(5) rseed(1523)
*model in stata
mi estimate, : mixed y i.var1 var2 || area:, reml
*model in stata using mlwin
sort area id
gen cons=1
mi est, mcerror cmdok: runmlwin y cons i.var1 var2, level2(area: cons,) level1(id: cons) nopause
*results
. drop _mi_miss _1_var2 _2_var2 _3_var2 _4_var2 _5_var2 _6_var2 _7_var2 _8_var2
> _9_var2 ///
> _10_var2 _1_var1 _2_var1 _3_var1 _4_var1 _5_var1 _6_var1 _7_var1 _8_var1 _9_va
> r1 _10_var1
. mi set wide
. mi describ
Style: wide
last mi update 01oct2014 18:15:41, 0 seconds ago
Obs.: complete 203
incomplete 0 (M = 0 imputations)
---------------------
total 203
Vars.: imputed: 0
passive: 0
regular: 0
system: 1; _mi_miss
(there are 5 unregistered variables)
. mi register imputed var1 var2
. mi impute chained (mlogit) var1 (regress) var2= y, add(5) rseed(1523)
Conditional models:
var2: regress var2 i.var1 y
var1: mlogit var1 var2 y
Performing chained iterations ...
Multivariate imputation Imputations = 5
Chained equations added = 5
Imputed: m=1 through m=5 updated = 0
Initialization: monotone Iterations = 50
burn-in = 10
var1: multinomial logistic regression
var2: linear regression
------------------------------------------------------------------
| Observations per m
|----------------------------------------------
Variable | Complete Incomplete Imputed | Total
-------------------+-----------------------------------+----------
var1 | 165 38 38 | 203
var2 | 184 19 19 | 203
------------------------------------------------------------------
(complete + incomplete = total; imputed is the minimum across m
of the number of filled-in observations.)
.
. mi estimate, : mixed y i.var1 var2 || area:, reml
Multiple-imputation estimates Imputations = 5
Mixed-effects REML regression Number of obs = 203
Group variable: area Number of groups = 17
Obs per group: min = 1
avg = 11.9
max = 25
Average RVI = 0.1133
Largest FMI = 0.3464
DF adjustment: Large sample DF: min = 40.37
avg = 59588.91
max = 226426.59
Model F test: Equal FMI F( 3, 186.6) = 1.39
Prob > F = 0.2487
------------------------------------------------------------------------------
y | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
var1 |
2 | 162.8015 90.83603 1.79 0.073 -15.39469 340.9978
4 | 64.80362 313.3858 0.21 0.837 -568.393 698.0002
|
var2 | 7.725514 6.676412 1.16 0.248 -5.410592 20.86162
_cons | 2038.737 1087.449 1.87 0.062 -100.6839 4178.158
------------------------------------------------------------------------------
------------------------------------------------------------------------------
Random-effects Parameters | Estimate Std. Err. [95% Conf. Interval]
-----------------------------+------------------------------------------------
area: Identity |
sd(_cons) | 97.24503 63.21491 27.19782 347.6969
-----------------------------+------------------------------------------------
sd(Residual) | 586.6303 30.30025 530.1495 649.1284
------------------------------------------------------------------------------
.
. sort area id
. gen cons=1
.
. do "C:\Users\SOUEDR~1\AppData\Local\Temp\STD00000000.tmp"
. mi est, cmdok: runmlwin y cons i.var1 var2, level2(area: cons,) level1(id: con
> s) nopause
Multiple-imputation estimates Imputations = 5
Normal response model Number of obs = 203
Average RVI = 0.1146
Largest FMI = 0.3512
DF adjustment: Large sample DF: min = 39.30
avg = 91844.87
max = 424369.54
------------------------------------------------------------------------------
| Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
FP1 |
cons | 2024.962 1076.085 1.88 0.061 -92.0137 4141.938
_2_var1 | 162.8681 89.82891 1.81 0.070 -13.35063 339.0868
_4_var1 | 61.05552 310.9212 0.20 0.845 -567.6872 689.7982
var2 | 7.804148 6.60805 1.18 0.238 -5.196928 20.80522
-------------+----------------------------------------------------------------
RP2 |
var(cons) | 7242.816 11863.4 0.61 0.542 -16009.1 30494.73
-------------+----------------------------------------------------------------
RP1 |
var(cons) | 338825.9 34927.96 9.70 0.000 270367.7 407284.1
------------------------------------------------------------------------------
Note: number of groups varies among imputations.
Note: number of observations per group varies among imputations.
L
-
- Site Admin
- Posts: 432
- Joined: Fri Apr 01, 2011 2:14 pm
Re: Unordered imputed variable
Great,
Very please you got it working
Best wishes
George
Very please you got it working
Best wishes
George