How do I use the model generated by the R package poLCA to classify new data as belonging to one of the classes?2019 Community Moderator ElectionHow to classify and cluster this time series dataWhat loss function does the 'multinomial' distribution with the gbm package in R use?How to automate left join of multiple data frames with single data frame one by one in RHow to cluster multiple time-series from one data frameHow to get the probability of belonging to clusters for k-means?R data frame create a new variable which corresponds to one of the existing onehow to use the ecospat.max.tss command in R?New to data Science. Which techniques best to use Large data set in insurance company?How to use cluster analysis with grouped data so one cluster may only have not more than one item from each group?Classification problem: custom minimization measure

Hostile work environment after whistle-blowing on coworker and our boss. What do I do?

Curses work by shouting - How to avoid collateral damage?

What would be the benefits of having both a state and local currencies?

How can I use the arrow sign in my bash prompt?

How will losing mobility of one hand affect my career as a programmer?

Tiptoe or tiphoof? Adjusting words to better fit fantasy races

quarter to five p.m

What is the intuitive meaning of having a linear relationship between the logs of two variables?

How to verify if g is a generator for p?

Can somebody explain Brexit in a few child-proof sentences?

Why "be dealt cards" rather than "be dealing cards"?

Can I convert a rim brake wheel to a disc brake wheel?

Using parameter substitution on a Bash array

Failed to fetch jessie backports repository

Time travel short story where a man arrives in the late 19th century in a time machine and then sends the machine back into the past

Displaying the order of the columns of a table

Select empty space and change color in vector

Is there a measurement for the vocal speed of a song?

The plural of 'stomach"

Greatest common substring

Is a roofing delivery truck likely to crack my driveway slab?

What's a natural way to say that someone works somewhere (for a job)?

How do I keep an essay about "feeling flat" from feeling flat?

Hide Select Output from T-SQL



How do I use the model generated by the R package poLCA to classify new data as belonging to one of the classes?



2019 Community Moderator ElectionHow to classify and cluster this time series dataWhat loss function does the 'multinomial' distribution with the gbm package in R use?How to automate left join of multiple data frames with single data frame one by one in RHow to cluster multiple time-series from one data frameHow to get the probability of belonging to clusters for k-means?R data frame create a new variable which corresponds to one of the existing onehow to use the ecospat.max.tss command in R?New to data Science. Which techniques best to use Large data set in insurance company?How to use cluster analysis with grouped data so one cluster may only have not more than one item from each group?Classification problem: custom minimization measure










1












$begingroup$


For example, in the election example from the documentation, if I create a new set of answers to the questions, how can I use the poLCA model to tell me what class (cluster) it's most likely to be in?



There doesn't appear to be a function to do this, though the model has a df within it that lists the probabilities of class membership for each value of each manifest variable. I'm tasked with converting some sql code that takes a second dataset and classifies the patients there as members of the clusters created from a first. Superficially this is a programming question. It seems like a function to do this would be a reasonable addition to the package. More deeply, if indeed there isn't such a function, it would become a question about how to use the table of probabilities to classify new data.



If readers aren't familiar with the R package poLCA, it's an LCA package that works with discrete/categorized data.



(full disclosure: I asked on cross-validated and a shorter version of this question was put on hold.)










share|improve this question











