Reponse must have 3 or more levels










0















I am trying to perform a ordinal logistic regression using R, but I keep getting this error which says: response must have 3 or more levels. What does "response" mean in R? Tried searching on google but nothing is explained on the meaning of response in R. I am pasting the snapshot of the data I am trying to regress and the code I have written so far:



enter image description here



m <- polr(as.factor(Gender) ~ VeryUnsat + Unsat + Sat + VerySat, data = df, Hess=TRUE)
summary(m)
ctable <- coef(summary(m))
p <- pnorm(abs(ctable[, "t value"]), lower.tail = FALSE) * 2
ctable <- cbind(ctable, "p value" = p)
ci <- confint(m)
exp(coef(m))
exp(cbind(OR = coef(m), ci))`









share|improve this question

















  • 1





    "Response" is the outcome you're trying to model. Right now it looks like you have your formula backwards, as the response/outcome should be on the left-hand side of ~, where you currently have Gender.

    – Marius
    Nov 15 '18 at 3:34











  • So how do I fix this? Age has 3 levels, but not gender...

    – TotalGadha
    Nov 15 '18 at 3:38











  • Pls provide data, no pictures. Check ?dput.

    – vaettchen
    Nov 15 '18 at 3:46











  • I am new to this community, how do I provide my data here? It is in an excel file..

    – TotalGadha
    Nov 15 '18 at 3:47











  • What are you trying to model here? It looks like your response/outcome should be satisfaction, which has 4 levels. You need something like polr(Satisfaction ~ age + gender + other_predictors), but you may have to reshape your data so it's "long" and you have one row per observation first.

    – Marius
    Nov 15 '18 at 3:49















0















I am trying to perform a ordinal logistic regression using R, but I keep getting this error which says: response must have 3 or more levels. What does "response" mean in R? Tried searching on google but nothing is explained on the meaning of response in R. I am pasting the snapshot of the data I am trying to regress and the code I have written so far:



enter image description here



m <- polr(as.factor(Gender) ~ VeryUnsat + Unsat + Sat + VerySat, data = df, Hess=TRUE)
summary(m)
ctable <- coef(summary(m))
p <- pnorm(abs(ctable[, "t value"]), lower.tail = FALSE) * 2
ctable <- cbind(ctable, "p value" = p)
ci <- confint(m)
exp(coef(m))
exp(cbind(OR = coef(m), ci))`









share|improve this question

















  • 1





    "Response" is the outcome you're trying to model. Right now it looks like you have your formula backwards, as the response/outcome should be on the left-hand side of ~, where you currently have Gender.

    – Marius
    Nov 15 '18 at 3:34











  • So how do I fix this? Age has 3 levels, but not gender...

    – TotalGadha
    Nov 15 '18 at 3:38











  • Pls provide data, no pictures. Check ?dput.

    – vaettchen
    Nov 15 '18 at 3:46











  • I am new to this community, how do I provide my data here? It is in an excel file..

    – TotalGadha
    Nov 15 '18 at 3:47











  • What are you trying to model here? It looks like your response/outcome should be satisfaction, which has 4 levels. You need something like polr(Satisfaction ~ age + gender + other_predictors), but you may have to reshape your data so it's "long" and you have one row per observation first.

    – Marius
    Nov 15 '18 at 3:49













0












0








0








I am trying to perform a ordinal logistic regression using R, but I keep getting this error which says: response must have 3 or more levels. What does "response" mean in R? Tried searching on google but nothing is explained on the meaning of response in R. I am pasting the snapshot of the data I am trying to regress and the code I have written so far:



enter image description here



