classification (N-level ID) issue
-
- Posts: 45
- Joined: Tue Jan 10, 2017 3:36 am
classification (N-level ID) issue
Hello,
Just finished all installation procedures and started to run Stat-JR based on Chrome.
First, I uploaded the DTA file that contains missing information.
Then, based on the manual, I chose "Template" => "N-Level" => "NLevelMod" => "Use" to build four-level models (as my model of interest is a four-level random intercept model although the missing is only at level 1).
After I put "4" as the number of classification, I couldn't find some of "ID" variables (i.e., individual ID, household ID, and PSU) from the "classification" bar. However, I did find those variables from the "response" bar.
The same issue happened when I tried to use other template such as 2-Level.
I am wondering how I can address this part. Would appreciate your supports!
Best wishes,
Yongjoo
Just finished all installation procedures and started to run Stat-JR based on Chrome.
First, I uploaded the DTA file that contains missing information.
Then, based on the manual, I chose "Template" => "N-Level" => "NLevelMod" => "Use" to build four-level models (as my model of interest is a four-level random intercept model although the missing is only at level 1).
After I put "4" as the number of classification, I couldn't find some of "ID" variables (i.e., individual ID, household ID, and PSU) from the "classification" bar. However, I did find those variables from the "response" bar.
The same issue happened when I tried to use other template such as 2-Level.
I am wondering how I can address this part. Would appreciate your supports!
Best wishes,
Yongjoo
-
- Posts: 1354
- Joined: Mon Oct 19, 2009 10:34 am
Re: classification (N-level ID) issue
For these templates the number of classifications that you specify refers to higher level classifications, i.e. you don't need to specify a level-1 unit classification. For variables to be offered as options for the classifications they need to be of an integer type (i.e. none of the values contain any decimals). I would suggest checking that this is the case for the variables that you are trying to use.
-
- Posts: 45
- Joined: Tue Jan 10, 2017 3:36 am
Re: classification (N-level ID) issue
I just quickly checked the DTA file, and it seems those (individual, household, and PSU IDs) variables were coded as "character" values (i.e., A010101). I am wondering what might be a good solution to address this part, and would appreciate your help! ![Smile :)](./images/smilies/icon_e_smile.gif)
Best wishes,
Yongjoo
![Smile :)](./images/smilies/icon_e_smile.gif)
Best wishes,
Yongjoo
-
- Posts: 1354
- Joined: Mon Oct 19, 2009 10:34 am
Re: classification (N-level ID) issue
If you have Stata then you could convert them to numeric variables using the encode command (see https://www.stata.com/help.cgi?encode).
Alternatively if you just open the .dta file in MLwiN then it will convert any string variables into numeric codes, with the old string used as the value label. You can then reexport the data from MLwiN for use in Stat-JR.
Alternatively if you just open the .dta file in MLwiN then it will convert any string variables into numeric codes, with the old string used as the value label. You can then reexport the data from MLwiN for use in Stat-JR.
-
- Posts: 45
- Joined: Tue Jan 10, 2017 3:36 am
Re: classification (N-level ID) issue
Thank you so much Chris! Both sound like excellent suggestions!
I just tried the first option with Stata encode command and Stat-JR started to recognize those variables finally! Then, I've got a couple follow-up questions.
First, if my original multilevel is a four-level (individual-household-psu- wider geographic area), then how many "classification" should I assign? Is it "four" like MOI or "three" as you mentioned in the earlier discussion?
Second, after assigning the number of classification, in terms of model specification, I am wondering whether I need to build the exactly same model as MOI (which did not include potential mediator variables), or it might be better to include more variables (i.e., mediator variables or anything that might provide relevant information to the overall imputation procedure?)
Thank you very much again!
Best wishes,
Yongjoo
I just tried the first option with Stata encode command and Stat-JR started to recognize those variables finally! Then, I've got a couple follow-up questions.
First, if my original multilevel is a four-level (individual-household-psu- wider geographic area), then how many "classification" should I assign? Is it "four" like MOI or "three" as you mentioned in the earlier discussion?
Second, after assigning the number of classification, in terms of model specification, I am wondering whether I need to build the exactly same model as MOI (which did not include potential mediator variables), or it might be better to include more variables (i.e., mediator variables or anything that might provide relevant information to the overall imputation procedure?)
Thank you very much again!
Best wishes,
Yongjoo
-
- Posts: 45
- Joined: Tue Jan 10, 2017 3:36 am
Re: classification (N-level ID) issue
Hello,
While trying to run Stat-JR, I've got an error message and would appreciate your supports!
1. Setting
- I've uploaded a dta file for Stat-JR.
- I chose "N-level" with "NLevelMod" option as my MOI is a four-level linear model.
- I set the highest level (level 2) as classification 1, second highest level (level 3) as classification 2, and second lowest level (level 2) as classification 3.
- When I run this, I've got an error message as below.
2. Error message
Traceback (most recent call last):
File "webtest.py", line 375, in go
File "C:\StatJR\packages\eStat.py", line 1196, in run
self.runcode(str(self.eng.outputs['modelcode.cpp'].content), self.vars[chainnum], self.data)
File "C:\StatJR\packages\eStat.py", line 832, in runcode
result = runcode(code, self.scode, locals, globals)
File "O:\repo\stat-jr\src\lib\EStat\Utils.py", line 141, in runcode
File "c:\Python27\lib\site-packages\weave\inline_tools.py", line 366, in inline
File "c:\Python27\lib\site-packages\weave\inline_tools.py", line 496, in compile_function
File "c:\Python27\lib\site-packages\weave\ext_tools.py", line 373, in compile
File "c:\Python27\lib\site-packages\weave\build_tools.py", line 279, in build_extension
File "c:\Python27\lib\site-packages\numpy\distutils\core.py", line 169, in setup
File "c:\Python27\lib\distutils\core.py", line 166, in setup
CompileError: error: Command "g++ -O2 -Wall -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x0900 -IC:\StatJR\src\lib\EStat\templates -IC:\StatJR\src\apps\tree\include -IC:\StatJR\src\apps\tree\include\scxx -IC:\StatJR\src\apps\tree\tree.exe\numpy\core\include -IC:\StatJR\src\apps\tree\include -IC:\StatJR\src\apps\tree\PC -c C:\StatJR\src\lib\EStat\templates\rng_simple.cpp -o c:\users\yok880\appdata\local\temp\scipy-yok880-_tddu8\python27_intermediate\compiler_e433b115c443362274443bf1b7e873b5\Release\statjr\src\lib\estat\templates\rng_simple.o -w -O3 -std=c++11" failed with exit status 1
Would appreciate your support!
Best wishes,
Yongjoo
While trying to run Stat-JR, I've got an error message and would appreciate your supports!
1. Setting
- I've uploaded a dta file for Stat-JR.
- I chose "N-level" with "NLevelMod" option as my MOI is a four-level linear model.
- I set the highest level (level 2) as classification 1, second highest level (level 3) as classification 2, and second lowest level (level 2) as classification 3.
- When I run this, I've got an error message as below.
2. Error message
Traceback (most recent call last):
File "webtest.py", line 375, in go
File "C:\StatJR\packages\eStat.py", line 1196, in run
self.runcode(str(self.eng.outputs['modelcode.cpp'].content), self.vars[chainnum], self.data)
File "C:\StatJR\packages\eStat.py", line 832, in runcode
result = runcode(code, self.scode, locals, globals)
File "O:\repo\stat-jr\src\lib\EStat\Utils.py", line 141, in runcode
File "c:\Python27\lib\site-packages\weave\inline_tools.py", line 366, in inline
File "c:\Python27\lib\site-packages\weave\inline_tools.py", line 496, in compile_function
File "c:\Python27\lib\site-packages\weave\ext_tools.py", line 373, in compile
File "c:\Python27\lib\site-packages\weave\build_tools.py", line 279, in build_extension
File "c:\Python27\lib\site-packages\numpy\distutils\core.py", line 169, in setup
File "c:\Python27\lib\distutils\core.py", line 166, in setup
CompileError: error: Command "g++ -O2 -Wall -DNPY_MINGW_USE_CUSTOM_MSVCR -D__MSVCRT_VERSION__=0x0900 -IC:\StatJR\src\lib\EStat\templates -IC:\StatJR\src\apps\tree\include -IC:\StatJR\src\apps\tree\include\scxx -IC:\StatJR\src\apps\tree\tree.exe\numpy\core\include -IC:\StatJR\src\apps\tree\include -IC:\StatJR\src\apps\tree\PC -c C:\StatJR\src\lib\EStat\templates\rng_simple.cpp -o c:\users\yok880\appdata\local\temp\scipy-yok880-_tddu8\python27_intermediate\compiler_e433b115c443362274443bf1b7e873b5\Release\statjr\src\lib\estat\templates\rng_simple.o -w -O3 -std=c++11" failed with exit status 1
Would appreciate your support!
Best wishes,
Yongjoo
-
- Posts: 1354
- Joined: Mon Oct 19, 2009 10:34 am
Re: classification (N-level ID) issue
Could you please check the black command window that initially opened when you loaded Stat-JR and let me know if there are any further messages reported by the compiler?
-
- Posts: 4
- Joined: Tue Oct 02, 2018 9:45 am
Re: classification (N-level ID) issue
Hi,
I have the same error message and when I check the black command window there are this kind of message:
….\python27_compiled\sc_c3d528436cdc971e035966e30b71f59b2.cpp: In function 'PyObject* compiled_func(PyObject*, PyObject*)':
….\python27_compiled\sc_c3d528436cdc971e035966e30b71f59b2.cpp:5527:49: error: 'mat_x1_5_2' was not declared in this scope
for (int k = 0; k < mat_x1_5_2.cols(); k++) {
^~~~~~~~~~
….\python27_compiled\sc_c3d528436cdc971e035966e30b71f59b2.cpp:5527:49: note: suggested alternative: 'mat_x1_5_1'
for (int k = 0; k < mat_x1_5_2.cols(); k++) {
Thank you for any help!
Rina
I have the same error message and when I check the black command window there are this kind of message:
….\python27_compiled\sc_c3d528436cdc971e035966e30b71f59b2.cpp: In function 'PyObject* compiled_func(PyObject*, PyObject*)':
….\python27_compiled\sc_c3d528436cdc971e035966e30b71f59b2.cpp:5527:49: error: 'mat_x1_5_2' was not declared in this scope
for (int k = 0; k < mat_x1_5_2.cols(); k++) {
^~~~~~~~~~
….\python27_compiled\sc_c3d528436cdc971e035966e30b71f59b2.cpp:5527:49: note: suggested alternative: 'mat_x1_5_1'
for (int k = 0; k < mat_x1_5_2.cols(); k++) {
Thank you for any help!
Rina
-
- Posts: 1354
- Joined: Mon Oct 19, 2009 10:34 am
Re: classification (N-level ID) issue
Could you let us know the structure of the model that you are trying to fit? Could you also confirm that any categorical variables in your data are numbered consecutively from zero?
-
- Posts: 4
- Joined: Tue Oct 02, 2018 9:45 am
Re: classification (N-level ID) issue
The following is the string input:
{'want2': 'No', 'numimpute': '10', 'bin1_5': 'Unordered', 'ncatsPOLITICAL': '3', 'imputefirst': '1000', 'MOIlevel': '2 levels', 'bin1_3': 'Binary', 'bin1_2': 'Binary', 'bin1_1': 'Normal', 'bin1_7': 'Normal', 'bin1_6': 'Normal', 'iterations': '250', 'bin1_4': 'Unordered', 'bin1_9': 'Normal', 'bin1_8': 'Normal', 'MOIslope': 'Yes', 'condmarg': 'Yes', 'ximp1_4_0': 'Cons', 'numlevs': 'Yes', 'burnin': '100', 'priors': 'Uniform', 'ximp1_1': 'Cons', 'ximp1_0': 'Cons', 'ximp1_2': 'Cons', 'ximp1_5': 'Cons', 'ximp1_7': 'Cons', 'ximp1_6': 'Cons', 'ximp1_3_1': 'Cons', 'ximp1_3_0': 'Cons', 'ximp1_4_1': 'Cons', 'ximp1_8': 'Cons', 'x2': 'Education:cat,UNIVERSALISM,SELFDIRECTION,POWER,CONSERVATION,Cons', 'L2ID': 'cntry', 'yimp1': 'genver,gndr,migration,Education,POLITICAL,UNIVERSALISM,SELFDIRECTION,POWER,CONSERVATION', 'ncatsEducation': '3', 'imputeevery': '50', 'MOIdist': 'Normal', 'y': 'trstplc', 'x': 'gndr:cat,migration:cat,Education:cat,Alter,POLITICAL,CPI2011,UNIVERSALISM,SELFDIRECTION,POWER,CONSERVATION,Cons'}
and yes all categorial are from 0.
Thanks for your help!
{'want2': 'No', 'numimpute': '10', 'bin1_5': 'Unordered', 'ncatsPOLITICAL': '3', 'imputefirst': '1000', 'MOIlevel': '2 levels', 'bin1_3': 'Binary', 'bin1_2': 'Binary', 'bin1_1': 'Normal', 'bin1_7': 'Normal', 'bin1_6': 'Normal', 'iterations': '250', 'bin1_4': 'Unordered', 'bin1_9': 'Normal', 'bin1_8': 'Normal', 'MOIslope': 'Yes', 'condmarg': 'Yes', 'ximp1_4_0': 'Cons', 'numlevs': 'Yes', 'burnin': '100', 'priors': 'Uniform', 'ximp1_1': 'Cons', 'ximp1_0': 'Cons', 'ximp1_2': 'Cons', 'ximp1_5': 'Cons', 'ximp1_7': 'Cons', 'ximp1_6': 'Cons', 'ximp1_3_1': 'Cons', 'ximp1_3_0': 'Cons', 'ximp1_4_1': 'Cons', 'ximp1_8': 'Cons', 'x2': 'Education:cat,UNIVERSALISM,SELFDIRECTION,POWER,CONSERVATION,Cons', 'L2ID': 'cntry', 'yimp1': 'genver,gndr,migration,Education,POLITICAL,UNIVERSALISM,SELFDIRECTION,POWER,CONSERVATION', 'ncatsEducation': '3', 'imputeevery': '50', 'MOIdist': 'Normal', 'y': 'trstplc', 'x': 'gndr:cat,migration:cat,Education:cat,Alter,POLITICAL,CPI2011,UNIVERSALISM,SELFDIRECTION,POWER,CONSERVATION,Cons'}
and yes all categorial are from 0.
Thanks for your help!