$endgroup$
















    1












    $begingroup$


    For example, in the election example from the documentation, if I create a new set of answers to the questions, how can I use the poLCA model to tell me what class (cluster) it's most likely to be in?



    There doesn't appear to be a function to do this, though the model has a df within it that lists the probabilities of class membership for each value of each manifest variable. I'm tasked with converting some sql code that takes a second dataset and classifies the patients there as members of the clusters created from a first. Superficially this is a programming question. It seems like a function to do this would be a reasonable addition to the package. More deeply, if indeed there isn't such a function, it would become a question about how to use the table of probabilities to classify new data.



    If readers aren't familiar with the R package poLCA, it's an LCA package that works with discrete/categorized data.



    (full disclosure: I asked on cross-validated and a shorter version of this question was put on hold.)










    share|improve this question











    $endgroup$














      1












      1








      1





      $begingroup$


      For example, in the election example from the documentation, if I create a new set of answers to the questions, how can I use the poLCA model to tell me what class (cluster) it's most likely to be in?



      There doesn't appear to be a function to do this, though the model has a df within it that lists the probabilities of class membership for each value of each manifest variable. I'm tasked with converting some sql code that takes a second dataset and classifies the patients there as members of the clusters created from a first. Superficially this is a programming question. It seems like a function to do this would be a reasonable addition to the package. More deeply, if indeed there isn't such a function, it would become a question about how to use the table of probabilities to classify new data.



      If readers aren't familiar with the R package poLCA, it's an LCA package that works with discrete/categorized data.



      (full disclosure: I asked on cross-validated and a shorter version of this question was put on hold.)










      share|improve this question











      $endgroup$




      For example, in the election example from the documentation, if I create a new set of answers to the questions, how can I use the poLCA model to tell me what class (cluster) it's most likely to be in?



      There doesn't appear to be a function to do this, though the model has a df within it that lists the probabilities of class membership for each value of each manifest variable. I'm tasked with converting some sql code that takes a second dataset and classifies the patients there as members of the clusters created from a first. Superficially this is a programming question. It seems like a function to do this would be a reasonable addition to the package. More deeply, if indeed there isn't such a function, it would become a question about how to use the table of probabilities to classify new data.



      If readers aren't familiar with the R package poLCA, it's an LCA package that works with discrete/categorized data.



      (full disclosure: I asked on cross-validated and a shorter version of this question was put on hold.)







      r clustering






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 20 at 17:21









      KT12

      648




      648










      asked Nov 2 '18 at 15:54









      ChrisRChrisR

      1066




      1066




















          3 Answers
          3






          active

          oldest

          votes


















          0












          $begingroup$

          Using carcinoma data available in the poLCA package and a 4 latent classes solution:



           library poLCA
          data(carcinoma)
          f <- cbind(A, B, C, D, E, F, G) ~ 1
          lc4 <- poLCA(f, carcinoma, nclass = 4)


          The following line give the classification in terms of predicted probabilities



           lc4$predclass


          They could be usefully binded to the original data for further visualizations or analyses



           carcinoma.predclass <- cbind(carcinoma, "Predicted LC" = lc4$predclass)
          head(carcinoma.predclass)


          You could have a new data frame with the same columns/variables used in the previous analysis.



          new.data <- data.frame(A=c(1,2,1), B=c(2,2,1), C=c(1,2,1), D=c(1,1,1), E=c(1,2,1), F=c(2,2,1), G=c(1,2,1))

          A B C D E F G
          1 1 2 1 1 1 2 1
          2 2 2 2 1 2 2 2
          3 1 1 1 1 1 1 1


          A simple method can be link the observed data patterns in the new data frame with the estimated latent class probabilities in the previous data. In fact, the first pattern has missing prediction because it wasn't in the training data.



          left_join(new.data, unique(carcinoma.predclass))

          Joining, by = c("A", "B", "C", "D", "E", "F", "G")
          A B C D E F G Predicted LC
          1 1 2 1 1 1 2 1 NA
          2 2 2 2 1 2 2 2 1
          3 1 1 1 1 1 1 1 4


          The best method is to use the posterior of poLCA. From the parameters estimated by the latent class model, this function calculates the probability that a specified pattern belongs to each latent class. This function can calculate posterior class membership probabilities for new data, observed or not in the training data.



          new.lc4.posterior <- poLCA.posterior(lc4, new.data)


          And bind the predicted Latent Classes (the classes which the highest posterior probability) to the new data.



          cbind(new.data, "Predicted LC" = apply(new.lc4.posterior,1, FUN=which.max))

          A B C D E F G Predicted LC
          1 1 2 1 1 1 2 1 2
          2 2 2 2 1 2 2 2 1
          3 1 1 1 1 1 1 1 4





          share|improve this answer











          $endgroup$












          • $begingroup$
            Thanks. I want to create the model from one dataset and apply it to another. I have working code now, that I'll publish shortly.
            $endgroup$
            – ChrisR
            Dec 5 '18 at 23:10






          • 1




            $begingroup$
            Was my answer useful!
            $endgroup$
            – paoloeusebi
            Dec 5 '18 at 23:15










          • $begingroup$
            The desire is to apply the lc4$probs to a second dataset. Still planning on posting detail.
            $endgroup$
            – ChrisR
            Dec 13 '18 at 18:48






          • 1




            $begingroup$
            I have updated the answer with a solution. Hope it helps!
            $endgroup$
            – paoloeusebi
            Dec 13 '18 at 23:19










          • $begingroup$
            Thanks, I must have confused lca_model$posterior, the data, with poLCA.posterior() the function.
            $endgroup$
            – ChrisR
            Jan 15 at 23:27


















          0












          $begingroup$

          Part of the data returned from poLCA tells what probability a particular value of a variable adds to a subject's probability of membership to each class. The appendix S1 to this paper walks through an example calculation. I have some R code that does this at github to implement this. Comments welcome.






          share|improve this answer









          $endgroup$




















            0












            $begingroup$

            As Paolo says, use the poLCA.poseterior() function. The data comes out in the same format as the lca_model$posterior structure returned by the poLCA function.



            library(polca.application)
            data(election)
            column_names <- c('MORALG', 'CARESG', 'KNOWG', 'LEADG', 'DISHONG',
            'INTELG', 'MORALB',
            'CARESB', 'KNOWB', 'LEADB', 'DISHONB', 'INTELB')
            election_matrix = as.matrix(mapply(as.numeric,election[,column_names]))
            election_matrix_no_na =election_matrix[apply(election_matrix, 1,
            function(x) all(is.finite(x)) ),]
            preds = poLCA.posterior(lc=lca_model, y=election_matrix_no_na)





            share|improve this answer











            $endgroup$












              Your Answer





              StackExchange.ifUsing("editor", function ()
              return StackExchange.using("mathjaxEditing", function ()
              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
              );
              );
              , "mathjax-editing");

              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "557"
              ;
              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: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              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%2fdatascience.stackexchange.com%2fquestions%2f40632%2fhow-do-i-use-the-model-generated-by-the-r-package-polca-to-classify-new-data-as%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0












              $begingroup$

              Using carcinoma data available in the poLCA package and a 4 latent classes solution:



               library poLCA
              data(carcinoma)
              f <- cbind(A, B, C, D, E, F, G) ~ 1
              lc4 <- poLCA(f, carcinoma, nclass = 4)


              The following line give the classification in terms of predicted probabilities



               lc4$predclass


              They could be usefully binded to the original data for further visualizations or analyses



               carcinoma.predclass <- cbind(carcinoma, "Predicted LC" = lc4$predclass)
              head(carcinoma.predclass)


              You could have a new data frame with the same columns/variables used in the previous analysis.



              new.data <- data.frame(A=c(1,2,1), B=c(2,2,1), C=c(1,2,1), D=c(1,1,1), E=c(1,2,1), F=c(2,2,1), G=c(1,2,1))

              A B C D E F G
              1 1 2 1 1 1 2 1
              2 2 2 2 1 2 2 2
              3 1 1 1 1 1 1 1


              A simple method can be link the observed data patterns in the new data frame with the estimated latent class probabilities in the previous data. In fact, the first pattern has missing prediction because it wasn't in the training data.



              left_join(new.data, unique(carcinoma.predclass))

              Joining, by = c("A", "B", "C", "D", "E", "F", "G")
              A B C D E F G Predicted LC
              1 1 2 1 1 1 2 1 NA
              2 2 2 2 1 2 2 2 1
              3 1 1 1 1 1 1 1 4


              The best method is to use the posterior of poLCA. From the parameters estimated by the latent class model, this function calculates the probability that a specified pattern belongs to each latent class. This function can calculate posterior class membership probabilities for new data, observed or not in the training data.



              new.lc4.posterior <- poLCA.posterior(lc4, new.data)


              And bind the predicted Latent Classes (the classes which the highest posterior probability) to the new data.



              cbind(new.data, "Predicted LC" = apply(new.lc4.posterior,1, FUN=which.max))

              A B C D E F G Predicted LC
              1 1 2 1 1 1 2 1 2
              2 2 2 2 1 2 2 2 1
              3 1 1 1 1 1 1 1 4





              share|improve this answer











              $endgroup$












              • $begingroup$
                Thanks. I want to create the model from one dataset and apply it to another. I have working code now, that I'll publish shortly.
                $endgroup$
                – ChrisR
                Dec 5 '18 at 23:10






              • 1




                $begingroup$
                Was my answer useful!
                $endgroup$
                – paoloeusebi
                Dec 5 '18 at 23:15










              • $begingroup$
                The desire is to apply the lc4$probs to a second dataset. Still planning on posting detail.
                $endgroup$
                – ChrisR
                Dec 13 '18 at 18:48






              • 1




                $begingroup$
                I have updated the answer with a solution. Hope it helps!
                $endgroup$
                – paoloeusebi
                Dec 13 '18 at 23:19










              • $begingroup$
                Thanks, I must have confused lca_model$posterior, the data, with poLCA.posterior() the function.
                $endgroup$
                – ChrisR
                Jan 15 at 23:27















              0












              $begingroup$

              Using carcinoma data available in the poLCA package and a 4 latent classes solution:



               library poLCA
              data(carcinoma)
              f <- cbind(A, B, C, D, E, F, G) ~ 1
              lc4 <- poLCA(f, carcinoma, nclass = 4)


              The following line give the classification in terms of predicted probabilities



               lc4$predclass


              They could be usefully binded to the original data for further visualizations or analyses



               carcinoma.predclass <- cbind(carcinoma, "Predicted LC" = lc4$predclass)
              head(carcinoma.predclass)


              You could have a new data frame with the same columns/variables used in the previous analysis.



              new.data <- data.frame(A=c(1,2,1), B=c(2,2,1), C=c(1,2,1), D=c(1,1,1), E=c(1,2,1), F=c(2,2,1), G=c(1,2,1))

              A B C D E F G
              1 1 2 1 1 1 2 1
              2 2 2 2 1 2 2 2
              3 1 1 1 1 1 1 1


              A simple method can be link the observed data patterns in the new data frame with the estimated latent class probabilities in the previous data. In fact, the first pattern has missing prediction because it wasn't in the training data.



              left_join(new.data, unique(carcinoma.predclass))

              Joining, by = c("A", "B", "C", "D", "E", "F", "G")
              A B C D E F G Predicted LC
              1 1 2 1 1 1 2 1 NA
              2 2 2 2 1 2 2 2 1
              3 1 1 1 1 1 1 1 4


              The best method is to use the posterior of poLCA. From the parameters estimated by the latent class model, this function calculates the probability that a specified pattern belongs to each latent class. This function can calculate posterior class membership probabilities for new data, observed or not in the training data.



              new.lc4.posterior <- poLCA.posterior(lc4, new.data)


              And bind the predicted Latent Classes (the classes which the highest posterior probability) to the new data.



              cbind(new.data, "Predicted LC" = apply(new.lc4.posterior,1, FUN=which.max))

              A B C D E F G Predicted LC
              1 1 2 1 1 1 2 1 2
              2 2 2 2 1 2 2 2 1
              3 1 1 1 1 1 1 1 4





              share|improve this answer











              $endgroup$












              • $begingroup$
                Thanks. I want to create the model from one dataset and apply it to another. I have working code now, that I'll publish shortly.
                $endgroup$
                – ChrisR
                Dec 5 '18 at 23:10






              • 1




                $begingroup$
                Was my answer useful!
                $endgroup$
                – paoloeusebi
                Dec 5 '18 at 23:15










              • $begingroup$
                The desire is to apply the lc4$probs to a second dataset. Still planning on posting detail.
                $endgroup$
                – ChrisR
                Dec 13 '18 at 18:48






              • 1




                $begingroup$
                I have updated the answer with a solution. Hope it helps!
                $endgroup$
                – paoloeusebi
                Dec 13 '18 at 23:19










              • $begingroup$
                Thanks, I must have confused lca_model$posterior, the data, with poLCA.posterior() the function.
                $endgroup$
                – ChrisR
                Jan 15 at 23:27













              0












              0








              0





              $begingroup$

              Using carcinoma data available in the poLCA package and a 4 latent classes solution:



               library poLCA
              data(carcinoma)
              f <- cbind(A, B, C, D, E, F, G) ~ 1
              lc4 <- poLCA(f, carcinoma, nclass = 4)


              The following line give the classification in terms of predicted probabilities



               lc4$predclass


              They could be usefully binded to the original data for further visualizations or analyses



               carcinoma.predclass <- cbind(carcinoma, "Predicted LC" = lc4$predclass)
              head(carcinoma.predclass)


              You could have a new data frame with the same columns/variables used in the previous analysis.



              new.data <- data.frame(A=c(1,2,1), B=c(2,2,1), C=c(1,2,1), D=c(1,1,1), E=c(1,2,1), F=c(2,2,1), G=c(1,2,1))

              A B C D E F G
              1 1 2 1 1 1 2 1
              2 2 2 2 1 2 2 2
              3 1 1 1 1 1 1 1


              A simple method can be link the observed data patterns in the new data frame with the estimated latent class probabilities in the previous data. In fact, the first pattern has missing prediction because it wasn't in the training data.



              left_join(new.data, unique(carcinoma.predclass))

              Joining, by = c("A", "B", "C", "D", "E", "F", "G")
              A B C D E F G Predicted LC
              1 1 2 1 1 1 2 1 NA
              2 2 2 2 1 2 2 2 1
              3 1 1 1 1 1 1 1 4


              The best method is to use the posterior of poLCA. From the parameters estimated by the latent class model, this function calculates the probability that a specified pattern belongs to each latent class. This function can calculate posterior class membership probabilities for new data, observed or not in the training data.



              new.lc4.posterior <- poLCA.posterior(lc4, new.data)


              And bind the predicted Latent Classes (the classes which the highest posterior probability) to the new data.



              cbind(new.data, "Predicted LC" = apply(new.lc4.posterior,1, FUN=which.max))

              A B C D E F G Predicted LC
              1 1 2 1 1 1 2 1 2
              2 2 2 2 1 2 2 2 1
              3 1 1 1 1 1 1 1 4





              share|improve this answer











              $endgroup$



              Using carcinoma data available in the poLCA package and a 4 latent classes solution:



               library poLCA
              data(carcinoma)
              f <- cbind(A, B, C, D, E, F, G) ~ 1
              lc4 <- poLCA(f, carcinoma, nclass = 4)


              The following line give the classification in terms of predicted probabilities



               lc4$predclass


              They could be usefully binded to the original data for further visualizations or analyses



               carcinoma.predclass <- cbind(carcinoma, "Predicted LC" = lc4$predclass)
              head(carcinoma.predclass)


              You could have a new data frame with the same columns/variables used in the previous analysis.



              new.data <- data.frame(A=c(1,2,1), B=c(2,2,1), C=c(1,2,1), D=c(1,1,1), E=c(1,2,1), F=c(2,2,1), G=c(1,2,1))

              A B C D E F G
              1 1 2 1 1 1 2 1
              2 2 2 2 1 2 2 2
              3 1 1 1 1 1 1 1


              A simple method can be link the observed data patterns in the new data frame with the estimated latent class probabilities in the previous data. In fact, the first pattern has missing prediction because it wasn't in the training data.



              left_join(new.data, unique(carcinoma.predclass))

              Joining, by = c("A", "B", "C", "D", "E", "F", "G")
              A B C D E F G Predicted LC
              1 1 2 1 1 1 2 1 NA
              2 2 2 2 1 2 2 2 1
              3 1 1 1 1 1 1 1 4


              The best method is to use the posterior of poLCA. From the parameters estimated by the latent class model, this function calculates the probability that a specified pattern belongs to each latent class. This function can calculate posterior class membership probabilities for new data, observed or not in the training data.



              new.lc4.posterior <- poLCA.posterior(lc4, new.data)


              And bind the predicted Latent Classes (the classes which the highest posterior probability) to the new data.



              cbind(new.data, "Predicted LC" = apply(new.lc4.posterior,1, FUN=which.max))

              A B C D E F G Predicted LC
              1 1 2 1 1 1 2 1 2
              2 2 2 2 1 2 2 2 1
              3 1 1 1 1 1 1 1 4






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Dec 15 '18 at 9:49

























              answered Nov 2 '18 at 22:43









              paoloeusebipaoloeusebi

              3266




              3266











              • $begingroup$
                Thanks. I want to create the model from one dataset and apply it to another. I have working code now, that I'll publish shortly.
                $endgroup$
                – ChrisR
                Dec 5 '18 at 23:10






              • 1




                $begingroup$
                Was my answer useful!
                $endgroup$
                – paoloeusebi
                Dec 5 '18 at 23:15










              • $begingroup$
                The desire is to apply the lc4$probs to a second dataset. Still planning on posting detail.
                $endgroup$
                – ChrisR
                Dec 13 '18 at 18:48






              • 1




                $begingroup$
                I have updated the answer with a solution. Hope it helps!
                $endgroup$
                – paoloeusebi
                Dec 13 '18 at 23:19










              • $begingroup$
                Thanks, I must have confused lca_model$posterior, the data, with poLCA.posterior() the function.
                $endgroup$
                – ChrisR
                Jan 15 at 23:27
















              • $begingroup$
                Thanks. I want to create the model from one dataset and apply it to another. I have working code now, that I'll publish shortly.
                $endgroup$
                – ChrisR
                Dec 5 '18 at 23:10






              • 1




                $begingroup$
                Was my answer useful!
                $endgroup$
                – paoloeusebi
                Dec 5 '18 at 23:15










              • $begingroup$
                The desire is to apply the lc4$probs to a second dataset. Still planning on posting detail.
                $endgroup$
                – ChrisR
                Dec 13 '18 at 18:48






              • 1




                $begingroup$
                I have updated the answer with a solution. Hope it helps!
                $endgroup$
                – paoloeusebi
                Dec 13 '18 at 23:19










              • $begingroup$
                Thanks, I must have confused lca_model$posterior, the data, with poLCA.posterior() the function.
                $endgroup$
                – ChrisR
                Jan 15 at 23:27















              $begingroup$
              Thanks. I want to create the model from one dataset and apply it to another. I have working code now, that I'll publish shortly.
              $endgroup$
              – ChrisR
              Dec 5 '18 at 23:10




              $begingroup$
              Thanks. I want to create the model from one dataset and apply it to another. I have working code now, that I'll publish shortly.
              $endgroup$
              – ChrisR
              Dec 5 '18 at 23:10




              1




              1




              $begingroup$
              Was my answer useful!
              $endgroup$
              – paoloeusebi
              Dec 5 '18 at 23:15




              $begingroup$
              Was my answer useful!
              $endgroup$
              – paoloeusebi
              Dec 5 '18 at 23:15












              $begingroup$
              The desire is to apply the lc4$probs to a second dataset. Still planning on posting detail.
              $endgroup$
              – ChrisR
              Dec 13 '18 at 18:48




              $begingroup$
              The desire is to apply the lc4$probs to a second dataset. Still planning on posting detail.
              $endgroup$
              – ChrisR
              Dec 13 '18 at 18:48




              1




              1




              $begingroup$
              I have updated the answer with a solution. Hope it helps!
              $endgroup$
              – paoloeusebi
              Dec 13 '18 at 23:19




              $begingroup$
              I have updated the answer with a solution. Hope it helps!
              $endgroup$
              – paoloeusebi
              Dec 13 '18 at 23:19












              $begingroup$
              Thanks, I must have confused lca_model$posterior, the data, with poLCA.posterior() the function.
              $endgroup$
              – ChrisR
              Jan 15 at 23:27




              $begingroup$
              Thanks, I must have confused lca_model$posterior, the data, with poLCA.posterior() the function.
              $endgroup$
              – ChrisR
              Jan 15 at 23:27











              0












              $begingroup$

              Part of the data returned from poLCA tells what probability a particular value of a variable adds to a subject's probability of membership to each class. The appendix S1 to this paper walks through an example calculation. I have some R code that does this at github to implement this. Comments welcome.






              share|improve this answer









              $endgroup$

















                0












                $begingroup$

                Part of the data returned from poLCA tells what probability a particular value of a variable adds to a subject's probability of membership to each class. The appendix S1 to this paper walks through an example calculation. I have some R code that does this at github to implement this. Comments welcome.






                share|improve this answer









                $endgroup$















                  0












                  0








                  0





                  $begingroup$

                  Part of the data returned from poLCA tells what probability a particular value of a variable adds to a subject's probability of membership to each class. The appendix S1 to this paper walks through an example calculation. I have some R code that does this at github to implement this. Comments welcome.






                  share|improve this answer









                  $endgroup$



                  Part of the data returned from poLCA tells what probability a particular value of a variable adds to a subject's probability of membership to each class. The appendix S1 to this paper walks through an example calculation. I have some R code that does this at github to implement this. Comments welcome.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 19 '18 at 23:56









                  ChrisRChrisR

                  1066




                  1066





















                      0












                      $begingroup$

                      As Paolo says, use the poLCA.poseterior() function. The data comes out in the same format as the lca_model$posterior structure returned by the poLCA function.



                      library(polca.application)
                      data(election)
                      column_names <- c('MORALG', 'CARESG', 'KNOWG', 'LEADG', 'DISHONG',
                      'INTELG', 'MORALB',
                      'CARESB', 'KNOWB', 'LEADB', 'DISHONB', 'INTELB')
                      election_matrix = as.matrix(mapply(as.numeric,election[,column_names]))
                      election_matrix_no_na =election_matrix[apply(election_matrix, 1,
                      function(x) all(is.finite(x)) ),]
                      preds = poLCA.posterior(lc=lca_model, y=election_matrix_no_na)





                      share|improve this answer











                      $endgroup$

















                        0












                        $begingroup$

                        As Paolo says, use the poLCA.poseterior() function. The data comes out in the same format as the lca_model$posterior structure returned by the poLCA function.



                        library(polca.application)
                        data(election)
                        column_names <- c('MORALG', 'CARESG', 'KNOWG', 'LEADG', 'DISHONG',
                        'INTELG', 'MORALB',
                        'CARESB', 'KNOWB', 'LEADB', 'DISHONB', 'INTELB')
                        election_matrix = as.matrix(mapply(as.numeric,election[,column_names]))
                        election_matrix_no_na =election_matrix[apply(election_matrix, 1,
                        function(x) all(is.finite(x)) ),]
                        preds = poLCA.posterior(lc=lca_model, y=election_matrix_no_na)





                        share|improve this answer











                        $endgroup$















                          0












                          0








                          0





                          $begingroup$

                          As Paolo says, use the poLCA.poseterior() function. The data comes out in the same format as the lca_model$posterior structure returned by the poLCA function.



                          library(polca.application)
                          data(election)
                          column_names <- c('MORALG', 'CARESG', 'KNOWG', 'LEADG', 'DISHONG',
                          'INTELG', 'MORALB',
                          'CARESB', 'KNOWB', 'LEADB', 'DISHONB', 'INTELB')
                          election_matrix = as.matrix(mapply(as.numeric,election[,column_names]))
                          election_matrix_no_na =election_matrix[apply(election_matrix, 1,
                          function(x) all(is.finite(x)) ),]
                          preds = poLCA.posterior(lc=lca_model, y=election_matrix_no_na)





                          share|improve this answer











                          $endgroup$



                          As Paolo says, use the poLCA.poseterior() function. The data comes out in the same format as the lca_model$posterior structure returned by the poLCA function.



                          library(polca.application)
                          data(election)
                          column_names <- c('MORALG', 'CARESG', 'KNOWG', 'LEADG', 'DISHONG',
                          'INTELG', 'MORALB',
                          'CARESB', 'KNOWB', 'LEADB', 'DISHONB', 'INTELB')
                          election_matrix = as.matrix(mapply(as.numeric,election[,column_names]))
                          election_matrix_no_na =election_matrix[apply(election_matrix, 1,
                          function(x) all(is.finite(x)) ),]
                          preds = poLCA.posterior(lc=lca_model, y=election_matrix_no_na)






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Jan 15 at 23:39

























                          answered Jan 15 at 23:25









                          ChrisRChrisR

                          1066




                          1066



























                              draft saved

                              draft discarded
















































                              Thanks for contributing an answer to Data Science Stack Exchange!


                              • 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.

                              Use MathJax to format equations. MathJax reference.


                              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%2fdatascience.stackexchange.com%2fquestions%2f40632%2fhow-do-i-use-the-model-generated-by-the-r-package-polca-to-classify-new-data-as%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







                              Popular posts from this blog

                              Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

                              Tähtien Talli Jäsenet | Lähteet | NavigointivalikkoSuomen Hippos – Tähtien Talli

                              Do these cracks on my tires look bad? The Next CEO of Stack OverflowDry rot tire should I replace?Having to replace tiresFishtailed so easily? Bad tires? ABS?Filling the tires with something other than air, to avoid puncture hassles?Used Michelin tires safe to install?Do these tyre cracks necessitate replacement?Rumbling noise: tires or mechanicalIs it possible to fix noisy feathered tires?Are bad winter tires still better than summer tires in winter?Torque converter failure - Related to replacing only 2 tires?Why use snow tires on all 4 wheels on 2-wheel-drive cars?