m <- polr(as.factor(Gender) ~ VeryUnsat + Unsat + Sat + VerySat, data = df, Hess=TRUE)
summary(m)
ctable <- coef(summary(m))
p <- pnorm(abs(ctable[, "t value"]), lower.tail = FALSE) * 2
ctable <- cbind(ctable, "p value" = p)
ci <- confint(m)
exp(coef(m))
exp(cbind(OR = coef(m), ci))`









share|improve this question














I am trying to perform a ordinal logistic regression using R, but I keep getting this error which says: response must have 3 or more levels. What does "response" mean in R? Tried searching on google but nothing is explained on the meaning of response in R. I am pasting the snapshot of the data I am trying to regress and the code I have written so far:



enter image description here



m <- polr(as.factor(Gender) ~ VeryUnsat + Unsat + Sat + VerySat, data = df, Hess=TRUE)
summary(m)
ctable <- coef(summary(m))
p <- pnorm(abs(ctable[, "t value"]), lower.tail = FALSE) * 2
ctable <- cbind(ctable, "p value" = p)
ci <- confint(m)
exp(coef(m))
exp(cbind(OR = coef(m), ci))`






r regression






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 15 '18 at 3:32









TotalGadhaTotalGadha

336




336







  • 1





    "Response" is the outcome you're trying to model. Right now it looks like you have your formula backwards, as the response/outcome should be on the left-hand side of ~, where you currently have Gender.

    – Marius
    Nov 15 '18 at 3:34











  • So how do I fix this? Age has 3 levels, but not gender...

    – TotalGadha
    Nov 15 '18 at 3:38











  • Pls provide data, no pictures. Check ?dput.

    – vaettchen
    Nov 15 '18 at 3:46











  • I am new to this community, how do I provide my data here? It is in an excel file..

    – TotalGadha
    Nov 15 '18 at 3:47











  • What are you trying to model here? It looks like your response/outcome should be satisfaction, which has 4 levels. You need something like polr(Satisfaction ~ age + gender + other_predictors), but you may have to reshape your data so it's "long" and you have one row per observation first.

    – Marius
    Nov 15 '18 at 3:49












  • 1





    "Response" is the outcome you're trying to model. Right now it looks like you have your formula backwards, as the response/outcome should be on the left-hand side of ~, where you currently have Gender.

    – Marius
    Nov 15 '18 at 3:34











  • So how do I fix this? Age has 3 levels, but not gender...

    – TotalGadha
    Nov 15 '18 at 3:38











  • Pls provide data, no pictures. Check ?dput.

    – vaettchen
    Nov 15 '18 at 3:46











  • I am new to this community, how do I provide my data here? It is in an excel file..

    – TotalGadha
    Nov 15 '18 at 3:47











  • What are you trying to model here? It looks like your response/outcome should be satisfaction, which has 4 levels. You need something like polr(Satisfaction ~ age + gender + other_predictors), but you may have to reshape your data so it's "long" and you have one row per observation first.

    – Marius
    Nov 15 '18 at 3:49







1




1





"Response" is the outcome you're trying to model. Right now it looks like you have your formula backwards, as the response/outcome should be on the left-hand side of ~, where you currently have Gender.

– Marius
Nov 15 '18 at 3:34





"Response" is the outcome you're trying to model. Right now it looks like you have your formula backwards, as the response/outcome should be on the left-hand side of ~, where you currently have Gender.

– Marius
Nov 15 '18 at 3:34













So how do I fix this? Age has 3 levels, but not gender...

– TotalGadha
Nov 15 '18 at 3:38





So how do I fix this? Age has 3 levels, but not gender...

– TotalGadha
Nov 15 '18 at 3:38













Pls provide data, no pictures. Check ?dput.

– vaettchen
Nov 15 '18 at 3:46





Pls provide data, no pictures. Check ?dput.

– vaettchen
Nov 15 '18 at 3:46













I am new to this community, how do I provide my data here? It is in an excel file..

– TotalGadha
Nov 15 '18 at 3:47





I am new to this community, how do I provide my data here? It is in an excel file..

– TotalGadha
Nov 15 '18 at 3:47













What are you trying to model here? It looks like your response/outcome should be satisfaction, which has 4 levels. You need something like polr(Satisfaction ~ age + gender + other_predictors), but you may have to reshape your data so it's "long" and you have one row per observation first.

– Marius
Nov 15 '18 at 3:49





