Page 1 of 1

Some levels in 'outcomeOrdered' do not exist in 'coding' for model component

Posted: 01 May 2021, 06:15
by infiniteugi
I got an error message like, "Some levels in 'outcomeOrdered' do not exist in 'coding' for model component "Ind_PT01" !

My code is written as:

Code: Select all

ol_PT01 = list(outcomeOrdered=PT01, 
                 V=zeta_PT01*LV_tl, 
                 tau=c(tau_PT01_1, tau_PT01_2, tau_PT01_3, tau_PT01_4),
                 rows=((PT01!=-99) & (Exp==1)),
                 componentName  = "Ind_PT01")
Note:
Variable PT01 has the following values: [-99, 1, 2, 3, 4, 5], and -99 should be read N/A.

Could anyone help me resolve this error?

Re: Some levels in 'outcomeOrdered' do not exist in 'coding' for model component

Posted: 05 May 2021, 20:18
by dpalma
Hi,

First, I would recommend updating to Apollo v0.2.5. This version is not yet on CRAN, but you can download it from http://www.apollochoicemodelling.com/code.html . Note that you need to download the appropriate file for your operating system.

If you are using RStudio, you install this file simply by selecting Tool > Install Packages... in the menu bar, and then selecting Install from: Package Archive File, and select the file you downloaded.

If you are not using RStudio, then you can run the following code:

Code: Select all

install.packages("C:/path/to/file/apollo_0.2.5.zip", repos=NULL)
Where you need to change "C:/path/to/file/apollo_0.2.5.zip" to the appropriate path to the downloaded file.

Please let us know if that doesn't solve the issue.

Cheers
David

Re: Some levels in 'outcomeOrdered' do not exist in 'coding' for model component

Posted: 10 Sep 2021, 08:42
by janak12_jp
Hii!!

I came across the same error. Updated the Apollo to v0.2.5. But the same error is occurring.

Re: Some levels in 'outcomeOrdered' do not exist in 'coding' for model component

Posted: 10 Sep 2021, 10:12
by dpalma
Hi,

Does the error only happens when using multiple cores? If it does, then could you share your code and data so we can look at the problem in more detail? If you don't want to post your code or data in the forum, you can email it to me to D.Palma [at] leeds.ac.uk . We will treat the data confidentially and delete it after solving the issue.

If the problem happens when running on a single core, then I'd recommend checking your data. It may be that one level of the ordered outcome is never chosen in your data.

Cheers
David

Re: Some levels in 'outcomeOrdered' do not exist in 'coding' for model component

Posted: 10 Sep 2021, 10:43
by janak12_jp
The problem occurs on single as well as multiple cores. I have mailed the code as well as my data to your mail ID since it is a part of my research.

Thank you!

Re: Some levels in 'outcomeOrdered' do not exist in 'coding' for model component

Posted: 10 Sep 2021, 19:25
by dpalma
Hi,

Using ordered logit is a bit tricky, as it requires very careful coding, making sure that all the inputs are consistent. Things you should look for:
  • Make sure that you are using the correct number of thresholds for each dependant variable. You should provide as many threshold parameters as OBSERVED number of levels minus one. Keep in mind that you cannot estimate thresholds for levels not observed (i.e. chosen) in your data. For example, imagine your dependant variable is a 5-point Likert scale, but no one chose level 1. So your dependant variable contains values 2, 3, 4 and 5. Then, you will only need three thresholds, as levels 1 and two become the new lower level.
  • If the levels of your dependant variable are not 1, 2, 3, ... , then you need to provide an explicit "coding" setting. Continuing with the example before, where no one chose level 1, your coding is no longer standard (it is 2 to 5 instead of 1 to 5). Therefore, you will need to provide the "coding" setting. See the example at the end.
  • Make sure to exclude unnecessary rows and those with missing data. It is common to exclude some rows from the ordered logit likelihood. For example, some observations (i.e. rows) may have missing data, or maybe you only want to keep the first row of each individual (as it is often done when using LV associated to each individual, not each observation). To do this, you can use the setting "rows" to tell the model which lines to consider. You need to indicate a condition that is TRUE for every row of the data that you want to be considered.
So, let's imagine you have a dependant variable "y" on a Likert scale from 1 to 5, but only levels 2 to 5 are actually observed in the data. Also, variable "y" can take the value 0 if the data is missing. You would code this model as follows:

Code: Select all

ol_settings= list(outcomeOrdered = y,
                  V      = zeta*LV,
                  tau    = c(tau1, tau2, tau3), # only three thresholds are needed as there are only four different observed levels
                  coding = c(2,3,4,5), # there are only four levels: 2, 3, 4 and 5
                  rows   = y!=0) # ignore lines where the dependant is equal to zero
Hope this helps.

Cheers
David

Re: Some levels in 'outcomeOrdered' do not exist in 'coding' for model component

Posted: 11 Sep 2021, 10:40
by janak12_jp
Thank you Dr David for posting reply.

The issue is resolved with minor improvement in what you have suggested regarding "coding" in ol_settings. I need to make sure that the levels should start from 1 only, even if none of the respondents in my data have selected 1. So in that case, if my latent indicator has four levels- 2, 3, 4 and 5, then I need to convert them into 1, 2, 3 and 4 respectively in my data. So my coding will remain c(1, 2, 3, 4) in ol_settings instead of c(2, 3, 4, 5). Then we are good to go!!

Re: Some levels in 'outcomeOrdered' do not exist in 'coding' for model component

Posted: 11 Sep 2021, 15:43
by dpalma
Hi,

Yes, if your dependant variable "y" takes values 2, 3, 4 and 5, you can either use coding=c(2,3,4,5), or you can simply transform it before running the model as y = y-1, and then you don't need to specify "coding".

The "coding" setting is particularly useful when the levels of the dependant variable are not numeric, for example "low", "medium" and "high".

Cheers
David

Re: Some levels in 'outcomeOrdered' do not exist in 'coding' for model component

Posted: 24 Nov 2021, 10:20
by hamiltonconnie
Your question help me too) thanks!