Fix variance components in sommer's mmer2?










1















When fitting a model with mmer2() of the sommer package - is it possible to fix variance components to a certain value similar to what we can do e.g. with the PARMS statement in SAS or the G.param and R.param arguments in ASReml-R v3?



I am specifically interested in fixing individual components irrespective of whether they are on the G-side or R-side of my mixed model.










share|improve this question


























    1















    When fitting a model with mmer2() of the sommer package - is it possible to fix variance components to a certain value similar to what we can do e.g. with the PARMS statement in SAS or the G.param and R.param arguments in ASReml-R v3?



    I am specifically interested in fixing individual components irrespective of whether they are on the G-side or R-side of my mixed model.










    share|improve this question
























      1












      1








      1








      When fitting a model with mmer2() of the sommer package - is it possible to fix variance components to a certain value similar to what we can do e.g. with the PARMS statement in SAS or the G.param and R.param arguments in ASReml-R v3?



      I am specifically interested in fixing individual components irrespective of whether they are on the G-side or R-side of my mixed model.










      share|improve this question














      When fitting a model with mmer2() of the sommer package - is it possible to fix variance components to a certain value similar to what we can do e.g. with the PARMS statement in SAS or the G.param and R.param arguments in ASReml-R v3?



      I am specifically interested in fixing individual components irrespective of whether they are on the G-side or R-side of my mixed model.







      r mixed-models






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 15:11









      Paul SchmidtPaul Schmidt

      525




      525






















          1 Answer
          1






          active

          oldest

          votes


















          1














          If you have sommer >= 3.7 forcing specific variance or covariance components can be done using the Gt (initial values) and Gtc (contraints) arguments from the vs() function that is used to specify the variance model for a random effect.



          For example assume you fit the following multivariate mixed model for two traits:



          library(sommer)
          data(DT_cpdata)
          #### create the variance-covariance matrix for id levels
          A <- A.mat(GT) # additive relationship matrix
          D <- D.mat(GT) # additive relationship matrix
          #### look at the data and fit the model
          DT$idd <- DT$id
          head(DT)
          ans.m <- mmer(cbind(Yield,color)~1,
          random=~ vs(id, Gu=A)
          + vs(Rowf,Gtc=diag(2)),
          rcov=~ vs(units),
          data=DT)


          In this model there's 2 random effects (id and Rowf) and a residual term for units. By default an unstructured variance model is fitted (i.e. units and id) but you can see how for Rowf the Gtc argument is a constraint matrix that makes a diagonal model for Rowf:



          > diag(2)
          [,1] [,2]
          [1,] 1 0
          [2,] 0 1


          which follows the rules:
          0: not to be estimated
          1: estimated and constrained to be positive
          2: estimated and unconstrained
          3: fixed variance-covariance component provided in Gt



          After that is easy to see that if you want to force certain variance components you have to provide initial values (Gt argument) and specify a constraint matrix with values 3's (the function fixm() can creates such matrix).



          ans.mf <- mmer(cbind(Yield,color)~1,
          random=~ vs(id, Gu=A, Gt=ans.m$sigma_scaled$id,Gtc=fixm(2))
          + vs(Rowf,Gt=ans.m$sigma_scaled$Rowf, Gtc=fixm(2))
          + vs(idd, Gu=D),
          rcov=~ vs(units, Gt=ans.m$sigma_scaled$units, Gtc=fixm(2)),
          data=DT)

          ans.m$sigma
          ans.mf$sigma


          If you check the results you can see that you have forced the variance components for id, Rowf and units and estimated properly the components for idd.






          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%2f53303311%2ffix-variance-components-in-sommers-mmer2%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









            1














            If you have sommer >= 3.7 forcing specific variance or covariance components can be done using the Gt (initial values) and Gtc (contraints) arguments from the vs() function that is used to specify the variance model for a random effect.



            For example assume you fit the following multivariate mixed model for two traits:



            library(sommer)
            data(DT_cpdata)
            #### create the variance-covariance matrix for id levels
            A <- A.mat(GT) # additive relationship matrix
            D <- D.mat(GT) # additive relationship matrix
            #### look at the data and fit the model
            DT$idd <- DT$id
            head(DT)
            ans.m <- mmer(cbind(Yield,color)~1,
            random=~ vs(id, Gu=A)
            + vs(Rowf,Gtc=diag(2)),
            rcov=~ vs(units),
            data=DT)


            In this model there's 2 random effects (id and Rowf) and a residual term for units. By default an unstructured variance model is fitted (i.e. units and id) but you can see how for Rowf the Gtc argument is a constraint matrix that makes a diagonal model for Rowf:



            > diag(2)
            [,1] [,2]
            [1,] 1 0
            [2,] 0 1


            which follows the rules:
            0: not to be estimated
            1: estimated and constrained to be positive
            2: estimated and unconstrained
            3: fixed variance-covariance component provided in Gt



            After that is easy to see that if you want to force certain variance components you have to provide initial values (Gt argument) and specify a constraint matrix with values 3's (the function fixm() can creates such matrix).



            ans.mf <- mmer(cbind(Yield,color)~1,
            random=~ vs(id, Gu=A, Gt=ans.m$sigma_scaled$id,Gtc=fixm(2))
            + vs(Rowf,Gt=ans.m$sigma_scaled$Rowf, Gtc=fixm(2))
            + vs(idd, Gu=D),
            rcov=~ vs(units, Gt=ans.m$sigma_scaled$units, Gtc=fixm(2)),
            data=DT)

            ans.m$sigma
            ans.mf$sigma


            If you check the results you can see that you have forced the variance components for id, Rowf and units and estimated properly the components for idd.






            share|improve this answer



























              1














              If you have sommer >= 3.7 forcing specific variance or covariance components can be done using the Gt (initial values) and Gtc (contraints) arguments from the vs() function that is used to specify the variance model for a random effect.



              For example assume you fit the following multivariate mixed model for two traits:



              library(sommer)
              data(DT_cpdata)
              #### create the variance-covariance matrix for id levels
              A <- A.mat(GT) # additive relationship matrix
              D <- D.mat(GT) # additive relationship matrix
              #### look at the data and fit the model
              DT$idd <- DT$id
              head(DT)
              ans.m <- mmer(cbind(Yield,color)~1,
              random=~ vs(id, Gu=A)
              + vs(Rowf,Gtc=diag(2)),
              rcov=~ vs(units),
              data=DT)


              In this model there's 2 random effects (id and Rowf) and a residual term for units. By default an unstructured variance model is fitted (i.e. units and id) but you can see how for Rowf the Gtc argument is a constraint matrix that makes a diagonal model for Rowf:



              > diag(2)
              [,1] [,2]
              [1,] 1 0
              [2,] 0 1


              which follows the rules:
              0: not to be estimated
              1: estimated and constrained to be positive
              2: estimated and unconstrained
              3: fixed variance-covariance component provided in Gt



              After that is easy to see that if you want to force certain variance components you have to provide initial values (Gt argument) and specify a constraint matrix with values 3's (the function fixm() can creates such matrix).



              ans.mf <- mmer(cbind(Yield,color)~1,
              random=~ vs(id, Gu=A, Gt=ans.m$sigma_scaled$id,Gtc=fixm(2))
              + vs(Rowf,Gt=ans.m$sigma_scaled$Rowf, Gtc=fixm(2))
              + vs(idd, Gu=D),
              rcov=~ vs(units, Gt=ans.m$sigma_scaled$units, Gtc=fixm(2)),
              data=DT)

              ans.m$sigma
              ans.mf$sigma


              If you check the results you can see that you have forced the variance components for id, Rowf and units and estimated properly the components for idd.






              share|improve this answer

























                1












                1








                1







                If you have sommer >= 3.7 forcing specific variance or covariance components can be done using the Gt (initial values) and Gtc (contraints) arguments from the vs() function that is used to specify the variance model for a random effect.



                For example assume you fit the following multivariate mixed model for two traits:



                library(sommer)
                data(DT_cpdata)
                #### create the variance-covariance matrix for id levels
                A <- A.mat(GT) # additive relationship matrix
                D <- D.mat(GT) # additive relationship matrix
                #### look at the data and fit the model
                DT$idd <- DT$id
                head(DT)
                ans.m <- mmer(cbind(Yield,color)~1,
                random=~ vs(id, Gu=A)
                + vs(Rowf,Gtc=diag(2)),
                rcov=~ vs(units),
                data=DT)


                In this model there's 2 random effects (id and Rowf) and a residual term for units. By default an unstructured variance model is fitted (i.e. units and id) but you can see how for Rowf the Gtc argument is a constraint matrix that makes a diagonal model for Rowf:



                > diag(2)
                [,1] [,2]
                [1,] 1 0
                [2,] 0 1


                which follows the rules:
                0: not to be estimated
                1: estimated and constrained to be positive
                2: estimated and unconstrained
                3: fixed variance-covariance component provided in Gt



                After that is easy to see that if you want to force certain variance components you have to provide initial values (Gt argument) and specify a constraint matrix with values 3's (the function fixm() can creates such matrix).



                ans.mf <- mmer(cbind(Yield,color)~1,
                random=~ vs(id, Gu=A, Gt=ans.m$sigma_scaled$id,Gtc=fixm(2))
                + vs(Rowf,Gt=ans.m$sigma_scaled$Rowf, Gtc=fixm(2))
                + vs(idd, Gu=D),
                rcov=~ vs(units, Gt=ans.m$sigma_scaled$units, Gtc=fixm(2)),
                data=DT)

                ans.m$sigma
                ans.mf$sigma


                If you check the results you can see that you have forced the variance components for id, Rowf and units and estimated properly the components for idd.






                share|improve this answer













                If you have sommer >= 3.7 forcing specific variance or covariance components can be done using the Gt (initial values) and Gtc (contraints) arguments from the vs() function that is used to specify the variance model for a random effect.



                For example assume you fit the following multivariate mixed model for two traits:



                library(sommer)
                data(DT_cpdata)
                #### create the variance-covariance matrix for id levels
                A <- A.mat(GT) # additive relationship matrix
                D <- D.mat(GT) # additive relationship matrix
                #### look at the data and fit the model
                DT$idd <- DT$id
                head(DT)
                ans.m <- mmer(cbind(Yield,color)~1,
                random=~ vs(id, Gu=A)
                + vs(Rowf,Gtc=diag(2)),
                rcov=~ vs(units),
                data=DT)


                In this model there's 2 random effects (id and Rowf) and a residual term for units. By default an unstructured variance model is fitted (i.e. units and id) but you can see how for Rowf the Gtc argument is a constraint matrix that makes a diagonal model for Rowf:



                > diag(2)
                [,1] [,2]
                [1,] 1 0
                [2,] 0 1


                which follows the rules:
                0: not to be estimated
                1: estimated and constrained to be positive
                2: estimated and unconstrained
                3: fixed variance-covariance component provided in Gt



                After that is easy to see that if you want to force certain variance components you have to provide initial values (Gt argument) and specify a constraint matrix with values 3's (the function fixm() can creates such matrix).



                ans.mf <- mmer(cbind(Yield,color)~1,
                random=~ vs(id, Gu=A, Gt=ans.m$sigma_scaled$id,Gtc=fixm(2))
                + vs(Rowf,Gt=ans.m$sigma_scaled$Rowf, Gtc=fixm(2))
                + vs(idd, Gu=D),
                rcov=~ vs(units, Gt=ans.m$sigma_scaled$units, Gtc=fixm(2)),
                data=DT)

                ans.m$sigma
                ans.mf$sigma


                If you check the results you can see that you have forced the variance components for id, Rowf and units and estimated properly the components for idd.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 14 '18 at 19:00









                CovaruberCovaruber

                964




                964



























                    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%2f53303311%2ffix-variance-components-in-sommers-mmer2%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

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    ReactJS Fetched API data displays live - need Data displayed static

                    政党