What are you trying to model here? It looks like your response/outcome should be satisfaction, which has 4 levels. You need something like polr(Satisfaction ~ age + gender + other_predictors), but you may have to reshape your data so it's "long" and you have one row per observation first.

– Marius
Nov 15 '18 at 3:49












1 Answer
1






active

oldest

votes


















0














You should look at the example of polr method.
Just type ?polr in your command line in RStudio



You will see that your response variable is not well defined for what polr expects (unless I am misunderstanding what you try to do)



polr tries to model multilevel ordered variables such as Sat in the example.



I see two problems in your data:



  1. you have aggregated data, a count of how many samples have each level of satisfaction for each combination of age and gender.


  2. your response variable is splitted across different columns. Starting from the non-aggregated data you need to convert to a single variable with multiple possible values (VeryUnsat, Unsat, Sat, VerySat)


You may be able to use the aggregated data if the method allows to specify some weights to each combination (haven't checked the details of the method).






share|improve this answer






















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312036%2freponse-must-have-3-or-more-levels%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You should look at the example of polr method.
    Just type ?polr in your command line in RStudio



    You will see that your response variable is not well defined for what polr expects (unless I am misunderstanding what you try to do)



    polr tries to model multilevel ordered variables such as Sat in the example.



    I see two problems in your data:



    1. you have aggregated data, a count of how many samples have each level of satisfaction for each combination of age and gender.


    2. your response variable is splitted across different columns. Starting from the non-aggregated data you need to convert to a single variable with multiple possible values (VeryUnsat, Unsat, Sat, VerySat)


    You may be able to use the aggregated data if the method allows to specify some weights to each combination (haven't checked the details of the method).






    share|improve this answer



























      0














      You should look at the example of polr method.
      Just type ?polr in your command line in RStudio



      You will see that your response variable is not well defined for what polr expects (unless I am misunderstanding what you try to do)



      polr tries to model multilevel ordered variables such as Sat in the example.



      I see two problems in your data:



      1. you have aggregated data, a count of how many samples have each level of satisfaction for each combination of age and gender.


      2. your response variable is splitted across different columns. Starting from the non-aggregated data you need to convert to a single variable with multiple possible values (VeryUnsat, Unsat, Sat, VerySat)


      You may be able to use the aggregated data if the method allows to specify some weights to each combination (haven't checked the details of the method).






      share|improve this answer

























        0












        0








        0







        You should look at the example of polr method.
        Just type ?polr in your command line in RStudio



        You will see that your response variable is not well defined for what polr expects (unless I am misunderstanding what you try to do)



        polr tries to model multilevel ordered variables such as Sat in the example.



        I see two problems in your data:



        1. you have aggregated data, a count of how many samples have each level of satisfaction for each combination of age and gender.


        2. your response variable is splitted across different columns. Starting from the non-aggregated data you need to convert to a single variable with multiple possible values (VeryUnsat, Unsat, Sat, VerySat)


        You may be able to use the aggregated data if the method allows to specify some weights to each combination (haven't checked the details of the method).






        share|improve this answer













        You should look at the example of polr method.
        Just type ?polr in your command line in RStudio



        You will see that your response variable is not well defined for what polr expects (unless I am misunderstanding what you try to do)



        polr tries to model multilevel ordered variables such as Sat in the example.



        I see two problems in your data:



        1. you have aggregated data, a count of how many samples have each level of satisfaction for each combination of age and gender.


        2. your response variable is splitted across different columns. Starting from the non-aggregated data you need to convert to a single variable with multiple possible values (VeryUnsat, Unsat, Sat, VerySat)


        You may be able to use the aggregated data if the method allows to specify some weights to each combination (haven't checked the details of the method).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 15 '18 at 3:57









        PicarusPicarus

        5801722




        5801722





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312036%2freponse-must-have-3-or-more-levels%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            這個網誌中的熱門文章

            Barbados

            How to read a connectionString WITH PROVIDER in .NET Core?

            Node.js Script on GitHub Pages or Amazon S3