├── .Rproj.user ├── shared │ └── notebooks │ │ ├── patch-chunk-names │ │ └── paths ├── 584CA4EF │ ├── sources │ │ ├── prop │ │ │ ├── DCAB6E41 │ │ │ ├── 27370B6C │ │ │ ├── 4C2D4000 │ │ │ └── INDEX │ │ └── per │ │ │ └── t │ │ │ ├── AF998D96-contents │ │ │ ├── AF998D96 │ │ │ ├── 53DCAE0C │ │ │ ├── D1DB82FB │ │ │ ├── 53DCAE0C-contents │ │ │ └── D1DB82FB-contents │ ├── saved_source_markers │ ├── pcs │ │ ├── source-pane.pper │ │ ├── workbench-pane.pper │ │ ├── files-pane.pper │ │ └── windowlayoutstate.pper │ └── rmd-outputs └── 6F6C4B3A │ ├── saved_source_markers │ ├── pcs │ ├── source-pane.pper │ ├── workbench-pane.pper │ ├── files-pane.pper │ ├── packages-pane.pper │ └── windowlayoutstate.pper │ ├── sources │ └── prop │ │ ├── 4566BC63 │ │ ├── D8394665 │ │ ├── 150078C7 │ │ ├── 82D418B5 │ │ ├── C42C918D │ │ ├── C5272C1D │ │ ├── E568B466 │ │ ├── F9A3FE83 │ │ ├── FC7EC653 │ │ ├── BACFE030 │ │ ├── C8D636F7 │ │ └── INDEX │ └── rmd-outputs ├── SAS ├── SAS.lnk ├── autoregressive_time_series_results_VC.txt ├── autoregressive_time_series_results_AIC.txt ├── datasets for SAS.R ├── heterogeneous_error_variance_results_AIC.txt ├── heterogeneous_error_variance_results_VC.txt ├── data_heterogeneous_error_variance.txt └── data_autoregressive_time_series.txt ├── img ├── hexdplyr.png ├── hexpipe.png ├── hexpurrr.png ├── hexscales.png ├── hextibble.png ├── hextidyr.png ├── corrvalues.PNG ├── hexggplot2.png ├── hexstringr.png ├── banner_mmfair.jpg ├── hextidyverse.png └── logo │ ├── favicon.ico │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ ├── flaviconMMFAIR.png │ ├── hexagonMMFAIR.png │ ├── mstile-150x150.png │ ├── ScreenshotIndex.PNG │ ├── apple-touch-icon.png │ ├── android-chrome-192x192.png │ ├── android-chrome-512x512.png │ ├── browserconfig.xml │ ├── site.webmanifest │ ├── safari-pinned-tab.svg │ ├── flaviconMMFAIR.svg │ └── hexagonMMFAIR.svg ├── site_libs ├── bootstrap-3.3.5 │ ├── css │ │ └── fonts │ │ │ ├── Lato.ttf │ │ │ ├── Raleway.ttf │ │ │ ├── Roboto.ttf │ │ │ ├── Ubuntu.ttf │ │ │ ├── LatoBold.ttf │ │ │ ├── NewsCycle.ttf │ │ │ ├── OpenSans.ttf │ │ │ ├── LatoItalic.ttf │ │ │ ├── OpenSansBold.ttf │ │ │ ├── RalewayBold.ttf │ │ │ ├── RobotoBold.ttf │ │ │ ├── RobotoLight.ttf │ │ │ ├── RobotoMedium.ttf │ │ │ ├── NewsCycleBold.ttf │ │ │ ├── OpenSansItalic.ttf │ │ │ ├── OpenSansLight.ttf │ │ │ ├── SourceSansPro.ttf │ │ │ ├── SourceSansProBold.ttf │ │ │ ├── OpenSansBoldItalic.ttf │ │ │ ├── OpenSansLightItalic.ttf │ │ │ ├── SourceSansProItalic.ttf │ │ │ └── SourceSansProLight.ttf │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ ├── js │ │ └── npm.js │ └── shim │ │ ├── html5shiv.min.js │ │ └── respond.min.js ├── jqueryui-1.11.4 │ ├── images │ │ ├── ui-icons_444444_256x240.png │ │ ├── ui-icons_555555_256x240.png │ │ ├── ui-icons_777620_256x240.png │ │ ├── ui-icons_777777_256x240.png │ │ ├── ui-icons_cc0000_256x240.png │ │ └── ui-icons_ffffff_256x240.png │ ├── README │ ├── jquery-ui.structure.min.css │ └── jquery-ui.theme.min.css ├── kePrint-0.0.1 │ └── kePrint.js ├── navigation-1.1 │ ├── sourceembed.js │ ├── codefolding.js │ └── tabsets.js ├── header-attrs-2.7 │ └── header-attrs.js ├── tocify-1.9.1 │ └── jquery.tocify.css └── lightable-0.0.1 │ └── lightable.css ├── variance_structures_files └── figure-html │ ├── unnamed-chunk-2-1.png │ └── unnamed-chunk-3-1.png ├── autoregressive_time_series_files └── figure-html │ └── unnamed-chunk-5-1.gif ├── heterogeneous_error_variance_files └── figure-html │ ├── unnamed-chunk-5-1.png │ └── unnamed-chunk-6-1.png ├── MMFAIR.Rproj ├── 0 render_site.R ├── README.md ├── footer.html ├── _site.yml ├── .gitignore ├── _hilang_setup.Rmd ├── Rpurl ├── glmmtmbdispformula0.R └── autoregressive_time_series.R ├── header.html ├── styles.css ├── model_selection.Rmd ├── 0contactinfo.Rmd ├── sources.Rmd ├── index.Rmd ├── weighted_two_stage.Rmd ├── glmmtmbdispformula0.Rmd └── variance_structures.Rmd /.Rproj.user/shared/notebooks/patch-chunk-names: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/sources/prop/DCAB6E41: -------------------------------------------------------------------------------- 1 | { 2 | } -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/saved_source_markers: -------------------------------------------------------------------------------- 1 | {"active_set":"","sets":[]} -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/saved_source_markers: -------------------------------------------------------------------------------- 1 | {"active_set":"","sets":[]} -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/pcs/source-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "activeTab" : 0 3 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/pcs/source-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "activeTab" : 4 3 | } -------------------------------------------------------------------------------- /SAS/SAS.lnk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/SAS/SAS.lnk -------------------------------------------------------------------------------- /img/hexdplyr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/hexdplyr.png -------------------------------------------------------------------------------- /img/hexpipe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/hexpipe.png -------------------------------------------------------------------------------- /img/hexpurrr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/hexpurrr.png -------------------------------------------------------------------------------- /img/hexscales.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/hexscales.png -------------------------------------------------------------------------------- /img/hextibble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/hextibble.png -------------------------------------------------------------------------------- /img/hextidyr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/hextidyr.png -------------------------------------------------------------------------------- /img/corrvalues.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/corrvalues.PNG -------------------------------------------------------------------------------- /img/hexggplot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/hexggplot2.png -------------------------------------------------------------------------------- /img/hexstringr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/hexstringr.png -------------------------------------------------------------------------------- /img/banner_mmfair.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/banner_mmfair.jpg -------------------------------------------------------------------------------- /img/hextidyverse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/hextidyverse.png -------------------------------------------------------------------------------- /img/logo/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/logo/favicon.ico -------------------------------------------------------------------------------- /img/logo/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/logo/favicon-16x16.png -------------------------------------------------------------------------------- /img/logo/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/logo/favicon-32x32.png -------------------------------------------------------------------------------- /img/logo/flaviconMMFAIR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/logo/flaviconMMFAIR.png -------------------------------------------------------------------------------- /img/logo/hexagonMMFAIR.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/logo/hexagonMMFAIR.png -------------------------------------------------------------------------------- /img/logo/mstile-150x150.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/logo/mstile-150x150.png -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/sources/prop/27370B6C: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "44,1", 3 | "scrollLine" : "28" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/sources/prop/4C2D4000: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "5,29", 3 | "scrollLine" : "0" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/4566BC63: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "8,0", 3 | "scrollLine" : "0" 4 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/D8394665: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "4,15", 3 | "scrollLine" : "0" 4 | } -------------------------------------------------------------------------------- /img/logo/ScreenshotIndex.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/logo/ScreenshotIndex.PNG -------------------------------------------------------------------------------- /img/logo/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/logo/apple-touch-icon.png -------------------------------------------------------------------------------- /img/logo/android-chrome-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/logo/android-chrome-192x192.png -------------------------------------------------------------------------------- /img/logo/android-chrome-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/img/logo/android-chrome-512x512.png -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/pcs/workbench-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "TabSet1" : 0, 3 | "TabSet2" : 0, 4 | "TabZoom" : { 5 | } 6 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/pcs/workbench-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "TabSet1" : 4, 3 | "TabSet2" : 4, 4 | "TabZoom" : { 5 | } 6 | } -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/Lato.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/Lato.ttf -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/150078C7: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "23,12", 3 | "scrollLine" : "0", 4 | "tempName" : "Untitled1" 5 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/82D418B5: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "22,9", 3 | "scrollLine" : "15", 4 | "tempName" : "Untitled1" 5 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/C42C918D: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "56,38", 3 | "scrollLine" : "44", 4 | "tempName" : "Untitled2" 5 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/C5272C1D: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "10,3", 3 | "scrollLine" : "0", 4 | "tempName" : "Untitled2" 5 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/E568B466: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "80,50", 3 | "scrollLine" : "64", 4 | "tempName" : "Untitled2" 5 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/F9A3FE83: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "19,0", 3 | "scrollLine" : "7", 4 | "tempName" : "Untitled1" 5 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/FC7EC653: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "3,0", 3 | "scrollLine" : "0", 4 | "tempName" : "Untitled1" 5 | } -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/Raleway.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/Raleway.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/Roboto.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/Roboto.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/Ubuntu.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/Ubuntu.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/LatoBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/LatoBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/NewsCycle.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/NewsCycle.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/OpenSans.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/LatoItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/LatoItalic.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSansBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/OpenSansBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/RalewayBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/RalewayBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/RobotoBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/RobotoBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/RobotoLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/RobotoLight.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/RobotoMedium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/RobotoMedium.ttf -------------------------------------------------------------------------------- /SAS/autoregressive_time_series_results_VC.txt: -------------------------------------------------------------------------------- 1 | CovParm Subject Estimate mod 2 | factweek plot 0.02318 iid 3 | AR(1) plot 0.7490 ar1 4 | Residual 0.02216 ar1 5 | -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/NewsCycleBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/NewsCycleBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSansItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/OpenSansItalic.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSansLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/OpenSansLight.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/SourceSansPro.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/SourceSansPro.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/SourceSansProBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/SourceSansProBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSansBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/OpenSansBoldItalic.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSansLightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/OpenSansLightItalic.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/SourceSansProItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/SourceSansProItalic.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/SourceSansProLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/css/fonts/SourceSansProLight.ttf -------------------------------------------------------------------------------- /variance_structures_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/variance_structures_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /variance_structures_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/variance_structures_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_444444_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/jqueryui-1.11.4/images/ui-icons_444444_256x240.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_555555_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/jqueryui-1.11.4/images/ui-icons_555555_256x240.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_777620_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/jqueryui-1.11.4/images/ui-icons_777620_256x240.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_777777_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/jqueryui-1.11.4/images/ui-icons_777777_256x240.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_cc0000_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/jqueryui-1.11.4/images/ui-icons_cc0000_256x240.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/jqueryui-1.11.4/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/BACFE030: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "82,0", 3 | "docOutlineVisible" : "1", 4 | "scrollLine" : "0", 5 | "tempName" : "Untitled1" 6 | } -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /autoregressive_time_series_files/figure-html/unnamed-chunk-5-1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/autoregressive_time_series_files/figure-html/unnamed-chunk-5-1.gif -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/rmd-outputs: -------------------------------------------------------------------------------- 1 | ~/GitHub/MMFAIR/ex_diag_error.html 2 | 3 | ~/GitHub/MMFAIR/ex_diag_error.html 4 | ~/GitHub/MMFAIR/ex_diag_error.html 5 | ~/GitHub/MMFAIR/ex_diag_error.html 6 | -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/sources/prop/INDEX: -------------------------------------------------------------------------------- 1 | ~%2FGitHub%2FMMFAIR%2F_site.yml="DCAB6E41" 2 | ~%2FGitHub%2FMMFAIR%2Fex_diag_error.Rmd="4C2D4000" 3 | ~%2FGitHub%2FMMFAIR%2Fstyles.css="27370B6C" 4 | -------------------------------------------------------------------------------- /heterogeneous_error_variance_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/heterogeneous_error_variance_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /heterogeneous_error_variance_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SchmidtPaul/MMFAIR/HEAD/heterogeneous_error_variance_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/pcs/files-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "path" : "~/GitHub/MMFAIR", 3 | "sortOrder" : [ 4 | { 5 | "ascending" : true, 6 | "columnIndex" : 2 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/pcs/files-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "path" : "D:/Coding/MMFAIR", 3 | "sortOrder" : [ 4 | { 5 | "ascending" : true, 6 | "columnIndex" : 2 7 | } 8 | ] 9 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/C8D636F7: -------------------------------------------------------------------------------- 1 | { 2 | "cursorPosition" : "1,36", 3 | "disableDependencyDiscovery" : "1", 4 | "docOutlineVisible" : "1", 5 | "scrollLine" : "0", 6 | "tempName" : "Untitled1" 7 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/pcs/packages-pane.pper: -------------------------------------------------------------------------------- 1 | { 2 | "installOptions" : { 3 | "installDependencies" : true, 4 | "installFromRepository" : true, 5 | "libraryPath" : "C:/Users/schmi/Documents/R/win-library/4.0" 6 | } 7 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/rmd-outputs: -------------------------------------------------------------------------------- 1 | D:/Coding/MMFAIR/0contactinfo.html 2 | D:/Coding/MMFAIR/glmmtmbdispformula0.html 3 | D:/Coding/MMFAIR/glmmtmbdispformula0.html 4 | D:/Coding/MMFAIR/glmmtmbdispformula0.html 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /MMFAIR.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Website 16 | -------------------------------------------------------------------------------- /img/logo/browserconfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #da532c 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /site_libs/kePrint-0.0.1/kePrint.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | if (typeof $('[data-toggle="tooltip"]').tooltip === 'function') { 3 | $('[data-toggle="tooltip"]').tooltip(); 4 | } 5 | if ($('[data-toggle="popover"]').popover === 'function') { 6 | $('[data-toggle="popover"]').popover(); 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /SAS/autoregressive_time_series_results_AIC.txt: -------------------------------------------------------------------------------- 1 | Descr Value mod 2 | -2 Res Log-Likelihood -3.7 iid 3 | AIC (kleiner ist besser) -1.7 iid 4 | AICC (kleiner ist besser) -1.7 iid 5 | BIC (kleiner ist besser) -0.7 iid 6 | -2 Res Log-Likelihood -46.0 ar1 7 | AIC (kleiner ist besser) -42.0 ar1 8 | AICC (kleiner ist besser) -41.7 ar1 9 | BIC (kleiner ist besser) -40.0 ar1 10 | -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/pcs/windowlayoutstate.pper: -------------------------------------------------------------------------------- 1 | { 2 | "left" : { 3 | "panelheight" : 958, 4 | "splitterpos" : 398, 5 | "topwindowstate" : "NORMAL", 6 | "windowheight" : 996 7 | }, 8 | "right" : { 9 | "panelheight" : 958, 10 | "splitterpos" : 597, 11 | "topwindowstate" : "NORMAL", 12 | "windowheight" : 996 13 | } 14 | } -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/pcs/windowlayoutstate.pper: -------------------------------------------------------------------------------- 1 | { 2 | "left" : { 3 | "panelheight" : 865, 4 | "splitterpos" : 314, 5 | "topwindowstate" : "NORMAL", 6 | "windowheight" : 905 7 | }, 8 | "right" : { 9 | "panelheight" : 865, 10 | "splitterpos" : 466, 11 | "topwindowstate" : "NORMAL", 12 | "windowheight" : 905 13 | } 14 | } -------------------------------------------------------------------------------- /site_libs/navigation-1.1/sourceembed.js: -------------------------------------------------------------------------------- 1 | 2 | window.initializeSourceEmbed = function(filename) { 3 | $("#rmd-download-source").click(function() { 4 | var src = $("#rmd-source-code").html(); 5 | var a = document.createElement('a'); 6 | a.href = "data:text/x-r-markdown;base64," + src; 7 | a.download = filename; 8 | document.body.appendChild(a); 9 | a.click(); 10 | document.body.removeChild(a); 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/README: -------------------------------------------------------------------------------- 1 | This a jQuery UI custom build, downloaded from: 2 | http://jqueryui.com/download/#!version=1.11.4&components=1111111111110111111111111111111111111 3 | 4 | It includes all components except the datepicker, because it conflicts with 5 | bootstrap-datepicker that is packaged with Shiny. 6 | 7 | The copy of jQuery that is bundled with the download, under external/, is not 8 | included because Shiny already has its own copy of jQuery. 9 | -------------------------------------------------------------------------------- /SAS/datasets for SAS.R: -------------------------------------------------------------------------------- 1 | pacman::p_load(dplyr, purrr, readr, tibble, tidyr) 2 | 3 | # heterogeneous_error_variance 4 | agridat::mcconway.turnip %>% 5 | as_tibble() %>% 6 | mutate(densf = density %>% as.factor) %>% 7 | write_delim(path="SAS/data_heterogeneous_error_variance.txt") 8 | 9 | # autoregressive_time_series 10 | agriTutorial::sorghum %>% 11 | rename(block = Replicate, plot = factplot) %>% 12 | dplyr::select(y, variety, block, plot, factweek, varweek) %>% 13 | write_delim(path="SAS/data_autoregressive_time_series.txt") 14 | -------------------------------------------------------------------------------- /img/logo/site.webmanifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "", 3 | "short_name": "", 4 | "icons": [ 5 | { 6 | "src": "/img/logo/android-chrome-192x192.png", 7 | "sizes": "192x192", 8 | "type": "image/png" 9 | }, 10 | { 11 | "src": "/img/logo/android-chrome-512x512.png", 12 | "sizes": "512x512", 13 | "type": "image/png" 14 | } 15 | ], 16 | "theme_color": "#ffffff", 17 | "background_color": "#ffffff", 18 | "display": "standalone" 19 | } 20 | -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /site_libs/header-attrs-2.7/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/sources/per/t/AF998D96-contents: -------------------------------------------------------------------------------- 1 | name: "MMFAIR-website" 2 | output_dir: "." # in GitHub master folder instead of default "_site" so that GitHub Pages works 3 | 4 | navbar: 5 | title: "MMFAIR" 6 | left: 7 | - text: "Home" 8 | href: index.html 9 | - text: "Examples" 10 | href: ex_diag_error.html 11 | - text: "Sources" 12 | href: sources.html 13 | 14 | output: 15 | html_document: 16 | theme: lumen 17 | code_folding: show 18 | highlight: tango 19 | toc: true 20 | toc_float: true 21 | # number_sections: true 22 | css: 'styles.css' -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/sources/per/t/AF998D96: -------------------------------------------------------------------------------- 1 | { 2 | "collab_server" : "", 3 | "contents" : "", 4 | "created" : 1588613523486.000, 5 | "dirty" : false, 6 | "encoding" : "UTF-8", 7 | "folds" : "", 8 | "hash" : "2072962068", 9 | "id" : "AF998D96", 10 | "lastKnownWriteTime" : 1588612844, 11 | "last_content_update" : 1588612844, 12 | "path" : "~/GitHub/MMFAIR/_site.yml", 13 | "project_path" : "_site.yml", 14 | "properties" : { 15 | }, 16 | "read_only" : false, 17 | "read_only_alternatives" : [ 18 | ], 19 | "relative_order" : 2, 20 | "source_on_save" : false, 21 | "source_window" : "", 22 | "type" : "yaml" 23 | } -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/sources/per/t/53DCAE0C: -------------------------------------------------------------------------------- 1 | { 2 | "collab_server" : "", 3 | "contents" : "", 4 | "created" : 1588613717061.000, 5 | "dirty" : false, 6 | "encoding" : "UTF-8", 7 | "folds" : "", 8 | "hash" : "561387358", 9 | "id" : "53DCAE0C", 10 | "lastKnownWriteTime" : 1588614127, 11 | "last_content_update" : 1588614127995, 12 | "path" : "~/GitHub/MMFAIR/styles.css", 13 | "project_path" : "styles.css", 14 | "properties" : { 15 | "cursorPosition" : "44,1", 16 | "scrollLine" : "28" 17 | }, 18 | "read_only" : false, 19 | "read_only_alternatives" : [ 20 | ], 21 | "relative_order" : 3, 22 | "source_on_save" : false, 23 | "source_window" : "", 24 | "type" : "css" 25 | } -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/sources/per/t/D1DB82FB: -------------------------------------------------------------------------------- 1 | { 2 | "collab_server" : "", 3 | "contents" : "", 4 | "created" : 1588613337766.000, 5 | "dirty" : false, 6 | "encoding" : "UTF-8", 7 | "folds" : "", 8 | "hash" : "3985410878", 9 | "id" : "D1DB82FB", 10 | "lastKnownWriteTime" : 1588614771, 11 | "last_content_update" : 1588614771889, 12 | "path" : "~/GitHub/MMFAIR/ex_diag_error.Rmd", 13 | "project_path" : "ex_diag_error.Rmd", 14 | "properties" : { 15 | "cursorPosition" : "5,29", 16 | "scrollLine" : "0" 17 | }, 18 | "read_only" : false, 19 | "read_only_alternatives" : [ 20 | ], 21 | "relative_order" : 1, 22 | "source_on_save" : false, 23 | "source_window" : "", 24 | "type" : "r_markdown" 25 | } -------------------------------------------------------------------------------- /SAS/heterogeneous_error_variance_results_AIC.txt: -------------------------------------------------------------------------------- 1 | Descr Value mod 2 | -2 Res Log-Likelihood 272.1 1 3 | AIC (kleiner ist besser) 276.1 1 4 | AICC (kleiner ist besser) 276.4 1 5 | BIC (kleiner ist besser) 274.9 1 6 | -2 Res Log-Likelihood 263.9 2 7 | AIC (kleiner ist besser) 269.9 2 8 | AICC (kleiner ist besser) 270.5 2 9 | BIC (kleiner ist besser) 268.1 2 10 | -2 Res Log-Likelihood 256.3 3 11 | AIC (kleiner ist besser) 266.3 3 12 | AICC (kleiner ist besser) 267.7 3 13 | BIC (kleiner ist besser) 263.2 3 14 | -2 Res Log-Likelihood 250.3 4 15 | AIC (kleiner ist besser) 262.3 4 16 | AICC (kleiner ist besser) 264.3 4 17 | BIC (kleiner ist besser) 258.6 4 18 | -2 Res Log-Likelihood 248.2 5 19 | AIC (kleiner ist besser) 266.2 5 20 | AICC (kleiner ist besser) 270.9 5 21 | BIC (kleiner ist besser) 260.7 5 22 | -------------------------------------------------------------------------------- /SAS/heterogeneous_error_variance_results_VC.txt: -------------------------------------------------------------------------------- 1 | CovParm Estimate mod Group 2 | block 2.8117 1 3 | Residual 9.5914 1 4 | block 1.5966 2 5 | Residual 4.3061 2 date 21AUG1990 6 | Residual 15.5051 2 date 28AUG1990 7 | block 0.4747 3 8 | Residual 2.2522 3 densf 1 9 | Residual 3.6695 3 densf 2 10 | Residual 25.0373 3 densf 4 11 | Residual 13.3385 3 densf 8 12 | block 0.1603 4 13 | EXP date -0.5581 4 14 | EXP densf -1.2937 4 15 | EXP densf -0.5075 4 16 | EXP densf 1.0559 4 17 | Residual 6.5593 4 18 | block 0.07393 5 19 | Residual 0.8796 5 date*densf 21A 20 | Residual 3.0812 5 date*densf 21A 21 | Residual 6.2625 5 date*densf 21A 22 | Residual 9.7597 5 date*densf 21A 23 | Residual 3.4465 5 date*densf 28A 24 | Residual 4.9972 5 date*densf 28A 25 | Residual 48.0949 5 date*densf 28A 26 | Residual 19.9377 5 date*densf 28A 27 | -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/sources/per/t/53DCAE0C-contents: -------------------------------------------------------------------------------- 1 | h1 { 2 | font-size: 32px; 3 | } 4 | title { 5 | font-size: 32px; 6 | } 7 | h2 { 8 | font-size: 28px; 9 | } 10 | h3 { 11 | font-size: 20px; 12 | font-style: italic; 13 | font-weight: 100; 14 | } 15 | h4 { 16 | font-size: 20px; 17 | } 18 | h5 { 19 | font-size: 16px; 20 | } 21 | h6 { 22 | font-size: 12px; 23 | } 24 | blockquote { 25 | background: #f9f9f9; 26 | border-left: 10px solid #ccc; 27 | margin: 1.5em 10px; 28 | padding: 0.5em 10px; 29 | quotes: "\201C""\201D""\2018""\2019"; 30 | font-size: 12px; 31 | } 32 | blockquote:before { 33 | color: #ccc; 34 | content: "side note:"; 35 | font-size: 16px; 36 | line-height: 0.1em; 37 | margin-right: 0.25em; 38 | vertical-align: 0em; 39 | } 40 | blockquote p { 41 | display: inline; 42 | } 43 | nav-pills>li:nth-child(2) { 44 | background: green; 45 | } -------------------------------------------------------------------------------- /0 render_site.R: -------------------------------------------------------------------------------- 1 | setwd("D:/Coding/MMFAIR") 2 | library("rmarkdown") 3 | `%not_in%` = Negate(`%in%`) 4 | 5 | rmarkdown::clean_site() # delete old files 6 | rmarkdown::render_site(encoding="UTF-8") # render all files new; UTF-8 for ä, ö, ü, ß 7 | 8 | ### create purled R files ### 9 | purl_files <- list.files(pattern = ".Rmd") %>% 10 | tibble(Rmd = .) %>% 11 | filter(Rmd %not_in% c("_hilang_setup.Rmd", 12 | "0contactinfo.Rmd", 13 | "index.Rmd", 14 | "model_selection.Rmd", 15 | "sources.Rmd", 16 | "variance_structures.Rmd", 17 | "weighted_two_stage.Rmd")) %>% 18 | mutate(R = paste0("Rpurl/",str_sub(Rmd, 1, -3))) 19 | 20 | for(i in 1:nrow(purl_files)){ 21 | 22 | knitr::purl(input = purl_files %>% slice(i) %>% pull(Rmd), 23 | output = purl_files %>% slice(i) %>% pull(R), 24 | documentation = 0) 25 | 26 | } 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MMFAIR - Mixed Models for Agriculture in R 2 | [📈🌱 MMFAIR - Mixed Models for Agriculture in R](https://schmidtpaul.github.io/MMFAIR/) can on one hand be seen as the bigger brother [📊🌱 DSFAIR - Data Science for Agriculture in R](https://schmidtpaul.github.io/DSFAIR/), because it deals with more sophisticated analyses. On the other hand, however, it also deals with the limitations of (generalized) linear mixed model analyses in R: 3 | 4 | To this day, R has no single go-to package for such analyses. Instead, packages like `nlme`, `lme4`, `glmmTMB` or `sommer` provide the tools to fit some but not all such models. Therefore, our aim is to 5 | * provide a cookbook with (generalized) linear mixed model analyses of typical examples in life sciences (focus on agriculture/biology) and 6 | * compare the possibilities or rather limitations of the R-packages to each other, but also to SAS’ `PROC MIXED`. 7 | 8 | Where possible, we try to use example data/analyses that have been published in peer-reviewed journals. 9 | -------------------------------------------------------------------------------- /.Rproj.user/shared/notebooks/paths: -------------------------------------------------------------------------------- 1 | D:/Coding/CV/CVeng.Rmd="850BC263" 2 | D:/Coding/MMFAIR notes/Heterogeneous Error Variances/giovanni mod4.R="4FB06E20" 3 | D:/Coding/MMFAIR notes/ar_time_series.R="539C271B" 4 | D:/Coding/MMFAIR notes/notes.txt="7C888FE5" 5 | D:/Coding/MMFAIR notes/variance structures.R="2BD7B93A" 6 | D:/Coding/MMFAIR/../MMFAIR notes/Heterogeneous Error Variances/giovanni mod4.R="FD28757B" 7 | D:/Coding/MMFAIR/../MMFAIR notes/ar_time_series.R="FDAB3AD2" 8 | D:/Coding/MMFAIR/../MMFAIR notes/notes.txt="985B6C15" 9 | D:/Coding/MMFAIR/../MMFAIR notes/variance structures.R="24366C69" 10 | D:/Coding/MMFAIR/0contactinfo.Rmd="5B82BB97" 11 | D:/Coding/MMFAIR/SAS/datasets for SAS.R="4BC5EDCF" 12 | D:/Coding/MMFAIR/_hilang_setup.Rmd="28D80B80" 13 | D:/Coding/MMFAIR/autoregressive_time_series.Rmd="6930DBB9" 14 | D:/Coding/MMFAIR/glmmtmbdispformula0.Rmd="C4947080" 15 | D:/Coding/MMFAIR/heterogeneous_error_variance.Rmd="23CBAE10" 16 | D:/Coding/MMFAIR/index.Rmd="41740345" 17 | D:/Coding/MMFAIR/model_selection.Rmd="91101177" 18 | D:/Coding/MMFAIR/sources.Rmd="ACC08C50" 19 | D:/Coding/MMFAIR/styles.css="A86D2EFD" 20 | D:/Coding/MMFAIR/variance_structures.Rmd="B1486609" 21 | D:/Coding/MMFAIR/weighted_two_stage.Rmd="50436F5C" 22 | -------------------------------------------------------------------------------- /footer.html: -------------------------------------------------------------------------------- 1 |   2 |
3 |

Please feel free to contact us about any of this!

4 |

schmidtpaul1989@outlook.com

5 | 6 | 7 | 8 | 9 | 10 |

11 | 12 | 13 | 14 | 15 |

16 | 17 | 18 | 19 |   -------------------------------------------------------------------------------- /_site.yml: -------------------------------------------------------------------------------- 1 | name: "MMFAIR-website" 2 | share-img: "img/logo/hexagonMMFAIR.png" 3 | output_dir: "." # in GitHub master folder instead of default "_site" so that GitHub Pages works 4 | 5 | navbar: 6 | title: "MMFAIR" 7 | left: 8 | - text: "Home" 9 | href: index.html 10 | - text: "Chapters" 11 | menu: 12 | - text: "Heterogeneous error variance" 13 | href: heterogeneous_error_variance.html 14 | - text: "First-order autoregressive" 15 | href: autoregressive_time_series.html 16 | - text: "Weighted two-stage analyses" 17 | href: weighted_two_stage.html 18 | - text: "Summaries" 19 | menu: 20 | - text: "Variance Structures" 21 | href: variance_structures.html 22 | - text: "Model Selection" 23 | href: model_selection.html 24 | - text: "Error varcov struct with glmmTMB" 25 | href: glmmtmbdispformula0.html 26 | - text: "Sources" 27 | href: sources.html 28 | - text: "Contact" 29 | href: 0contactinfo.html 30 | 31 | output: 32 | html_document: 33 | theme: lumen 34 | # code_folding: show 35 | highlight: tango 36 | toc: true 37 | toc_float: true 38 | # number_sections: true 39 | css: 'styles.css' 40 | 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .Rapp.history 4 | 5 | # Session Data files 6 | .RData 7 | 8 | # User-specific files 9 | .Ruserdata 10 | 11 | # Example code in package build process 12 | *-Ex.R 13 | .R 14 | 15 | # Output files from R CMD build 16 | /*.tar.gz 17 | 18 | # Output files from R CMD check 19 | /*.Rcheck/ 20 | 21 | # RStudio files 22 | /*.Rproj.user/ 23 | .Rproj.user/* 24 | .Rproj.user/ 25 | .Rproj.user 26 | .Rproj 27 | 28 | # produced vignettes 29 | vignettes/*.html 30 | vignettes/*.pdf 31 | 32 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 33 | .httr-oauth 34 | 35 | # knitr and R markdown default cache directories 36 | *_cache/ 37 | /cache/ 38 | 39 | # Temporary files created by R markdown 40 | *.utf8.md 41 | *.knit.md 42 | 43 | # R Environment Variables 44 | .Renviron 45 | 46 | # pkgdown site 47 | docs/ 48 | .Rproj.user/6F6C4B3A/sources/prop/C5272C1D 49 | .Rproj.user/6F6C4B3A/pcs/workbench-pane.pper 50 | .Rproj.user/6F6C4B3A/pcs/windowlayoutstate.pper 51 | *.pper 52 | *.pper 53 | *.pper 54 | .Rproj.user/6F6C4B3A/sources/prop/C5272C1D 55 | .Rproj.user/shared/notebooks/paths 56 | .Rproj.user/6F6C4B3A/sources/prop/BACFE030 57 | .Rproj.user/6F6C4B3A/sources/prop/INDEX 58 | .Rproj.user/6F6C4B3A/sources/prop/150078C7 59 | *.pper 60 | .Rproj.user/6F6C4B3A/pcs/source-pane.pper 61 | .Rproj.user/6F6C4B3A/pcs/windowlayoutstate.pper 62 | .Rproj.user/6F6C4B3A/pcs/workbench-pane.pper 63 | .Rproj.user/6F6C4B3A/rmd-outputs 64 | .Rproj.user/6F6C4B3A/sources/prop/150078C7 65 | .Rproj.user/6F6C4B3A/sources/prop/BACFE030 66 | .Rhistory 67 | *.pper 68 | -------------------------------------------------------------------------------- /_hilang_setup.Rmd: -------------------------------------------------------------------------------- 1 | ```{r eval=TRUE, echo=FALSE, results="asis"} 2 | # take a character vector of parameters and inject 3 | # the appropriate script tag for code mirror 4 | # ensures that the script tags are only inserted once 5 | for(i in seq_along(params$hilang)) { 6 | js_mode <- paste0("\n\n") 7 | cat(htmltools::htmlPreserve(js_mode)) 8 | } 9 | ``` 10 | 11 | ```{r eval=TRUE, echo=FALSE} 12 | knitr::knit_hooks$set(source = function(x, options) { 13 | if (!is.null(options$hilang)) { 14 | textarea_id <- paste(sample(LETTERS, 5), collapse = "") 15 | code_open <- paste0("\n\n" 17 | jscript_editor <- paste0("\n\n") 18 | 19 | # if the option from_file is set to true then assume that 20 | # whatever is in the code chunk is a file path 21 | if (!is.null(options$from_file) && options$from_file) { 22 | code_body <- readLines(file.path(x)) 23 | } else { 24 | code_body <- x 25 | } 26 | 27 | knitr::asis_output( 28 | htmltools::htmlPreserve( 29 | stringr::str_c( 30 | code_open, 31 | paste(code_body, collapse = "\n"), 32 | code_close, 33 | jscript_editor 34 | ) 35 | ) 36 | ) 37 | } else { 38 | stringr::str_c("\n\n```", tolower(options$engine), "\n", paste0(x, collapse = "\n"), "\n```\n\n") 39 | } 40 | }) 41 | ``` -------------------------------------------------------------------------------- /SAS/data_heterogeneous_error_variance.txt: -------------------------------------------------------------------------------- 1 | gen date density block yield densf 2 | Barkant 21Aug1990 1 B1 2.7 1 3 | Barkant 21Aug1990 1 B2 1.4 1 4 | Barkant 21Aug1990 1 B3 1.2 1 5 | Barkant 21Aug1990 1 B4 3.8 1 6 | Barkant 21Aug1990 2 B1 7.3 2 7 | Barkant 21Aug1990 2 B2 3.8 2 8 | Barkant 21Aug1990 2 B3 3 2 9 | Barkant 21Aug1990 2 B4 1.2 2 10 | Barkant 21Aug1990 4 B1 6.5 4 11 | Barkant 21Aug1990 4 B2 4.6 4 12 | Barkant 21Aug1990 4 B3 4.7 4 13 | Barkant 21Aug1990 4 B4 0.8 4 14 | Barkant 21Aug1990 8 B1 8.2 8 15 | Barkant 21Aug1990 8 B2 4 8 16 | Barkant 21Aug1990 8 B3 6 8 17 | Barkant 21Aug1990 8 B4 2.5 8 18 | Barkant 28Aug1990 1 B1 4.4 1 19 | Barkant 28Aug1990 1 B2 0.4 1 20 | Barkant 28Aug1990 1 B3 6.5 1 21 | Barkant 28Aug1990 1 B4 3.1 1 22 | Barkant 28Aug1990 2 B1 2.6 2 23 | Barkant 28Aug1990 2 B2 7.1 2 24 | Barkant 28Aug1990 2 B3 7 2 25 | Barkant 28Aug1990 2 B4 3.2 2 26 | Barkant 28Aug1990 4 B1 24 4 27 | Barkant 28Aug1990 4 B2 14.9 4 28 | Barkant 28Aug1990 4 B3 14.6 4 29 | Barkant 28Aug1990 4 B4 2.6 4 30 | Barkant 28Aug1990 8 B1 12.2 8 31 | Barkant 28Aug1990 8 B2 18.9 8 32 | Barkant 28Aug1990 8 B3 15.6 8 33 | Barkant 28Aug1990 8 B4 9.9 8 34 | Marco 21Aug1990 1 B1 1.2 1 35 | Marco 21Aug1990 1 B2 1.3 1 36 | Marco 21Aug1990 1 B3 1.5 1 37 | Marco 21Aug1990 1 B4 1 1 38 | Marco 21Aug1990 2 B1 2.2 2 39 | Marco 21Aug1990 2 B2 2 2 40 | Marco 21Aug1990 2 B3 2.1 2 41 | Marco 21Aug1990 2 B4 2.5 2 42 | Marco 21Aug1990 4 B1 2.2 4 43 | Marco 21Aug1990 4 B2 6.2 4 44 | Marco 21Aug1990 4 B3 5.7 4 45 | Marco 21Aug1990 4 B4 0.6 4 46 | Marco 21Aug1990 8 B1 4 8 47 | Marco 21Aug1990 8 B2 2.8 8 48 | Marco 21Aug1990 8 B3 10.8 8 49 | Marco 21Aug1990 8 B4 3.1 8 50 | Marco 28Aug1990 1 B1 2.5 1 51 | Marco 28Aug1990 1 B2 1.6 1 52 | Marco 28Aug1990 1 B3 1.3 1 53 | Marco 28Aug1990 1 B4 0.3 1 54 | Marco 28Aug1990 2 B1 5.5 2 55 | Marco 28Aug1990 2 B2 1.2 2 56 | Marco 28Aug1990 2 B3 2 2 57 | Marco 28Aug1990 2 B4 0.9 2 58 | Marco 28Aug1990 4 B1 4.7 4 59 | Marco 28Aug1990 4 B2 13.2 4 60 | Marco 28Aug1990 4 B3 9 4 61 | Marco 28Aug1990 4 B4 2.9 4 62 | Marco 28Aug1990 8 B1 14.9 8 63 | Marco 28Aug1990 8 B2 13.3 8 64 | Marco 28Aug1990 8 B3 9.3 8 65 | Marco 28Aug1990 8 B4 3.6 8 66 | -------------------------------------------------------------------------------- /site_libs/navigation-1.1/codefolding.js: -------------------------------------------------------------------------------- 1 | 2 | window.initializeCodeFolding = function(show) { 3 | 4 | // handlers for show-all and hide all 5 | $("#rmd-show-all-code").click(function() { 6 | $('div.r-code-collapse').each(function() { 7 | $(this).collapse('show'); 8 | }); 9 | }); 10 | $("#rmd-hide-all-code").click(function() { 11 | $('div.r-code-collapse').each(function() { 12 | $(this).collapse('hide'); 13 | }); 14 | }); 15 | 16 | // index for unique code element ids 17 | var currentIndex = 1; 18 | 19 | // select all R code blocks 20 | var rCodeBlocks = $('pre.r, pre.python, pre.bash, pre.sql, pre.cpp, pre.stan, pre.julia, pre.foldable'); 21 | rCodeBlocks.each(function() { 22 | 23 | // create a collapsable div to wrap the code in 24 | var div = $('
'); 25 | var showThis = (show || $(this).hasClass('fold-show')) && !$(this).hasClass('fold-hide'); 26 | if (showThis) div.collapse('show'); 27 | var id = 'rcode-643E0F36' + currentIndex++; 28 | div.attr('id', id); 29 | $(this).before(div); 30 | $(this).detach().appendTo(div); 31 | 32 | // add a show code button right above 33 | var showCodeText = $('' + (showThis ? 'Hide' : 'Code') + ''); 34 | var showCodeButton = $(''); 35 | showCodeButton.append(showCodeText); 36 | showCodeButton 37 | .attr('data-toggle', 'collapse') 38 | .attr('data-target', '#' + id) 39 | .attr('aria-expanded', showThis) 40 | .attr('aria-controls', id); 41 | 42 | var buttonRow = $('
'); 43 | var buttonCol = $('
'); 44 | 45 | buttonCol.append(showCodeButton); 46 | buttonRow.append(buttonCol); 47 | 48 | div.before(buttonRow); 49 | 50 | // update state of button on show/hide 51 | div.on('hidden.bs.collapse', function () { 52 | showCodeText.text('Code'); 53 | }); 54 | div.on('show.bs.collapse', function () { 55 | showCodeText.text('Hide'); 56 | }); 57 | }); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /site_libs/tocify-1.9.1/jquery.tocify.css: -------------------------------------------------------------------------------- 1 | /* 2 | * jquery.tocify.css 1.9.1 3 | * Author: @gregfranko 4 | */ 5 | 6 | /* The Table of Contents container element */ 7 | .tocify { 8 | width: 20%; 9 | max-height: 90%; 10 | overflow: auto; 11 | margin-left: 2%; 12 | position: fixed; 13 | border: 1px solid #ccc; 14 | border-radius: 6px; 15 | } 16 | 17 | /* The Table of Contents is composed of multiple nested unordered lists. These styles remove the default styling of an unordered list because it is ugly. */ 18 | .tocify ul, .tocify li { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | border: none; 23 | line-height: 30px; 24 | } 25 | 26 | /* Top level header elements */ 27 | .tocify-header { 28 | text-indent: 10px; 29 | } 30 | 31 | /* Top level subheader elements. These are the first nested items underneath a header element. */ 32 | .tocify-subheader { 33 | text-indent: 20px; 34 | display: none; 35 | } 36 | 37 | /* Makes the font smaller for all subheader elements. */ 38 | .tocify-subheader li { 39 | font-size: 12px; 40 | } 41 | 42 | /* Further indents second level subheader elements. */ 43 | .tocify-subheader .tocify-subheader { 44 | text-indent: 30px; 45 | } 46 | .tocify-subheader .tocify-subheader .tocify-subheader { 47 | text-indent: 40px; 48 | } 49 | .tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader { 50 | text-indent: 50px; 51 | } 52 | .tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader { 53 | text-indent: 60px; 54 | } 55 | 56 | /* Twitter Bootstrap Override Style */ 57 | .tocify .tocify-item > a, .tocify .nav-list .nav-header { 58 | margin: 0px; 59 | } 60 | 61 | /* Twitter Bootstrap Override Styles */ 62 | .tocify .tocify-item a, .tocify .list-group-item { 63 | padding: 5px; 64 | } 65 | 66 | .tocify .nav-pills > li { 67 | float: none; 68 | } 69 | 70 | /* We don't override the bootstrap colors because this gives us the 71 | wrong selection colors when using bootstrap themes 72 | 73 | .tocify .list-group-item:hover, .tocify .list-group-item:focus { 74 | background-color: #f5f5f5; 75 | } 76 | 77 | .tocify .list-group-item.active:hover, .tocify .list-group-item.active:focus { 78 | background-color: #428bca; 79 | } 80 | */ 81 | 82 | /* End Twitter Bootstrap Override Styles */ 83 | -------------------------------------------------------------------------------- /SAS/data_autoregressive_time_series.txt: -------------------------------------------------------------------------------- 1 | y variety block plot factweek varweek unit 2 | 5 1 1 1 1 1 1 3 | 4.84 1 1 1 2 2 2 4 | 4.02 1 1 1 3 3 3 5 | 3.75 1 1 1 4 4 4 6 | 3.13 1 1 1 5 5 5 7 | 4.42 1 2 2 1 1 6 8 | 4.3 1 2 2 2 2 7 9 | 3.67 1 2 2 3 3 8 10 | 3.23 1 2 2 4 4 9 11 | 2.83 1 2 2 5 5 10 12 | 4.42 1 3 3 1 1 11 13 | 4.1 1 3 3 2 2 12 14 | 3.46 1 3 3 3 3 13 15 | 3.09 1 3 3 4 4 14 16 | 2.82 1 3 3 5 5 15 17 | 4.01 1 4 4 1 1 16 18 | 3.89 1 4 4 2 2 17 19 | 3.21 1 4 4 3 3 18 20 | 2.89 1 4 4 4 4 19 21 | 2.56 1 4 4 5 5 20 22 | 3.36 1 5 5 1 1 21 23 | 3.1 1 5 5 2 2 22 24 | 2.67 1 5 5 3 3 23 25 | 2.47 1 5 5 4 4 24 26 | 2.16 1 5 5 5 5 25 27 | 5.82 2 1 6 1 1 26 28 | 5.6 2 1 6 2 2 27 29 | 5.05 2 1 6 3 3 28 30 | 4.72 2 1 6 4 4 29 31 | 4.46 2 1 6 5 5 30 32 | 5.73 2 2 7 1 1 31 33 | 5.59 2 2 7 2 2 32 34 | 5 2 2 7 3 3 33 35 | 4.65 2 2 7 4 4 34 36 | 4.42 2 2 7 5 5 35 37 | 5.31 2 3 8 1 1 36 38 | 5.19 2 3 8 2 2 37 39 | 4.86 2 3 8 3 3 38 40 | 4.44 2 3 8 4 4 39 41 | 4.22 2 3 8 5 5 40 42 | 4.92 2 4 9 1 1 41 43 | 4.66 2 4 9 2 2 42 44 | 4.56 2 4 9 3 3 43 45 | 4.16 2 4 9 4 4 44 46 | 3.99 2 4 9 5 5 45 47 | 3.96 2 5 10 1 1 46 48 | 3.86 2 5 10 2 2 47 49 | 3.5 2 5 10 3 3 48 50 | 3.13 2 5 10 4 4 49 51 | 2.95 2 5 10 5 5 50 52 | 5.65 3 1 11 1 1 51 53 | 5.97 3 1 11 2 2 52 54 | 5.27 3 1 11 3 3 53 55 | 5.07 3 1 11 4 4 54 56 | 4.52 3 1 11 5 5 55 57 | 5.39 3 2 12 1 1 56 58 | 5.49 3 2 12 2 2 57 59 | 5.08 3 2 12 3 3 58 60 | 4.87 3 2 12 4 4 59 61 | 4.32 3 2 12 5 5 60 62 | 5.15 3 3 13 1 1 61 63 | 5.28 3 3 13 2 2 62 64 | 4.93 3 3 13 3 3 63 65 | 4.67 3 3 13 4 4 64 66 | 4.15 3 3 13 5 5 65 67 | 4.5 3 4 14 1 1 66 68 | 4.89 3 4 14 2 2 67 69 | 4.74 3 4 14 3 3 68 70 | 4.49 3 4 14 4 4 69 71 | 4.1 3 4 14 5 5 70 72 | 3.75 3 5 15 1 1 71 73 | 3.74 3 5 15 2 2 72 74 | 3.55 3 5 15 3 3 73 75 | 3.28 3 5 15 4 4 74 76 | 3 3 5 15 5 5 75 77 | 5.86 4 1 16 1 1 76 78 | 5.6 4 1 16 2 2 77 79 | 5.37 4 1 16 3 3 78 80 | 5 4 1 16 4 4 79 81 | 4.37 4 1 16 5 5 80 82 | 5.82 4 2 17 1 1 81 83 | 5.55 4 2 17 2 2 82 84 | 5.29 4 2 17 3 3 83 85 | 4.95 4 2 17 4 4 84 86 | 4.07 4 2 17 5 5 85 87 | 5.26 4 3 18 1 1 86 88 | 5.06 4 3 18 2 2 87 89 | 4.76 4 3 18 3 3 88 90 | 4.48 4 3 18 4 4 89 91 | 3.94 4 3 18 5 5 90 92 | 4.87 4 4 19 1 1 91 93 | 4.75 4 4 19 2 2 92 94 | 4.55 4 4 19 3 3 93 95 | 4.33 4 4 19 4 4 94 96 | 3.83 4 4 19 5 5 95 97 | 3.96 4 5 20 1 1 96 98 | 3.76 4 5 20 2 2 97 99 | 3.56 4 5 20 3 3 98 100 | 3.18 4 5 20 4 4 99 101 | 2.96 4 5 20 5 5 100 102 | -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/shim/html5shiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | // Only run this code in IE 8 5 | if (!!window.navigator.userAgent.match("MSIE 8")) { 6 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.2",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b)}(this,document); 7 | }; 8 | -------------------------------------------------------------------------------- /.Rproj.user/6F6C4B3A/sources/prop/INDEX: -------------------------------------------------------------------------------- 1 | C%3A%2FUsers%2Fschmi%2FDesktop%2Fbbolker.R="F5AB04A2" 2 | D%3A%2FCoding%2FCV%2FCVeng.Rmd="E77D2CA" 3 | D%3A%2FCoding%2FMMFAIR%20notes%2FHeterogeneous%20Error%20Variances%2Fgiovanni%20mod4.R="3B1C8939" 4 | D%3A%2FCoding%2FMMFAIR%20notes%2Far_time_series.R="5968DC47" 5 | D%3A%2FCoding%2FMMFAIR%20notes%2Ffirst%20code.R="E568B466" 6 | D%3A%2FCoding%2FMMFAIR%20notes%2FhetVar.R="F9A3FE83" 7 | D%3A%2FCoding%2FMMFAIR%20notes%2Fnotes.txt="43F0E5F3" 8 | D%3A%2FCoding%2FMMFAIR%20notes%2Fsas%20test%202.Rmd="EABCD051" 9 | D%3A%2FCoding%2FMMFAIR%20notes%2Fsas%20test.Rmd="5A718292" 10 | D%3A%2FCoding%2FMMFAIR%20notes%2Fvariance%20structures.R="5B1FF433" 11 | D%3A%2FCoding%2FMMFAIR%2F..%2FMMFAIR%20notes%2FHeterogeneous%20Error%20Variances%2Fgiovanni%20mod4.R="2E01D075" 12 | D%3A%2FCoding%2FMMFAIR%2F..%2FMMFAIR%20notes%2Far_time_series.R="B25E8C56" 13 | D%3A%2FCoding%2FMMFAIR%2F..%2FMMFAIR%20notes%2Ffirst%20code.R="C42C918D" 14 | D%3A%2FCoding%2FMMFAIR%2F..%2FMMFAIR%20notes%2FhetVar.R="82D418B5" 15 | D%3A%2FCoding%2FMMFAIR%2F..%2FMMFAIR%20notes%2Fnotes.txt="A9DF846A" 16 | D%3A%2FCoding%2FMMFAIR%2F..%2FMMFAIR%20notes%2Fsas%20test%202.Rmd="6ABF5BCC" 17 | D%3A%2FCoding%2FMMFAIR%2F..%2FMMFAIR%20notes%2Fsas%20test.Rmd="3EB5ADF" 18 | D%3A%2FCoding%2FMMFAIR%2F..%2FMMFAIR%20notes%2Fvariance%20structures.R="1830152" 19 | D%3A%2FCoding%2FMMFAIR%2F0%20render_site.R="4566BC63" 20 | D%3A%2FCoding%2FMMFAIR%2F000test.Rmd="72C4817E" 21 | D%3A%2FCoding%2FMMFAIR%2F0contactinfo.Rmd="B433CFC2" 22 | D%3A%2FCoding%2FMMFAIR%2FSAS%2Fdatasets%20for%20SAS.R="DA96B780" 23 | D%3A%2FCoding%2FMMFAIR%2FSAS%2Ftemp%20SAS%20highlight%20test.Rmd="642AFC85" 24 | D%3A%2FCoding%2FMMFAIR%2F_hilang_setup.Rmd="FF7C9C04" 25 | D%3A%2FCoding%2FMMFAIR%2F_site.yml="150078C7" 26 | D%3A%2FCoding%2FMMFAIR%2Fautoregressive_time_series.R="CB7FDD6E" 27 | D%3A%2FCoding%2FMMFAIR%2Fautoregressive_time_series.Rmd="ECBF897C" 28 | D%3A%2FCoding%2FMMFAIR%2Fex_diagR.Rmd="FC7EC653" 29 | D%3A%2FCoding%2FMMFAIR%2Fex_diag_error.R="A49EDAE5" 30 | D%3A%2FCoding%2FMMFAIR%2Fex_diag_error.Rmd="C8D636F7" 31 | D%3A%2FCoding%2FMMFAIR%2Fglmmtmbdispformula0.R="7DC1BD2D" 32 | D%3A%2FCoding%2FMMFAIR%2Fglmmtmbdispformula0.Rmd="1EA0C397" 33 | D%3A%2FCoding%2FMMFAIR%2Fheterogeneous_error_variance.R="1A4803B1" 34 | D%3A%2FCoding%2FMMFAIR%2Fheterogeneous_error_variance.Rmd="883A5E6B" 35 | D%3A%2FCoding%2FMMFAIR%2Findex.Rmd="C5272C1D" 36 | D%3A%2FCoding%2FMMFAIR%2Fmodel_selection.Rmd="3E5AFF2E" 37 | D%3A%2FCoding%2FMMFAIR%2Fsources.Rmd="BACFE030" 38 | D%3A%2FCoding%2FMMFAIR%2Fstyles.css="D8394665" 39 | D%3A%2FCoding%2FMMFAIR%2Ftemp%20SAS%20highlight%20test.Rmd="54038BB" 40 | D%3A%2FCoding%2FMMFAIR%2Fvariance_structures.Rmd="97E3615E" 41 | D%3A%2FCoding%2FMMFAIR%2Fweighted_two_stage.Rmd="809AF92C" 42 | -------------------------------------------------------------------------------- /Rpurl/glmmtmbdispformula0.R: -------------------------------------------------------------------------------- 1 | pacman::p_load(conflicted, 2 | tidyverse, 3 | nlme, glmmTMB, 4 | broom.mixed, 5 | emo, flair) 6 | 7 | # package function conflicts 8 | conflict_prefer("filter", "dplyr") 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | dat <- agridat::mcconway.turnip %>% 21 | mutate(unit = 1:n()) %>% 22 | mutate_at(vars(density, unit), as.factor) 23 | 24 | StandErrMod <- glmmTMB( 25 | yield ~ 26 | gen*date*density + 27 | (1 | block), 28 | 29 | 30 | REML = TRUE, 31 | data = dat 32 | ) 33 | 34 | PseudErrMod <- glmmTMB( 35 | yield ~ 36 | gen*date*density + 37 | (1 | block) + 38 | (1 | unit), # Pseudo Err 39 | dispformula = ~ 0, # ErrVar = 0 40 | REML = TRUE, 41 | data = dat 42 | ) 43 | 44 | ## mixedup::extract_vc(StandErrMod) 45 | 46 | 47 | ## mixedup::extract_vc(PseudErrMod) 48 | 49 | 50 | ## AICcmodavg::aictab(list(StandErrMod, PseudErrMod), 51 | ## c("StandErrMod", "PseudErrMod"), 52 | ## second.ord = FALSE) 53 | 54 | 55 | diag_glmmTMB <- glmmTMB( 56 | yield ~ 57 | gen*date*density + 58 | (1 | block) + 59 | diag(date + 0 | unit), 60 | dispformula = ~ 0, 61 | REML = TRUE, 62 | data = dat 63 | ) 64 | 65 | diag_lme <- lme( 66 | yield ~ 67 | gen*date*density, 68 | random = ~ 1 | block, 69 | weights = varIdent(form = ~ 1 | date), 70 | 71 | 72 | data = dat 73 | ) 74 | 75 | glmmTMB_vc <- bind_rows( 76 | 77 | diag_glmmTMB %>% 78 | tidy(effects = "ran_pars", scales = "vcov") %>% 79 | filter(group == "block") %>% 80 | mutate(grp = str_remove(term, "var__")) %>% 81 | select(group, grp, estimate) %>% 82 | rename(variance = estimate, 83 | effect = group) 84 | 85 | , 86 | 87 | diag_glmmTMB %>% 88 | mixedup::extract_cor_structure(which_cor="diag") %>% 89 | pivot_longer( cols = 2:3, values_to ="variance", names_to="grp") %>% 90 | mutate(variance = variance ^ 2) %>% 91 | rename(effect = group) 92 | 93 | , 94 | 95 | tibble(effect = "Residual", 96 | grp = NA_character_, 97 | variance = glance(diag_glmmTMB) %>% pull(sigma) %>% `^`(2)) 98 | 99 | ) 100 | 101 | 102 | 103 | lme_vc <- bind_rows( 104 | 105 | diag_lme %>% 106 | tidy(effects = "ran_pars", scales = "vcov") %>% 107 | filter(group=="block") %>% 108 | mutate(grp = str_remove(term, "var_")) %>% 109 | select(group, grp, estimate) %>% 110 | rename(variance = estimate, 111 | effect = group) 112 | 113 | , 114 | 115 | diag_lme$modelStruct$varStruct %>% 116 | coef(unconstrained = FALSE, allCoef = TRUE) %>% 117 | enframe(name = "grp", value = "varStruct") %>% 118 | mutate(sigma = diag_lme$sigma) %>% 119 | mutate(StandardError = sigma * varStruct) %>% 120 | mutate(variance = StandardError ^ 2) %>% 121 | mutate(effect = "Residual") %>% 122 | select(effect, grp, variance) 123 | 124 | ) 125 | 126 | 127 | 128 | glmmTMB_fit <- diag_glmmTMB %>% 129 | glance() %>% select(logLik:BIC) 130 | 131 | 132 | 133 | lme_fit <- diag_lme %>% 134 | glance() %>% select(logLik:BIC) 135 | -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/shim/respond.min.js: -------------------------------------------------------------------------------- 1 | /*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl 2 | * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT 3 | * */ 4 | 5 | // Only run this code in IE 8 6 | if (!!window.navigator.userAgent.match("MSIE 8")) { 7 | !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | title { 2 | font-size: 30px; 3 | } 4 | h1 { 5 | font-size: 30px; 6 | } 7 | h2 { 8 | font-size: 28px; 9 | } 10 | h3 { 11 | font-size: 22px; 12 | } 13 | h4 { 14 | font-size: 18px; 15 | } 16 | h5 { 17 | font-size: 16px; 18 | } 19 | h6 { 20 | font-size: 12px; 21 | } 22 | 23 | /***********************/ 24 | /* Side note box start */ 25 | blockquote { 26 | background: #f9f9f9; 27 | border-left: 10px solid #ccc; 28 | margin: 1.5em 10px; 29 | padding: 0.5em 10px; 30 | quotes: "\201C""\201D""\2018""\2019"; 31 | font-size: 12px; 32 | } 33 | blockquote:before { 34 | color: #ccc; 35 | content: "side note:"; 36 | font-size: 16px; 37 | line-height: 0.1em; 38 | margin-right: 0.25em; 39 | vertical-align: 0em; 40 | } 41 | blockquote p { 42 | display: inline; 43 | } 44 | 45 | .center { 46 | display: block; 47 | margin-left: auto; 48 | margin-right: auto; 49 | width: 10%; 50 | } 51 | 52 | /* Side note box end */ 53 | /*********************/ 54 | 55 | 56 | /***************************/ 57 | /* Table of contents start */ 58 | 59 | #TOC::before { 60 | content: ""; 61 | display: block; 62 | height: 200px; 63 | margin: 2em 20px 40px 20px; 64 | background-image: url("img/logo/hexagonMMFAIR.png"); 65 | background-size: contain; 66 | background-position: center center; 67 | background-repeat: no-repeat; 68 | } 69 | 70 | .list-group-item.active, .list-group-item.active:focus, .list-group-item.active:hover { 71 | z-index: 2; 72 | color: #fff; 73 | background-color: #003f75ff; 74 | border-color: #003f75ff; 75 | } 76 | 77 | /* Table of contents end */ 78 | /*************************/ 79 | 80 | 81 | /**************/ 82 | /* Tabs start */ 83 | 84 | .nav-pills>li>a { 85 | color: #003f75ff; 86 | } 87 | .nav-pills>li>a:hover, .nav-pills>li>a:focus, .nav-pills>li.active>a, .nav-pills>li.active>a:hover, .nav-pills>li.active>a:focus{ 88 | color: white; 89 | background-color: #003f75ff; 90 | } 91 | 92 | /* Tabs end */ 93 | /************/ 94 | 95 | 96 | /**************************************/ 97 | /* Highlighting text with mouse start */ 98 | 99 | ::selection { 100 | color: white; 101 | background: #003f75ff; /* WebKit/Blink Browsers */ 102 | } 103 | ::-moz-selection { 104 | color: white; 105 | background: #003f75ff; /* WebKit/Blink Browsers */ 106 | } 107 | 108 | /* Highlighting text with mouse start */ 109 | /**************************************/ 110 | 111 | 112 | /*****************************/ 113 | /* Color Active Dropdown Tab */ 114 | 115 | ul.dropdown-menu>li.active>a:hover{ 116 | background: #003f75ff !important; 117 | } 118 | 119 | ul.dropdown-menu>li.active>a{ 120 | background: #003f75ff !important; 121 | } 122 | /* Color Active Dropdown Tab */ 123 | /*****************************/ 124 | 125 | 126 | /********************************************/ 127 | /* Hyperlinks with a target attribute start */ 128 | 129 | a[target]:link, a[target]:visited { 130 | text-decoration: none; 131 | line-height: 1; 132 | 133 | position: relative; 134 | z-index: 0; 135 | display: inline-block; 136 | padding: 3px 0px; 137 | overflow: hidden; 138 | color: #003f75ff; 139 | vertical-align: bottom; 140 | transition: color .3s ease-out; 141 | } 142 | 143 | a[target]:link::before, a[target]:visited::before { 144 | content: ""; 145 | position: absolute; 146 | z-index: -1; 147 | top: 0; 148 | left: 0; 149 | transform: translateY(calc(100% - 2px)); 150 | width: 100%; 151 | height: 100%; 152 | color: #003f75ff; 153 | background-image: linear-gradient(60deg, #003f75ff 0%, #1d5a8fff 100%); 154 | transition: transform .25s ease-out; 155 | } 156 | 157 | a[target]:link:hover, a[target]:visited:hover { 158 | color: #fff; 159 | } 160 | 161 | a[target]:link:hover::before, a[target]:visited:hover::before{ 162 | transform: translateY(0); 163 | transition: transform .25s ease-out; 164 | } 165 | 166 | .credits { 167 | position: fixed; 168 | top: 0; 169 | left: 0; 170 | width: 100vw; 171 | height: 20px; 172 | background-image: linear-gradient(60deg, #003f75ff 0%, #1d5a8fff 100%); 173 | text-align: center; 174 | font-size: 10px; 175 | line-height: 20px; 176 | color: white; 177 | letter-spacing: 1px; 178 | } 179 | 180 | .credits > a { 181 | text-decoration: none; 182 | color: #fff; 183 | letter-spacing: 1px; 184 | } 185 | 186 | /* Hyperlinks with a target attribute end */ 187 | /******************************************/ -------------------------------------------------------------------------------- /model_selection.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Model Selection" 3 | output: 4 | html_document: 5 | includes: 6 | in_header: header.html 7 | after_body: footer.html 8 | params: 9 | hilang: 10 | - sas 11 | --- 12 | 13 | It is often the case that a selection must be made on which model is suitable to analyze a given dataset. Note that "model selection" rarely means a single instant decision for a well thought out model. Instead, model selection is usually a process where *e.g.* effects (fixed and/or random), variance structures and/or data transformations are being investigated step-by-step in order to ultimately make an informed decision on which model works best for a given dataset. Several aspects go into the decision making and there is not always a single correct way of selecting a model. Depending on the perspective of the user and the goal of the analysis, the thoughts on model selection usually range somewhere between these two extremes: 14 | 15 | - Which mistakes must I avoid so that my model is appropriate for my analysis? 16 | - What else could I fine-tune to further improve the information gained from my analysis? 17 | 18 | Based on some experiences, we would like to emphasize a thought here: Although selecting a model is often not the last step of a statistical analysis, it must be clear that deciding for one and against another model is never merely a necessary step towards a final results (such as *e.g.* an ANOVA, a Tukey-test *etc.*), but always also in itself already knowledge gained and thus a result as well. 19 | 20 | # Fixed terms 21 | 22 | ## Wald-type F tests (ANOVA) 23 | 24 | in progress 25 | 26 | ## Post hoc analysis 27 | 28 | ### t-test 29 | 30 | in progress 31 | 32 | ### Tukey's test etc. 33 | 34 | Tukey's test, *a.k.a.* the Tukey's range test, Tukey-Kramer method, Tukey's honest significance test, or Tukey's HSD (honestly significant difference) test. 35 | 36 | in progress 37 | 38 | # Random terms 39 | 40 | ## Model Fit Statistics 41 | 42 | ### Log-Likelihood 43 | 44 | The likelihood function (often simply called the likelihood) measures the goodness of fit (for given values of the unknown parameters) of a model to a dataset. Thus, it measures _how likely_ it is that a certain model fits a certain dataset. 45 | 46 | As [Piepho & Edmondson (2018)](https://onlinelibrary.wiley.com/doi/full/10.1111/jac.12267){target="_blank"} point out: *"Significance tests (i.e., [likelihood ratio tests](https://www.wikiwand.com/en/Likelihood-ratio_test){target="_blank"} in this case) can also be used to select between variance structures that are hierarchically nested, but not all structures meet this requirement, hence our preference for AIC."* 47 | 48 | ### AIC 49 | 50 | In terms of model selection, the AIC is based on, and can be seen as an enhancement of the (Log-)likelihood. Selecting the model with the smaller AIC value is standard procedure when comparing REML-based models that differ only in the random/error part of the model. In other words, REML-based models must be identical regarding their fixed effects to be comparable via AIC. 51 | 52 | _"A standard procedure is to fit a set of candidate models and to pick the best fitting one based on the **Akaike information criterion (AIC)** [(Burnham & Anderson, 2002)](https://www.springer.com/de/book/9780387953649){target="_blank"}, which is computed from_ 53 | 54 | $$-2 log L_R + 2p$$ 55 | 56 | _where $p$ is the number of variance–covariance parameters and $log L_R$ is the maximized residual log-likelihood. The term $2p$ acts as a penalty for model complexity and helps provide a balance between model realism on the one hand and model parsimony on the other. **The smaller the value of AIC, the better is the fit**."_ [(Piepho & Edmondson, 2018)](https://onlinelibrary.wiley.com/doi/full/10.1111/jac.12267){target="_blank"}. 57 | 58 | Notice that *"AIC could also be used to select fixed-effects model components, but this would require switching from REML to full maximum likelihood (ML) estimation. As REML is preferable to ML for variance parameter estimation [(Searle et al., 1992)](https://onlinelibrary.wiley.com/doi/book/10.1002/9780470316856){target="_blank"} and good distributional approximations are available for fixed-effects hypothesis testing [(Kenward & Roger, 1997](https://www.jstor.org/stable/2533558?origin=crossref&seq=1){target="_blank"}, 59 | [2009)](https://www.sciencedirect.com/science/article/abs/pii/S0167947308005768?via%3Dihub){target="_blank"}, we prefer Wald-type F tests and t tests for inference on fixed-effects model terms"* [(Piepho & Edmondson, 2018)](https://onlinelibrary.wiley.com/doi/full/10.1111/jac.12267){target="_blank"}. 60 | 61 | ### BIC 62 | 63 | in progress 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /site_libs/navigation-1.1/tabsets.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | /** 4 | * jQuery Plugin: Sticky Tabs 5 | * 6 | * @author Aidan Lister 7 | * adapted by Ruben Arslan to activate parent tabs too 8 | * http://www.aidanlister.com/2014/03/persisting-the-tab-state-in-bootstrap/ 9 | */ 10 | (function($) { 11 | "use strict"; 12 | $.fn.rmarkdownStickyTabs = function() { 13 | var context = this; 14 | // Show the tab corresponding with the hash in the URL, or the first tab 15 | var showStuffFromHash = function() { 16 | var hash = window.location.hash; 17 | var selector = hash ? 'a[href="' + hash + '"]' : 'li.active > a'; 18 | var $selector = $(selector, context); 19 | if($selector.data('toggle') === "tab") { 20 | $selector.tab('show'); 21 | // walk up the ancestors of this element, show any hidden tabs 22 | $selector.parents('.section.tabset').each(function(i, elm) { 23 | var link = $('a[href="#' + $(elm).attr('id') + '"]'); 24 | if(link.data('toggle') === "tab") { 25 | link.tab("show"); 26 | } 27 | }); 28 | } 29 | }; 30 | 31 | 32 | // Set the correct tab when the page loads 33 | showStuffFromHash(context); 34 | 35 | // Set the correct tab when a user uses their back/forward button 36 | $(window).on('hashchange', function() { 37 | showStuffFromHash(context); 38 | }); 39 | 40 | // Change the URL when tabs are clicked 41 | $('a', context).on('click', function(e) { 42 | history.pushState(null, null, this.href); 43 | showStuffFromHash(context); 44 | }); 45 | 46 | return this; 47 | }; 48 | }(jQuery)); 49 | 50 | window.buildTabsets = function(tocID) { 51 | 52 | // build a tabset from a section div with the .tabset class 53 | function buildTabset(tabset) { 54 | 55 | // check for fade and pills options 56 | var fade = tabset.hasClass("tabset-fade"); 57 | var pills = tabset.hasClass("tabset-pills"); 58 | var navClass = pills ? "nav-pills" : "nav-tabs"; 59 | 60 | // determine the heading level of the tabset and tabs 61 | var match = tabset.attr('class').match(/level(\d) /); 62 | if (match === null) 63 | return; 64 | var tabsetLevel = Number(match[1]); 65 | var tabLevel = tabsetLevel + 1; 66 | 67 | // find all subheadings immediately below 68 | var tabs = tabset.find("div.section.level" + tabLevel); 69 | if (!tabs.length) 70 | return; 71 | 72 | // create tablist and tab-content elements 73 | var tabList = $(''); 74 | $(tabs[0]).before(tabList); 75 | var tabContent = $('
'); 76 | $(tabs[0]).before(tabContent); 77 | 78 | // build the tabset 79 | var activeTab = 0; 80 | tabs.each(function(i) { 81 | 82 | // get the tab div 83 | var tab = $(tabs[i]); 84 | 85 | // get the id then sanitize it for use with bootstrap tabs 86 | var id = tab.attr('id'); 87 | 88 | // see if this is marked as the active tab 89 | if (tab.hasClass('active')) 90 | activeTab = i; 91 | 92 | // remove any table of contents entries associated with 93 | // this ID (since we'll be removing the heading element) 94 | $("div#" + tocID + " li a[href='#" + id + "']").parent().remove(); 95 | 96 | // sanitize the id for use with bootstrap tabs 97 | id = id.replace(/[.\/?&!#<>]/g, '').replace(/\s/g, '_'); 98 | tab.attr('id', id); 99 | 100 | // get the heading element within it, grab it's text, then remove it 101 | var heading = tab.find('h' + tabLevel + ':first'); 102 | var headingText = heading.html(); 103 | heading.remove(); 104 | 105 | // build and append the tab list item 106 | var a = $('' + headingText + ''); 107 | a.attr('href', '#' + id); 108 | a.attr('aria-controls', id); 109 | var li = $('
  • '); 110 | li.append(a); 111 | tabList.append(li); 112 | 113 | // set it's attributes 114 | tab.attr('role', 'tabpanel'); 115 | tab.addClass('tab-pane'); 116 | tab.addClass('tabbed-pane'); 117 | if (fade) 118 | tab.addClass('fade'); 119 | 120 | // move it into the tab content div 121 | tab.detach().appendTo(tabContent); 122 | }); 123 | 124 | // set active tab 125 | $(tabList.children('li')[activeTab]).addClass('active'); 126 | var active = $(tabContent.children('div.section')[activeTab]); 127 | active.addClass('active'); 128 | if (fade) 129 | active.addClass('in'); 130 | 131 | if (tabset.hasClass("tabset-sticky")) 132 | tabset.rmarkdownStickyTabs(); 133 | } 134 | 135 | // convert section divs with the .tabset class to tabsets 136 | var tabsets = $("div.section.tabset"); 137 | tabsets.each(function(i) { 138 | buildTabset($(tabsets[i])); 139 | }); 140 | }; 141 | 142 | -------------------------------------------------------------------------------- /img/logo/safari-pinned-tab.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 7 | 8 | Created by potrace 1.11, written by Peter Selinger 2001-2013 9 | 10 | 12 | 58 | 61 | 64 | 66 | 69 | 71 | 73 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /0contactinfo.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Dr. Paul Schmidt" 3 | output: 4 | html_document: 5 | includes: 6 | in_header: header.html 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, echo=FALSE, warning=FALSE, message=FALSE} 11 | # formatting tables for html output 12 | options(knitr.kable.NA = '') 13 | pacman::p_load(kableExtra, formattable ,htmltools) 14 | pacman::p_load(tidyverse, conflicted) 15 | conflict_prefer("select", "dplyr") 16 | ``` 17 | 18 | ```{r import, echo=FALSE, warning=FALSE, message=FALSE} 19 | text <- read.table(file = "https://raw.githubusercontent.com/SchmidtPaul/CV/master/contactinfo/infotext.csv", sep = ";", header = T, encoding = "UTF-8") %>% 20 | rename(English = 1) %>% 21 | tibble 22 | 23 | workshops <- read.table(file = "https://raw.githubusercontent.com/SchmidtPaul/CV/master/contactinfo/workshophistory.csv", sep = ";", header = T, encoding = "UTF-8") %>% 24 | rename(Time = 1) %>% tibble 25 | ``` 26 | 27 | 28 | 53 | 54 | 55 | Avatar 56 | 57 | 58 | 61 | 62 |

    63 | 64 | Hamburg, Germany
    65 | 66 | Contact
    67 | 68 | 69 | schmidtpaul1989@outlook.com
    70 | 71 | 72 | GitHub
    73 | 74 | 75 | LinkedIn
    76 | 77 | 78 | ResearchGate
    79 | 80 | 81 | Xing 82 | 83 | Websites
    84 | 85 | 86 | DSFAIR: Data Science for Agriculture in R
    87 | 88 | 89 | MMFAIR: Mixed Models for Agriculture in R
    90 | 91 | 92 | CrashcouRse: R für Bio- und Agrarwissenschaftler
    93 | 94 | R-packages
    95 | 96 | 97 | CitaviR: A set of tools for dealing with Citavi data
    98 | 99 |

    100 | 101 | ```{r text, echo=FALSE, warning=FALSE, message=FALSE} 102 | text %>% 103 | kbl() %>% 104 | kable_styling() %>% 105 | row_spec(0, color = "lightgrey") 106 | ``` 107 | 108 | ```{r workshops, echo=FALSE, warning=FALSE, message=FALSE} 109 | GerFlagURL <- "https://cdn.countryflags.com/thumbs/germany/flag-round-250.png" 110 | USAFlagURL <- "https://cdn.countryflags.com/thumbs/united-states-of-america/flag-round-250.png" 111 | zoomLogoURL <- "https://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Zoom_Communications_Logo.svg/1200px-Zoom_Communications_Logo.svg.png" 112 | whiteURL <- "https://www.ict-solutions-events.com/wp-content/uploads/2020/03/plain-white-background-300x200.jpg" 113 | 114 | LangFlags <- workshops %>% 115 | select(Language) %>% 116 | mutate(LangURL = case_when(Language == "Ger" ~ GerFlagURL, 117 | Language == "Eng" ~ USAFlagURL, 118 | T ~ NA_character_)) %>% pull(LangURL) 119 | 120 | LocZoom <- workshops %>% 121 | select(Location) %>% 122 | mutate(LogoURL = case_when(str_detect(Location, "via") == T ~ zoomLogoURL, 123 | T ~ whiteURL)) %>% pull(LogoURL) 124 | 125 | workshops %>% 126 | select(-URL) %>% 127 | kbl(align = c("r", "l", "r", "r", "r"), ) %>% 128 | kable_minimal(full_width = T, font_size = 10, 129 | bootstrap_options = c("hover", "condensed")) %>% 130 | column_spec(1, width = "5em") %>% 131 | column_spec(3, width = "5em", 132 | image = spec_image(LangFlags, 50, 50)) %>% 133 | column_spec(4, width = "20em", 134 | image = spec_image(LocZoom, 100, 20)) %>% 135 | column_spec(5, width = "5em") 136 | ``` 137 | -------------------------------------------------------------------------------- /sources.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "MMFAIR sources" 3 | output: 4 | html_document: 5 | includes: 6 | in_header: header.html 7 | after_body: footer.html 8 | params: 9 | hilang: 10 | - sas 11 | --- 12 | 13 | # Links & References {.tabset .tabset-fade .tabset-pills} 14 | 15 | ## Packages 16 | 17 | ### Mixed Model 18 | 19 | #### lme4 20 | * [Reference manual](https://cran.r-project.org/web/packages/lme4/lme4.pdf){target="_blank"} 21 | * Vignettes 22 | + [lmer Performance Tips](https://cran.r-project.org/web/packages/lme4/vignettes/lmerperf.html){target="_blank"} 23 | + [Fitting Linear Mixed-Effects Models using lme4](https://cran.r-project.org/web/packages/lme4/vignettes/lmer.pdf){target="_blank"} 24 | + [PLS vs GLS for LMMs](https://cran.r-project.org/web/packages/lme4/vignettes/PLSvGLS.pdf){target="_blank"} 25 | + [Computational Methods](https://cran.r-project.org/web/packages/lme4/vignettes/Theory.pdf){target="_blank"} 26 | 27 | #### glmmTMB 28 | * [Reference manual](https://cran.r-project.org/web/packages/glmmTMB/glmmTMB.pdf){target="_blank"} 29 | * Vignettes 30 | + [random effect structures](https://cran.r-project.org/web/packages/glmmTMB/vignettes/covstruct.html){target="_blank"} 31 | + [post-hoc MCMC](https://cran.r-project.org/web/packages/glmmTMB/vignettes/mcmc.html){target="_blank"} 32 | + [miscellaneous examples](https://cran.r-project.org/web/packages/glmmTMB/vignettes/miscEx.html){target="_blank"} 33 | + [parallel optimization](https://cran.r-project.org/web/packages/glmmTMB/vignettes/parallel.html){target="_blank"} 34 | + [simulate](https://cran.r-project.org/web/packages/glmmTMB/vignettes/sim.html){target="_blank"} 35 | + [troubleshooting](https://cran.r-project.org/web/packages/glmmTMB/vignettes/troubleshooting.html){target="_blank"} 36 | + [basic examples of glmmTMB usage](https://cran.r-project.org/web/packages/glmmTMB/vignettes/glmmTMB.pdf){target="_blank"} 37 | + [model evaluation](https://cran.r-project.org/web/packages/glmmTMB/vignettes/model_evaluation.pdf){target="_blank"} 38 | 39 | #### nlme 40 | * [Reference manual](https://cran.r-project.org/web/packages/nlme/nlme.pdf){target="_blank"} 41 | * Vignettes: none 42 | 43 | #### sommer 44 | * [Reference manual](https://cran.r-project.org/web/packages/sommer/sommer.pdf){target="_blank"} 45 | * Vignettes 46 | + [FAQ for the sommer package](https://cran.r-project.org/web/packages/sommer/vignettes/sommer.FAQ.pdf){target="_blank"} 47 | + [Quantitative genetics using the sommer package](https://cran.r-project.org/web/packages/sommer/vignettes/sommer.pdf){target="_blank"} 48 | + [Moving to newer versions of sommer](https://cran.r-project.org/web/packages/sommer/vignettes/sommer.changes.pdf){target="_blank"} 49 | + [Quick start for the sommer package](https://cran.r-project.org/web/packages/sommer/vignettes/sommer.start.pdf){target="_blank"} 50 | 51 | ### Helper Packages 52 | 53 | #### AICcmodavg 54 | * [Reference manual](https://cran.r-project.org/web/packages/AICcmodavg/AICcmodavg.pdf){target="_blank"} 55 | * Vignettes: none 56 | 57 | #### broom.mixed 58 | * [Reference manual](https://cran.r-project.org/web/packages/broom.mixed/broom.mixed.pdf){target="_blank"} 59 | * Vignettes 60 | + [introduction to broom.mixed](https://cran.r-project.org/web/packages/broom.mixed/vignettes/broom_mixed_intro.html){target="_blank"} 61 | 62 | #### mixedup 63 | * [github repositroy](https://github.com/m-clark/mixedup){target="_blank"} 64 | * Vignettes 65 | + [For more details and examples see here](https://m-clark.github.io/mixedup/){target="_blank"} 66 | 67 | ### Data/Examples 68 | 69 | #### agridat 70 | * [Reference manual](https://cran.r-project.org/web/packages/agridat/agridat.pdf){target="_blank"} 71 | * Vignettes 72 | + [Additional agricultural data](https://cran.r-project.org/web/packages/agridat/vignettes/agridat_data.html){target="_blank"} 73 | + [Graphical Gems in the agridat Package](https://cran.r-project.org/web/packages/agridat/vignettes/agridat_examples.html){target="_blank"} 74 | + [Using Papadakis covariates for nearest neighbor analysis](https://cran.r-project.org/web/packages/agridat/vignettes/agridat_papadakis.html){target="_blank"} 75 | 76 | #### agritutorial 77 | * [Reference manual](https://cran.r-project.org/web/packages/agriTutorial/agriTutorial.pdf){target="_blank"} 78 | * Vignettes 79 | + [Tutorial Analysis of Some Agricultural Experiments](https://cran.r-project.org/web/packages/agriTutorial/vignettes/agriTutorialVignette.pdf){target="_blank"} 80 | 81 | 82 | ## Publications 83 | [Buntaran, Harimurti, et al. (2020). Cross‐validation of stage‐wise mixed‐model analysis of Swedish variety trials with winter wheat and spring barley. Crop Science.](https://acsess.onlinelibrary.wiley.com/doi/full/10.1002/csc2.20177){target="_blank"} 84 | 85 | [Piepho, H. P. (2009). Data transformation in statistical analysis of field trials with changing treatment variance. Agronomy Journal, 101(4), 865-869.](https://acsess.onlinelibrary.wiley.com/doi/abs/10.2134/agronj2008.0226x){target="_blank"} 86 | 87 | [Piepho, H. P. & Edmondson, R. N. (2018). A tutorial on the statistical analysis of factorial experiments with qualitative and quantitative treatment factor levels. Journal of Agronomy and Crop Science 204(5): 429-455.](https://onlinelibrary.wiley.com/doi/full/10.1111/jac.12267){target="_blank"} 88 | 89 | ## Websites 90 | ["GLMM FAQ"](http://bbolker.github.io/mixedmodels-misc/glmmFAQ.html){target="_blank"} by Ben Bolker and others 91 | 92 | ["Mixed Models with R"](https://m-clark.github.io/mixed-models-with-R/introduction.html){target="_blank"} by Michael Clark 93 | 94 | ## Contributions 95 | **Proofreader** 96 | 97 | * [Muhammad Afzal](https://www.linkedin.com/in/mafzal2/){target="_blank"} 98 | * [Harimurti Buntaran](https://www.linkedin.com/in/harimurti-buntaran/){target="_blank"} 99 | 100 | ## Session Info 101 | ```{r, echo=FALSE} 102 | sessionInfo() 103 | ``` -------------------------------------------------------------------------------- /index.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Mixed Models for Agriculture in R" 3 | output: 4 | html_document: 5 | includes: 6 | in_header: header.html 7 | after_body: footer.html 8 | params: 9 | hilang: 10 | - sas 11 | --- 12 | ```{r echo=FALSE, message=FALSE, warning=FALSE} 13 | # packages for better formatting tables for html output 14 | library(kableExtra); library(formattable) 15 | library(dplyr); library(tibble); library(tidyr) 16 | ``` 17 | 18 | # Hi there!{.tabset .tabset-fade .tabset-pills} 19 | 20 | This is a project under construction. Our aim is to provide a cookbook with mixed model analyses of typical examples in life sciences (focus on agriculture/biology) and compare the possibilities or rather limitations of the R-packages 21 | 22 | * [`nlme`](https://CRAN.R-project.org/package=nlme){target="_blank"} 23 | * [`lme4`](https://CRAN.R-project.org/package=lme4){target="_blank"} 24 | * [`glmmTMB`](https://CRAN.R-project.org/package=glmmTMB){target="_blank"} 25 | * [`sommer`](https://CRAN.R-project.org/package=sommer){target="_blank"} 26 | 27 | to each other, but also to SAS' [`PROC MIXED`](https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_mixed_syntax.htm&docsetVersion=14.3&locale=en){target="_blank"}. 28 | 29 | Find chapters by navigating the menu at the top of the page. Each chapter focuses on a certain aspect of mixed modelling. Within each chapter, switch between tabs with codes from the different packages via these buttons: 30 | 31 | ## nlme 32 | ## lme4 33 | ## glmmTMB 34 | ## sommer 35 | ## SAS 36 | 37 | # Chapters 38 | 39 | ```{r echo=FALSE, message=FALSE, warning=FALSE} 40 | contents <- rbind( 41 | c("R-side", "Heterogeneous err. var.", "yes", "no", "kind of", "yes", "yes"), 42 | c("R-side", "First-order autoregressive", "yes", "no", "kind of", "not really", "yes"), 43 | c("R-side", "Fixed scalar (Smith's weights)", "in progress", "in progress", "in progress", "in progress", "yes"), 44 | c("R-side", "Fixed matrix (fully efficient weighting)", "in progress", "in progress", "in progress", "in progress", "yes"), 45 | c("G-side", "Fixed matrix (kinship/pedigree)", "in progress", "in progress", "in progress", "in progress", "in progress"), 46 | c("G-side", "Unstructured", "in progress", "in progress", "in progress", "in progress", "in progress"), 47 | c("G-side", "First-order factor analytic", "in progress", "in progress", "in progress", "in progress", "in progress"), 48 | c("ModelFit", "log-likelihood, AIC, BIC", "in progress", "in progress", "in progress", "in progress", "in progress"), 49 | c("ANOVA", "with DF adjustments", "in progress", "in progress", "in progress", "in progress", "in progress"), 50 | c("BLUPs", "raw/conditional predicted()", "in progress", "in progress", "in progress", "in progress", "in progress"), 51 | c("BLUEs", "raw/conditional emmeans()", "in progress", "in progress", "in progress", "in progress", "in progress"), 52 | c("Extract", "estimated R-side matrix", "in progress", "in progress", "in progress", "in progress", "in progress"), 53 | c("Extract", "estimated G-side matrix", "in progress", "in progress", "in progress", "in progress", "in progress"), 54 | c("Extract", "MMEq solutions", "in progress", "in progress", "in progress", "in progress", "in progress") 55 | 56 | ) %>% data.frame 57 | 58 | 59 | names(contents) <- c("Topic", "Chapter", "nlme", "lme4", "glmmTMB", "sommer", "SAS") 60 | 61 | contents %>% 62 | #mutate_at(vars(Topic:Chapter), ~cell_spec(., bold=TRUE)) %>% 63 | mutate_at(vars(nlme:SAS), 64 | ~cell_spec(., 65 | color=case_when(.=="in progress" ~ "#003f75ff", 66 | TRUE ~ "white"), 67 | background=case_when(.=="yes" ~ "green", 68 | .=="kind of" ~ "#7CB342", 69 | .=="not really" ~ "#FB8C00", 70 | .=="no" ~ "red", 71 | TRUE ~ "white"))) %>% 72 | kable(escape = FALSE) %>% 73 | kable_styling(bootstrap_options = c("hover","responsive"), 74 | position = "left", 75 | full_width = FALSE) %>% 76 | column_spec(1, bold = T) %>% 77 | collapse_rows(columns=1, valign = "top") %>% 78 | add_header_above(c(" ", " ", "Possible in"=5)) 79 | ``` 80 | 81 |
    82 | 83 | # Approach 84 | In addition to the *chapters*, there are *summaries* for certain topics where we felt additional info may be beneficial, but should not bloat the chapters themselves. Just like chapters, summaries can be found by navigating the menu at the top of the page. 85 | 86 | Where possible, we try to use example data/analyses for our chapters that have been published in peer-reviewed journals. 87 | 88 | In terms of R syntax, we generally try to follow the approach presented on the ["R for Data Science" website](https://r4ds.had.co.nz/){target="_blank"}, making use of: 89 | 90 | [](https://CRAN.R-project.org/package=dplyr) 91 | [](https://CRAN.R-project.org/package=ggplot2) 92 | [](https://r4ds.had.co.nz/pipes.html) 93 | [](https://CRAN.R-project.org/package=purrr) 94 | [](https://CRAN.R-project.org/package=scales) 95 | [](https://CRAN.R-project.org/package=stringr) 96 | [](https://CRAN.R-project.org/package=tibble) 97 | [](https://CRAN.R-project.org/package=tidyr) 98 | [](https://CRAN.R-project.org/package=tidyverse) 99 | -------------------------------------------------------------------------------- /site_libs/lightable-0.0.1/lightable.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * lightable v0.0.1 3 | * Copyright 2020 Hao Zhu 4 | * Licensed under MIT (https://github.com/haozhu233/kableExtra/blob/master/LICENSE) 5 | */ 6 | 7 | .lightable-minimal { 8 | border-collapse: separate; 9 | border-spacing: 16px 1px; 10 | width: 100%; 11 | margin-bottom: 10px; 12 | } 13 | 14 | .lightable-minimal td { 15 | margin-left: 5px; 16 | margin-right: 5px; 17 | } 18 | 19 | .lightable-minimal th { 20 | margin-left: 5px; 21 | margin-right: 5px; 22 | } 23 | 24 | .lightable-minimal thead tr:last-child th { 25 | border-bottom: 2px solid #00000050; 26 | empty-cells: hide; 27 | 28 | } 29 | 30 | .lightable-minimal tbody tr:first-child td { 31 | padding-top: 0.5em; 32 | } 33 | 34 | .lightable-minimal.lightable-hover tbody tr:hover { 35 | background-color: #f5f5f5; 36 | } 37 | 38 | .lightable-minimal.lightable-striped tbody tr:nth-child(even) { 39 | background-color: #f5f5f5; 40 | } 41 | 42 | .lightable-classic { 43 | border-top: 0.16em solid #111111; 44 | border-bottom: 0.16em solid #111111; 45 | width: 100%; 46 | margin-bottom: 10px; 47 | margin: 10px 5px; 48 | } 49 | 50 | .lightable-classic tfoot tr td { 51 | border: 0; 52 | } 53 | 54 | .lightable-classic tfoot tr:first-child td { 55 | border-top: 0.14em solid #111111; 56 | } 57 | 58 | .lightable-classic caption { 59 | color: #222222; 60 | } 61 | 62 | .lightable-classic td { 63 | padding-left: 5px; 64 | padding-right: 5px; 65 | color: #222222; 66 | } 67 | 68 | .lightable-classic th { 69 | padding-left: 5px; 70 | padding-right: 5px; 71 | font-weight: normal; 72 | color: #222222; 73 | } 74 | 75 | .lightable-classic thead tr:last-child th { 76 | border-bottom: 0.10em solid #111111; 77 | } 78 | 79 | .lightable-classic.lightable-hover tbody tr:hover { 80 | background-color: #F9EEC1; 81 | } 82 | 83 | .lightable-classic.lightable-striped tbody tr:nth-child(even) { 84 | background-color: #f5f5f5; 85 | } 86 | 87 | .lightable-classic-2 { 88 | border-top: 3px double #111111; 89 | border-bottom: 3px double #111111; 90 | width: 100%; 91 | margin-bottom: 10px; 92 | } 93 | 94 | .lightable-classic-2 tfoot tr td { 95 | border: 0; 96 | } 97 | 98 | .lightable-classic-2 tfoot tr:first-child td { 99 | border-top: 3px double #111111; 100 | } 101 | 102 | .lightable-classic-2 caption { 103 | color: #222222; 104 | } 105 | 106 | .lightable-classic-2 td { 107 | padding-left: 5px; 108 | padding-right: 5px; 109 | color: #222222; 110 | } 111 | 112 | .lightable-classic-2 th { 113 | padding-left: 5px; 114 | padding-right: 5px; 115 | font-weight: normal; 116 | color: #222222; 117 | } 118 | 119 | .lightable-classic-2 tbody tr:last-child td { 120 | border-bottom: 3px double #111111; 121 | } 122 | 123 | .lightable-classic-2 thead tr:last-child th { 124 | border-bottom: 1px solid #111111; 125 | } 126 | 127 | .lightable-classic-2.lightable-hover tbody tr:hover { 128 | background-color: #F9EEC1; 129 | } 130 | 131 | .lightable-classic-2.lightable-striped tbody tr:nth-child(even) { 132 | background-color: #f5f5f5; 133 | } 134 | 135 | .lightable-material { 136 | min-width: 100%; 137 | white-space: nowrap; 138 | table-layout: fixed; 139 | font-family: Roboto, sans-serif; 140 | border: 1px solid #EEE; 141 | border-collapse: collapse; 142 | margin-bottom: 10px; 143 | } 144 | 145 | .lightable-material tfoot tr td { 146 | border: 0; 147 | } 148 | 149 | .lightable-material tfoot tr:first-child td { 150 | border-top: 1px solid #EEE; 151 | } 152 | 153 | .lightable-material th { 154 | height: 56px; 155 | padding-left: 16px; 156 | padding-right: 16px; 157 | } 158 | 159 | .lightable-material td { 160 | height: 52px; 161 | padding-left: 16px; 162 | padding-right: 16px; 163 | border-top: 1px solid #eeeeee; 164 | } 165 | 166 | .lightable-material.lightable-hover tbody tr:hover { 167 | background-color: #f5f5f5; 168 | } 169 | 170 | .lightable-material.lightable-striped tbody tr:nth-child(even) { 171 | background-color: #f5f5f5; 172 | } 173 | 174 | .lightable-material.lightable-striped tbody td { 175 | border: 0; 176 | } 177 | 178 | .lightable-material.lightable-striped thead tr:last-child th { 179 | border-bottom: 1px solid #ddd; 180 | } 181 | 182 | .lightable-material-dark { 183 | min-width: 100%; 184 | white-space: nowrap; 185 | table-layout: fixed; 186 | font-family: Roboto, sans-serif; 187 | border: 1px solid #FFFFFF12; 188 | border-collapse: collapse; 189 | margin-bottom: 10px; 190 | background-color: #363640; 191 | } 192 | 193 | .lightable-material-dark tfoot tr td { 194 | border: 0; 195 | } 196 | 197 | .lightable-material-dark tfoot tr:first-child td { 198 | border-top: 1px solid #FFFFFF12; 199 | } 200 | 201 | .lightable-material-dark th { 202 | height: 56px; 203 | padding-left: 16px; 204 | padding-right: 16px; 205 | color: #FFFFFF60; 206 | } 207 | 208 | .lightable-material-dark td { 209 | height: 52px; 210 | padding-left: 16px; 211 | padding-right: 16px; 212 | color: #FFFFFF; 213 | border-top: 1px solid #FFFFFF12; 214 | } 215 | 216 | .lightable-material-dark.lightable-hover tbody tr:hover { 217 | background-color: #FFFFFF12; 218 | } 219 | 220 | .lightable-material-dark.lightable-striped tbody tr:nth-child(even) { 221 | background-color: #FFFFFF12; 222 | } 223 | 224 | .lightable-material-dark.lightable-striped tbody td { 225 | border: 0; 226 | } 227 | 228 | .lightable-material-dark.lightable-striped thead tr:last-child th { 229 | border-bottom: 1px solid #FFFFFF12; 230 | } 231 | 232 | .lightable-paper { 233 | width: 100%; 234 | margin-bottom: 10px; 235 | color: #444; 236 | } 237 | 238 | .lightable-paper tfoot tr td { 239 | border: 0; 240 | } 241 | 242 | .lightable-paper tfoot tr:first-child td { 243 | border-top: 1px solid #00000020; 244 | } 245 | 246 | .lightable-paper thead tr:last-child th { 247 | color: #666; 248 | vertical-align: bottom; 249 | border-bottom: 1px solid #00000020; 250 | line-height: 1.15em; 251 | padding: 10px 5px; 252 | } 253 | 254 | .lightable-paper td { 255 | vertical-align: middle; 256 | border-bottom: 1px solid #00000010; 257 | line-height: 1.15em; 258 | padding: 7px 5px; 259 | } 260 | 261 | .lightable-paper.lightable-hover tbody tr:hover { 262 | background-color: #F9EEC1; 263 | } 264 | 265 | .lightable-paper.lightable-striped tbody tr:nth-child(even) { 266 | background-color: #00000008; 267 | } 268 | 269 | .lightable-paper.lightable-striped tbody td { 270 | border: 0; 271 | } 272 | 273 | -------------------------------------------------------------------------------- /Rpurl/autoregressive_time_series.R: -------------------------------------------------------------------------------- 1 | params <- 2 | list(hilang = "sas") 3 | 4 | # packages 5 | pacman::p_load(conflicted, # package function conflicts 6 | dplyr, purrr, tibble, tidyr, stringr, # data handling 7 | gganimate, ggplot2, gifski, viridis, # plot 8 | nlme, lme4, glmmTMB, sommer, # mixed modelling 9 | AICcmodavg, mixedup) # mixed model extractions 10 | 11 | # package function conflicts 12 | conflict_prefer("filter", "dplyr") 13 | 14 | # data 15 | dat <- agriTutorial::sorghum %>% 16 | rename(block = Replicate, plot = factplot) %>% 17 | dplyr::select(y, variety, block, plot, factweek, varweek) %>% 18 | as_tibble() 19 | 20 | 21 | 22 | 23 | dat.wk1 <- dat %>% filter(factweek == "1") # subset data from first week only 24 | 25 | mod.wk1 <- lm(formula = y ~ variety + block, 26 | data = dat.wk1) 27 | 28 | mod.iid.nlme <- nlme::gls(model = y ~ factweek * (variety + block), 29 | correlation = NULL, # default, i.e. homoscedastic, independent errors 30 | data = dat) 31 | 32 | # Extract variance component estimates 33 | mod.iid.nlme.VC <- tibble(varstruct = "iid") %>% 34 | mutate(sigma = mod.iid.nlme$sigma) %>% 35 | mutate(Variance = sigma^2) 36 | 37 | 38 | dat <- dat %>% 39 | mutate(unit = 1:n() %>% as.factor) # new column with running number 40 | 41 | mod.iid.glmm <- glmmTMB(formula = y ~ factweek * (variety + block) 42 | + (1 | unit), # add random unit term to mimic error variance 43 | dispformula = ~ 0, # fix original error variance to 0 44 | REML = TRUE, # needs to be stated since default = ML 45 | data = dat) 46 | 47 | # Extract variance component estimates 48 | mod.iid.glmm.VC <- mod.iid.glmm %>% 49 | extract_vc(ci_scale = "var") 50 | 51 | 52 | mod.iid.somm <- mmer(fixed = y ~ factweek + variety + block + factweek:variety + factweek:block, 53 | rcov = ~ units, # default = iid 54 | data = dat, verbose=F) 55 | 56 | # Extract variance component estimates 57 | mod.iid.somm.VC <- summary(mod.iid.somm)$varcomp 58 | 59 | 60 | 61 | 62 | sasvc <- readr::read_delim("SAS/autoregressive_time_series_results_VC.txt", delim="\t") 63 | 64 | sasvciid <- sasvc %>% 65 | filter(mod=="iid") 66 | 67 | 68 | 69 | mod.ar1.nlme <- nlme::gls(model = y ~ factweek * (variety + block), 70 | correlation = corAR1(form = ~ varweek | plot), 71 | data = dat) 72 | 73 | # Extract variance component estimates 74 | mod.ar1.nlme.VC <- tibble(varstruct = "ar(1)") %>% 75 | mutate(sigma = mod.ar1.nlme$sigma, 76 | rho = coef(mod.ar1.nlme$modelStruct$corStruct, unconstrained = FALSE)) %>% 77 | mutate(Variance = sigma^2, 78 | Corr1wk = rho, 79 | Corr2wks = rho^2, 80 | Corr3wks = rho^3, 81 | Corr4wks = rho^4) 82 | 83 | 84 | mod.ar1.glmm <- glmmTMB(formula = y ~ factweek * (variety + block) 85 | + ar1(factweek + 0 | plot), # add ar1 structure as random term to mimic error variance 86 | dispformula = ~ 0, # fix original error variance to 0 87 | REML = TRUE, # needs to be stated since default = ML 88 | data = dat) 89 | 90 | # Extract variance component estimates 91 | mod.ar1.glmm.VC <- mod.ar1.glmm %>% 92 | extract_vc(ci_scale = "var", show_cor = TRUE) 93 | 94 | 95 | fixed.rho <- 0.7 # random guess 96 | 97 | mod.ar1.somm <- mmer(fixed = y ~ factweek + variety + block + factweek:variety + factweek:block, 98 | random = ~ vs(factweek, Gu = AR1(factweek, rho = fixed.rho)), 99 | rcov = ~ units, # default = iid 100 | data = dat, verbose=F) 101 | 102 | # Extract variance component estimates 103 | mod.ar1.somm.VC <- summary(mod.ar1.somm)$varcomp 104 | 105 | 106 | 107 | 108 | sasvcar1 <- sasvc %>% 109 | filter(mod=="ar1") 110 | 111 | 112 | 113 | AIC.nlme <- aictab(list(mod.iid.nlme, mod.ar1.nlme), modnames = c("iid", "ar1")) 114 | 115 | 116 | AIC.glmm <- aictab(list(mod.iid.glmm, mod.ar1.glmm), modnames = c("iid", "ar1")) 117 | 118 | 119 | somm.mods <- list(mod.iid.somm, mod.ar1.somm) 120 | 121 | AIC.somm <- tibble( 122 | Modnames = c("iid", "ar1"), 123 | AIC = somm.mods %>% map("AIC") %>% unlist, 124 | LL = somm.mods %>% map("monitor") %>% lapply(. %>% `[`(1, ncol(.))) %>% unlist) %>% # last element in first row of "monitor" 125 | arrange(AIC) 126 | 127 | 128 | sasaic <- readr::read_delim("SAS/autoregressive_time_series_results_AIC.txt", delim="\t") %>% 129 | mutate(Descr = str_remove(Descr, "\\s*\\([^\\)]+\\)") %>% str_trim) %>% 130 | pivot_wider(names_from=Descr, values_from=Value) 131 | 132 | 133 | 134 | tibble(mod="iid", estimate="variance") %>% 135 | cbind(., 136 | mod.iid.nlme.VC %>% dplyr::select(Variance) %>% rename(nlme=Variance), 137 | mod.iid.nlme.VC %>% mutate(lme4=NA) %>% dplyr::select(lme4), 138 | mod.iid.glmm.VC %>% filter(effect=="Intercept") %>% dplyr::select(variance) %>% rename(glmmTMB=variance), 139 | mod.iid.somm.VC %>% dplyr::select(VarComp) %>% rename(sommer=VarComp), 140 | sasvc %>% filter(mod=="iid") %>% dplyr::select(Estimate) %>% rename(SAS=Estimate)) %>% 141 | magrittr::set_rownames(NULL) %>% 142 | kable(escape = FALSE) %>% 143 | kable_styling(bootstrap_options = c("bordered", "hover", "condensed", "responsive"), 144 | full_width = FALSE) 145 | 146 | tibble(mod=c("ar1", "ar1"), estimate=c("variance", "correlation")) %>% 147 | cbind(., 148 | mod.ar1.nlme.VC %>% dplyr::select(Variance, rho) %>% 149 | pivot_longer(names_to = "estimate", values_to = "nlme", cols = 1:2) %>% 150 | dplyr::select(nlme), 151 | tibble(lme4=c(NA, NA)), 152 | tibble(glmmTMB= 153 | c(mod.ar1.glmm.VC %>% 154 | pluck("Variance Components") %>% 155 | filter(effect=="factweek1") %>% 156 | dplyr::select(variance), 157 | mod.ar1.glmm.VC %>% 158 | pluck("Cor") %>% pluck("plot") %>% 159 | pluck(2,1))%>% unlist), 160 | tibble(sommer=c(NA, NA)), 161 | sasvc %>% 162 | arrange(desc(CovParm)) %>% 163 | filter(mod=="ar1") %>% 164 | dplyr::select(Estimate) %>% 165 | rename(SAS=Estimate)) %>% 166 | kable(escape = FALSE) %>% 167 | kable_styling(bootstrap_options = c("bordered", "hover", "condensed", "responsive"), 168 | full_width = FALSE) 169 | 170 | tibble(mod=c("iid", "ar1"), estimate=c("AIC", "AIC")) %>% 171 | cbind(., 172 | AIC.nlme %>% dplyr::select(AICc) %>% rename(nlme=AICc), 173 | tibble(lme4=c(NA, NA)), 174 | AIC.glmm %>% dplyr::select(AICc) %>% rename(glmmTMB=AICc), 175 | tibble(sommer=c(AIC.somm %>% filter(Modnames=="iid") %>% pull(AIC), NA)), 176 | sasaic %>% dplyr::select(AIC) %>% rename(SAS=AIC)) %>% 177 | kable(escape = FALSE) %>% 178 | kable_styling(bootstrap_options = c("bordered", "hover", "condensed", "responsive"), 179 | full_width = FALSE) 180 | -------------------------------------------------------------------------------- /.Rproj.user/584CA4EF/sources/per/t/D1DB82FB-contents: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Heterogeneous error variance" 3 | output: 4 | html_document: 5 | includes: 6 | after_body: footer.html 7 | --- 8 | 9 | **packages & data** 10 | ```{r, echo=FALSE, message=FALSE, warning=FALSE} 11 | # packages for better formatting tables for html output 12 | library(kableExtra) 13 | library(formattable) 14 | ``` 15 | 16 | 17 | ```{r} 18 | pacman::p_load(dplyr, tibble, # packages for data handling 19 | nlme, lme4, glmmTMB, sommer) # packages for mixed models 20 | 21 | dat <- agridat::mcconway.turnip %>% 22 | as_tibble() %>% 23 | mutate(densf = as.factor(density)) 24 | ``` 25 | 26 | # Motivation 27 | This is a randomized complete block design (4 blocks) with three treatment factors: genotype, date and density, leading to 16 treatment combinations (2 genotypes, 2 planting dates, 4 densities) [(Piepho, 2009)](https://acsess.onlinelibrary.wiley.com/doi/abs/10.2134/agronj2008.0226x). It can be argued that heterogeneous error variances (*i.e.* heteroscedasticity) for two of the treatments should be considered: 28 | 29 | ```{r, out.width=c('50%', '50%'), fig.show='hold'} 30 | boxplot(yield ~ date, data=dat) 31 | boxplot(yield ~ density, data=dat) 32 | ``` 33 | 34 | # 4 Models {.tabset .tabset-fade .tabset-pills} 35 | We therefore set up 4 models, which only differ in the variance structure of the errors. More specifically, we allow for heterogeneous error variances / heteroscedascity per group for the effct levels of Date and Density. 36 | ```{r, echo=FALSE} 37 | tibble(Model = paste0("mod", 1:4) %>% cell_spec(bold=T), 38 | Block = "Identity", 39 | Genotype = "Identity", 40 | Density = c("Identity", "Identity", "Diagonal", "Diagonal"), 41 | Date = c("Identity", "Diagonal", "Identity", "Diagonal")) %>% 42 | mutate(Density = ifelse(Density=="Diagonal", cell_spec(Density, bold=T), Density), 43 | Date = ifelse( Date=="Diagonal", cell_spec(Date, bold=T), Date)) %>% 44 | kable(escape = FALSE) %>% 45 | kable_styling(bootstrap_options = c("striped", "hover"), 46 | full_width = FALSE) %>% 47 | add_header_above(c(" ", "Term in multiplicative variance structure"=4)) 48 | ``` 49 | 50 | ## nlme 51 | To accomplish this, we need to use the *variance function* `varIdent()` in the `weights=` statement, which is *used to allow different variances according to thelevels of a classification factor*. This variance structures is sometimes also referred to as *diagonal*. In model number 4 we are allowing for heterogeneous error variances for both dates and densities, which is done by combining two variance functions via `varComb()`: 52 | 53 | ```{r} 54 | mod1.nlme <- nlme::lme(fixed = yield ~ gen * date * densf, 55 | random = ~ 1|block, 56 | weights = NULL, # default, i.e. homoscedastic errors 57 | data = dat) 58 | 59 | mod2.nlme <- mod1.nlme %>% 60 | update(weights = varIdent(form=~1|densf)) # one error variance per density 61 | 62 | mod3.nlme <- mod1.nlme %>% 63 | update(weights = varIdent(form=~1|date)) # one error variance per date 64 | 65 | mod4.nlme <- mod1.nlme %>% 66 | update(weights = varComb(varIdent(form=~1|densf), # one error variance per 67 | varIdent(form=~1|date))) # density-date combination 68 | 69 | ``` 70 | 71 | ## lme4 72 | in progress 73 | 74 | ## glmmTMB 75 | in progress 76 | 77 | ## sommer 78 | in progress 79 | 80 | # Variance Components {.tabset .tabset-fade .tabset-pills} 81 | 82 | ## nlme 83 | As far as we know, it is quite cumbersome to extract the variance component estimates from `nlme`/`gls` objects (in a table format we are used to), even with helper packages such as `broom.mixed`. Beneath is the the most elegant approach we have so far when trying to get similarly formatted output for all 4 models. The general approach is to first get a table with a column for 84 | 85 | + all levels / level-combinations for which heterogeneous error variances were fit 86 | + their respective value of the model-object's `varStruct` and 87 | + the overall value of the model-object's `sigma`. 88 | 89 | By multiplying the latter two, we receive the respective standard error estimate, which needs to be squared in order to obtain the respective variance component estimate. 90 | 91 | ### mod1 92 | ```{r} 93 | mod1.nlme.VC <- tibble(grp="all", varStruct=1) %>% 94 | mutate(sigma = mod1.nlme$sigma) %>% 95 | mutate(StandardError = sigma*varStruct) %>% 96 | mutate(Variance = StandardError^2) 97 | ``` 98 | ```{r, echo=FALSE} 99 | mod1.nlme.VC %>% 100 | mutate_if(is.double, round, 3) %>% 101 | kable(escape = FALSE) %>% 102 | kable_styling(bootstrap_options = c("bordered", "hover"), 103 | full_width = FALSE) 104 | ``` 105 | 106 | ### mod2 107 | ```{r} 108 | mod2.nlme.VC <- mod2.nlme$modelStruct$varStruct %>% 109 | coef(unconstrained=FALSE, allCoef=TRUE) %>% 110 | enframe(name="grp", value="varStruct") %>% 111 | mutate(sigma = mod2.nlme$sigma) %>% 112 | mutate(StandardError = sigma*varStruct) %>% 113 | mutate(Variance = StandardError^2) 114 | ``` 115 | ```{r, echo=FALSE} 116 | mod2.nlme.VC %>% 117 | mutate_if(is.double, round, 3) %>% 118 | kable(escape = FALSE) %>% 119 | kable_styling(bootstrap_options = c("bordered", "hover"), 120 | full_width = FALSE) 121 | ``` 122 | 123 | ### mod3 124 | ```{r} 125 | mod3.nlme.VC <- mod3.nlme$modelStruct$varStruct %>% 126 | coef(unconstrained=FALSE, allCoef=TRUE) %>% 127 | enframe(name="grp", value="varStruct") %>% 128 | mutate(sigma = mod3.nlme$sigma) %>% 129 | mutate(StandardError = sigma*varStruct) %>% 130 | mutate(Variance = StandardError^2) 131 | ``` 132 | ```{r, echo=FALSE} 133 | mod3.nlme.VC %>% 134 | mutate_if(is.double, round, 3) %>% 135 | kable(escape = FALSE) %>% 136 | kable_styling(bootstrap_options = c("bordered", "hover"), 137 | full_width = FALSE) 138 | ``` 139 | 140 | ### mod4 141 | ```{r} 142 | mod4.nlme.varStruct.A <- mod4.nlme$modelStruct$varStruct$A %>% 143 | coef(unconstrained=FALSE, allCoef=TRUE) %>% 144 | enframe(name="grpA", value="varStructA") 145 | 146 | mod4.nlme.varStruct.B <- mod4.nlme$modelStruct$varStruct$B %>% 147 | coef(unconstrained=FALSE, allCoef=TRUE) %>% 148 | enframe(name="grpB", value="varStructB") 149 | 150 | mod4.nlme.VC <- expand.grid(mod4.nlme.varStruct.A$grpA, 151 | mod4.nlme.varStruct.B$grpB, 152 | stringsAsFactors=FALSE) %>% 153 | rename(grpA=Var1, grpB=Var2) %>% 154 | left_join(x=., y=mod4.nlme.varStruct.A, by="grpA") %>% 155 | left_join(x=., y=mod4.nlme.varStruct.B, by="grpB") %>% 156 | mutate(sigma = mod4.nlme$sigma) %>% 157 | mutate(StandardError = sigma*varStructA*varStructB) %>% 158 | mutate(Variance = StandardError^2) 159 | ``` 160 | ```{r, echo=FALSE} 161 | mod4.nlme.VC %>% 162 | mutate_if(is.double, round, 3) %>% 163 | kable(escape = FALSE) %>% 164 | kable_styling(bootstrap_options = c("bordered", "hover"), 165 | full_width = FALSE) 166 | ``` 167 | 168 | ## lme4 169 | in progress 170 | 171 | ## glmmTMB 172 | in progress 173 | 174 | ## sommer 175 | in progress 176 | 177 | # Model Fit {.tabset .tabset-fade .tabset-pills} 178 | As is standard procedure, we can do a model selection based on goodness-of-fit statistics such as the AIC. In order to have a direct comparison to Table 1 in [(Piepho, 2009)](https://acsess.onlinelibrary.wiley.com/doi/abs/10.2134/agronj2008.0226x), we also calculated the deviance (*i.e.* -2*loglikelihood) for each model. The code is shown for mod1: 179 | 180 | ## nlme 181 | 182 |
    183 | ```{r} 184 | mod1.nlme %>% AIC # AIC 185 | ``` 186 |
    187 | ```{r} 188 | -2 * logLik(mod1.nlme) %>% # Deviance 189 | as.double 190 | ``` 191 |
    192 | 193 | ```{r, echo=FALSE} 194 | tibble(Model = paste0("mod", 1:4), 195 | AIC = AIC(mod1.nlme,mod2.nlme,mod3.nlme,mod4.nlme)$AIC, 196 | Deviance = -2 * c(mod1.nlme %>% logLik, 197 | mod2.nlme %>% logLik, 198 | mod3.nlme %>% logLik, 199 | mod4.nlme %>% logLik) %>% as.double) %>% 200 | kable(escape = FALSE) %>% 201 | kable_styling(bootstrap_options = c("bordered", "hover"), 202 | full_width = FALSE) 203 | ``` 204 | 205 | ## lme4 206 | in progress 207 | 208 | ## glmmTMB 209 | in progress 210 | 211 | ## sommer 212 | in progress -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/jquery-ui.structure.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.11.4 - 2016-01-05 2 | * http://jqueryui.com 3 | * Copyright jQuery Foundation and other contributors; Licensed MIT */ 4 | 5 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-draggable-handle{-ms-touch-action:none;touch-action:none}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block;-ms-touch-action:none;touch-action:none}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable{-ms-touch-action:none;touch-action:none}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-sortable-handle{-ms-touch-action:none;touch-action:none}.ui-accordion .ui-accordion-header{display:block;cursor:pointer;position:relative;margin:2px 0 0 0;padding:.5em .5em .5em .7em;min-height:0;font-size:100%}.ui-accordion .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-icons .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-accordion-header-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;overflow:auto}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-button{display:inline-block;position:relative;padding:0;line-height:normal;margin-right:.1em;cursor:pointer;vertical-align:middle;text-align:center;overflow:visible}.ui-button,.ui-button:link,.ui-button:visited,.ui-button:hover,.ui-button:active{text-decoration:none}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:normal}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}input.ui-button::-moz-focus-inner,button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-dialog{overflow:hidden;position:absolute;top:0;left:0;padding:.2em;outline:0}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 0;white-space:nowrap;width:90%;overflow:hidden;text-overflow:ellipsis}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:20px;margin:-10px 0 0 0;padding:1px;height:20px}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:none;overflow:auto}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin-top:.5em;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:12px;height:12px;right:-5px;bottom:-5px;background-position:16px 16px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:none}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{position:relative;margin:0;padding:3px 1em 3px .4em;cursor:pointer;min-height:0;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0}.ui-progressbar{height:2em;text-align:left;overflow:hidden}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-progressbar .ui-progressbar-overlay{background:url("data:image/gif;base64,R0lGODlhKAAoAIABAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAQABACwAAAAAKAAoAAACkYwNqXrdC52DS06a7MFZI+4FHBCKoDeWKXqymPqGqxvJrXZbMx7Ttc+w9XgU2FB3lOyQRWET2IFGiU9m1frDVpxZZc6bfHwv4c1YXP6k1Vdy292Fb6UkuvFtXpvWSzA+HycXJHUXiGYIiMg2R6W459gnWGfHNdjIqDWVqemH2ekpObkpOlppWUqZiqr6edqqWQAAIfkECQEAAQAsAAAAACgAKAAAApSMgZnGfaqcg1E2uuzDmmHUBR8Qil95hiPKqWn3aqtLsS18y7G1SzNeowWBENtQd+T1JktP05nzPTdJZlR6vUxNWWjV+vUWhWNkWFwxl9VpZRedYcflIOLafaa28XdsH/ynlcc1uPVDZxQIR0K25+cICCmoqCe5mGhZOfeYSUh5yJcJyrkZWWpaR8doJ2o4NYq62lAAACH5BAkBAAEALAAAAAAoACgAAAKVDI4Yy22ZnINRNqosw0Bv7i1gyHUkFj7oSaWlu3ovC8GxNso5fluz3qLVhBVeT/Lz7ZTHyxL5dDalQWPVOsQWtRnuwXaFTj9jVVh8pma9JjZ4zYSj5ZOyma7uuolffh+IR5aW97cHuBUXKGKXlKjn+DiHWMcYJah4N0lYCMlJOXipGRr5qdgoSTrqWSq6WFl2ypoaUAAAIfkECQEAAQAsAAAAACgAKAAAApaEb6HLgd/iO7FNWtcFWe+ufODGjRfoiJ2akShbueb0wtI50zm02pbvwfWEMWBQ1zKGlLIhskiEPm9R6vRXxV4ZzWT2yHOGpWMyorblKlNp8HmHEb/lCXjcW7bmtXP8Xt229OVWR1fod2eWqNfHuMjXCPkIGNileOiImVmCOEmoSfn3yXlJWmoHGhqp6ilYuWYpmTqKUgAAIfkECQEAAQAsAAAAACgAKAAAApiEH6kb58biQ3FNWtMFWW3eNVcojuFGfqnZqSebuS06w5V80/X02pKe8zFwP6EFWOT1lDFk8rGERh1TTNOocQ61Hm4Xm2VexUHpzjymViHrFbiELsefVrn6XKfnt2Q9G/+Xdie499XHd2g4h7ioOGhXGJboGAnXSBnoBwKYyfioubZJ2Hn0RuRZaflZOil56Zp6iioKSXpUAAAh+QQJAQABACwAAAAAKAAoAAACkoQRqRvnxuI7kU1a1UU5bd5tnSeOZXhmn5lWK3qNTWvRdQxP8qvaC+/yaYQzXO7BMvaUEmJRd3TsiMAgswmNYrSgZdYrTX6tSHGZO73ezuAw2uxuQ+BbeZfMxsexY35+/Qe4J1inV0g4x3WHuMhIl2jXOKT2Q+VU5fgoSUI52VfZyfkJGkha6jmY+aaYdirq+lQAACH5BAkBAAEALAAAAAAoACgAAAKWBIKpYe0L3YNKToqswUlvznigd4wiR4KhZrKt9Upqip61i9E3vMvxRdHlbEFiEXfk9YARYxOZZD6VQ2pUunBmtRXo1Lf8hMVVcNl8JafV38aM2/Fu5V16Bn63r6xt97j09+MXSFi4BniGFae3hzbH9+hYBzkpuUh5aZmHuanZOZgIuvbGiNeomCnaxxap2upaCZsq+1kAACH5BAkBAAEALAAAAAAoACgAAAKXjI8By5zf4kOxTVrXNVlv1X0d8IGZGKLnNpYtm8Lr9cqVeuOSvfOW79D9aDHizNhDJidFZhNydEahOaDH6nomtJjp1tutKoNWkvA6JqfRVLHU/QUfau9l2x7G54d1fl995xcIGAdXqMfBNadoYrhH+Mg2KBlpVpbluCiXmMnZ2Sh4GBqJ+ckIOqqJ6LmKSllZmsoq6wpQAAAh+QQJAQABACwAAAAAKAAoAAAClYx/oLvoxuJDkU1a1YUZbJ59nSd2ZXhWqbRa2/gF8Gu2DY3iqs7yrq+xBYEkYvFSM8aSSObE+ZgRl1BHFZNr7pRCavZ5BW2142hY3AN/zWtsmf12p9XxxFl2lpLn1rseztfXZjdIWIf2s5dItwjYKBgo9yg5pHgzJXTEeGlZuenpyPmpGQoKOWkYmSpaSnqKileI2FAAACH5BAkBAAEALAAAAAAoACgAAAKVjB+gu+jG4kORTVrVhRlsnn2dJ3ZleFaptFrb+CXmO9OozeL5VfP99HvAWhpiUdcwkpBH3825AwYdU8xTqlLGhtCosArKMpvfa1mMRae9VvWZfeB2XfPkeLmm18lUcBj+p5dnN8jXZ3YIGEhYuOUn45aoCDkp16hl5IjYJvjWKcnoGQpqyPlpOhr3aElaqrq56Bq7VAAAOw==");height:100%;filter:alpha(opacity=25);opacity:0.25}.ui-progressbar-indeterminate .ui-progressbar-value{background-image:none}.ui-selectmenu-menu{padding:0;margin:0;position:absolute;top:0;left:0;display:none}.ui-selectmenu-menu .ui-menu{overflow:auto;overflow-x:hidden;padding-bottom:1px}.ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup{font-size:1em;font-weight:bold;line-height:1.5;padding:2px 0.4em;margin:0.5em 0 0 0;height:auto;border:0}.ui-selectmenu-open{display:block}.ui-selectmenu-button{display:inline-block;overflow:hidden;position:relative;text-decoration:none;cursor:pointer}.ui-selectmenu-button span.ui-icon{right:0.5em;left:auto;margin-top:-8px;position:absolute;top:50%}.ui-selectmenu-button span.ui-selectmenu-text{text-align:left;padding:0.4em 2.1em 0.4em 1em;display:block;line-height:1.4;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default;-ms-touch-action:none;touch-action:none}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider.ui-state-disabled .ui-slider-handle,.ui-slider.ui-state-disabled .ui-slider-range{filter:inherit}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-spinner{position:relative;display:inline-block;overflow:hidden;padding:0;vertical-align:middle}.ui-spinner-input{border:none;background:none;color:inherit;padding:0;margin:.2em 0;vertical-align:middle;margin-left:.4em;margin-right:22px}.ui-spinner-button{width:16px;height:50%;font-size:.5em;padding:0;margin:0;text-align:center;position:absolute;cursor:default;display:block;overflow:hidden;right:0}.ui-spinner a.ui-spinner-button{border-top:none;border-bottom:none;border-right:none}.ui-spinner .ui-icon{position:absolute;margin-top:-8px;top:50%;left:0}.ui-spinner-up{top:0}.ui-spinner-down{bottom:0}.ui-spinner .ui-icon-triangle-1-s{background-position:-65px -16px}.ui-tabs{position:relative;padding:.2em}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:0;margin:1px .2em 0 0;border-bottom-width:0;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav .ui-tabs-anchor{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-active{margin-bottom:-1px;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor,.ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor,.ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor{cursor:text}.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:none}.ui-tooltip{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}body .ui-tooltip{border-width:2px} -------------------------------------------------------------------------------- /weighted_two_stage.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Weighted two-stage analyses" 3 | output: 4 | html_document: 5 | includes: 6 | in_header: header.html 7 | after_body: footer.html 8 | params: 9 | hilang: 10 | - sas 11 | --- 12 | 13 | ```{r, echo=FALSE, message=FALSE, warning=FALSE, purl=FALSE} 14 | # markdown options 15 | options(knitr.kable.NA = '') # show NA as empty cells in output tables 16 | pacman::p_load(kableExtra, formattable, htmltools) # packages for better formatting tables for html output 17 | ``` 18 | 19 | ```{r, child="_hilang_setup.Rmd", purl=FALSE} 20 | # required for sas syntax highlighting 21 | ``` 22 | 23 | ```{r, message=FALSE} 24 | # packages 25 | pacman::p_load(dplyr, purrr, tibble, tidyr, stringr, # data handling 26 | nlme, lme4, glmmTMB, sommer, # mixed modelling 27 | AICcmodavg, mixedup) # mixed model extractions 28 | 29 | # data 30 | dat <- readr::read_csv("data/Winter Wheat 2016.csv") %>% 31 | dplyr::select(Year, everything()) %>% 32 | mutate_at(vars(Year:Cultivar), as.factor) 33 | ``` 34 | ```{r, echo=FALSE, purl=FALSE} 35 | dat %>% 36 | kable(escape = FALSE) %>% 37 | kable_styling(bootstrap_options = c("bordered", "hover", "condensed", "responsive"), 38 | full_width = FALSE) %>% 39 | scroll_box(height = "200px") 40 | ``` 41 | 42 | # Motivation 43 | 44 | This chapter deals with a topic that may not be familiar to many readers, but it was very important to us before and during our PhD, which was in the field of biostatistics/data science for plant breeding and other agricultural fields. Therefore, we here give a very brief summary: 45 | 46 | A **two-stage analysis** is really just that: Trying to analyze a dataset not via a single model (in a single step), but in two separate stages/steps, where the output of the first stage/model is the input for the second stage/model. The motivation for doing a two-stage analysis for us was ever so often that data from a multi-environment-trial (MET) needed to be analyzed. An environment here refers to a year-location-combination, so that when multiple trials are set up at multiple locations and/or over multiple years we have a MET. Strictly speaking, data from a MET does not necessarily call for a two-stage analysis, but can indeed often just be analyzed in a single-stage analysis. However, there are arguments that speak for a two-stage analysis, such as the lower amount of required computational power and more dynamic/intuitive analyses of the single environments. For more info see SOURCES. 47 | 48 | ## Example 49 | 50 | The example in this chapter is taken from [Buntaran et al. (2020)](https://acsess.onlinelibrary.wiley.com/doi/full/10.1002/csc2.20177){target="_blank"}. It considers data from a multi-environment trial with winter wheat varieties. The trial took place in 2016 across 18 locations in Sweden. Dry matter yield was analyzed. All trials were laid out as $\alpha$-designs with two replicates. Within each replicate, there were five to seven incomplete blocks. Sweden is divided into three different agricultural zones: South, Middle, and North. A zone is represented by a number of locations. The set of cultivars was the same across locations. 51 | 52 | # Modelling in two stages 53 | 54 | In Stage I, the cultivar means per location are estimated via best linear unbiased estimation (BLUE). This is done via fitting a linear mixed model separately for each location and taking the cultivar effect as fixed. Thus, we obtain one adjusted mean yield value for each cultivar at each location. 55 | 56 | In Stage II, the cultivar means obtained in Stage II serve as the response and 57 | 58 | > In such a two-stage approach, the cultivar main effect should be taken as fixed in Stage I in order to avoid double shrinkage ([Damesa et al., 2017](https://acsess.onlinelibrary.wiley.com/doi/abs/10.2134/agronj2016.07.0395){target="_blank"}; [Piepho et al., 2012](https://onlinelibrary.wiley.com/doi/abs/10.1002/bimj.201100219){target="_blank"}). 59 | 60 | ## Stage I {.tabset .tabset-fade .tabset-pills} 61 | 62 | ### nlme 63 | 64 | in progress, but probably not possible (?) 65 | 66 | ### lme4 67 | 68 | in progress, but probably not possible (?) 69 | 70 | ### glmmTMB 71 | 72 | in progress, but probably not possible (?) 73 | 74 | ### sommer 75 | 76 | in progress, but probably not possible (?) 77 | 78 | ### SAS {.active} 79 | 80 | In order to analyze each location separately in SAS, we can use the `BY` statement. However, the dataset must then also be sorted accordingly - in this case by `Zone Location`. 81 | 82 | In order to obtain the adjusted cultivar means, we take `Cultivar` as a fixed effect in the model and add the `LSMEANS Cultivar;` statement. Furthermore, adding `ODS OUTPUT LSMeans = stageIout_CultivarMeans;` saves the means into an object called `stageIout_CultivarMeans`. 83 | 84 | ```{r, eval=FALSE, hilang="sas", purl=FALSE} 85 | PROC SORT DATA=winterwheat; BY Zone Location Cultivar Rep Alpha; RUN; 86 | PROC MIXED DATA=winterwheat LOGNOTE; 87 | BY Zone Location; 88 | CLASS Cultivar Rep Alpha; 89 | MODEL Yield = Cultivar / DDFM=KR; 90 | RANDOM Rep Rep*Alpha; 91 | LSMEANS Cultivar / COV; 92 | ODS OUTPUT LSMeans = stageIout_CultivarMeans; 93 | RUN; 94 | ``` 95 | 96 | Notice that we also add `/COV;` to the `LSMEANS` statement. This is necessary for the Smith's weights weighting approach, as it provides us with the estimated covariance matrix of the adjusted means and saves it, together with the means, into the `stageIout_CultivarMeans` object. 97 | 98 | ## Stage II {.tabset .tabset-fade} 99 | 100 | ### Unweighted (not recommended) {.tabset .tabset-fade .tabset-pills} 101 | 102 | #### nlme 103 | 104 | in progress 105 | 106 | #### lme4 107 | 108 | in progress 109 | 110 | #### glmmTMB 111 | 112 | in progress 113 | 114 | #### sommer 115 | 116 | in progress 117 | 118 | #### SAS 119 | 120 | in progress 121 | 122 | ### Smith's Weights {.tabset .tabset-fade .tabset-pills .active} 123 | 124 | #### nlme 125 | 126 | in progress, but probably not possible (?) 127 | 128 | #### lme4 129 | 130 | in progress, but probably not possible (?) 131 | 132 | #### glmmTMB 133 | 134 | in progress, but probably not possible (?) 135 | 136 | #### sommer 137 | 138 | in progress, but probably not possible (?) 139 | 140 | #### SAS {.active} 141 | 142 | At this point we can conveniently make use of a [SAS-macro](https://blogs.sas.com/content/sgf/2020/04/22/how-to-create-and-use-sas-macro-functions/){target="_blank"} that is described in more detail in [Damesa et al., 2017](https://acsess.onlinelibrary.wiley.com/doi/abs/10.2134/agronj2016.07.0395){target="_blank"} and can be found in their supplemental material. Note that a copy of it can also be found [on github](https://github.com/SchmidtPaul/utilities/tree/master/SAS%20macros){target="_blank"} which makes its use in SAS via URL very convenient: 143 | 144 | ```{r, eval=FALSE, hilang="sas", purl=FALSE} 145 | FILENAME smith URL 146 | "https://raw.githubusercontent.com/SchmidtPaul/utilities/master/SAS%20macros/get_Smith_weights.sas"; 147 | %INCLUDE smith; 148 | 149 | %get_smith_weights(data=stageIout_CultivarMeans, 150 | entry=Cultivar, by=Zone, by2=Location, 151 | outL=stageIIin_CultivarMeans); 152 | ``` 153 | 154 | As can be seen, the macro `%get_smith_weights` basically needs the `stageIout_CultivarMeans` object as input, the name of the (main) effect for which means were calculated (*i.e.* `Cultivar`), as well as the variables that were used in the `BY` statement in Stage I. It then produces a `stageIIin_CultivarMeans` object that serves as the dataset in Stage II with an additional column `weight_Smith` with the desired weights. 155 | 156 | There are three things to consider when modelling the Smith's weights approach in SAS: 157 | 158 | 1. The `WEIGHT weight_Smith;` statement, which provides the name of the column that holds the weights 159 | 160 | 2. The `REPEATED;` statement must be provided, as it [directly changes how](https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_mixed_sect020.htm){target="_blank"} the `WEIGHT` statement operates 161 | 162 | 3. The `PARMS ...(1) /HOLD=n` statement makes sure that the error variance is forced to be equal to 1. Notice that the number of parameters (and thus the number of `(1)` that are required in the statement) differ between models. However, there must always at least be one, *i.e.* the error variance, and it will always be the last one in the `PARMS` statement. In this case the model has 5 parameters, *i.e.* variance components for the random effects `Cultivar`, `Zone:Cultivar`, `Zone:Location:Cultivar` and `Zone:Location` and for the error term. 163 | 164 | ```{r, eval=FALSE, hilang="sas", purl=FALSE} 165 | PROC MIXED DATA=stageIIin_CultivarMeans; 166 | CLASS Cultivar Zone Location; 167 | MODEL Estimate = Zone; 168 | WEIGHT weight_Smith; 169 | RANDOM Int Zone Zone*Location / SUB=Cultivar; 170 | RANDOM Zone*Location; 171 | REPEATED; 172 | PARMS (1)(1)(1)(1)(1) / HOLD=5; 173 | RUN; 174 | ``` 175 | 176 | This model then provides us with the Cultivar-BLUPs across all environments obtained in a two-stage analyses using Smith's weights. 177 | 178 | ### Fully Efficient Weighting {.tabset .tabset-fade .tabset-pills} 179 | 180 | #### nlme 181 | 182 | in progress, but probably not possible (?) 183 | 184 | #### lme4 185 | 186 | in progress, but probably not possible (?) 187 | 188 | #### glmmTMB 189 | 190 | in progress, but probably not possible (?) 191 | 192 | #### sommer 193 | 194 | in progress, but probably not possible (?) 195 | 196 | #### SAS {.active} 197 | 198 | At this point we can conveniently make use of a [SAS-macro](https://blogs.sas.com/content/sgf/2020/04/22/how-to-create-and-use-sas-macro-functions/){target="_blank"} that is described in more detail in [Damesa et al., 2017](https://acsess.onlinelibrary.wiley.com/doi/abs/10.2134/agronj2016.07.0395){target="_blank"} and can be found in their supplemental material. Note that a copy of it can also be found [on github](https://github.com/SchmidtPaul/utilities/tree/master/SAS%20macros){target="_blank"} which makes its use in SAS via URL very convenient: 199 | 200 | ```{r, eval=FALSE, hilang="sas", purl=FALSE} 201 | FILENAME fullyeff URL 202 | "https://raw.githubusercontent.com/SchmidtPaul/utilities/master/SAS%20macros/get_one_big_omega.sas"; 203 | %INCLUDE fullyeff; 204 | 205 | %get_one_big_omega(data=stageIout_CultivarMeans, 206 | entry=Cultivar, by=Zone, by2=Location, 207 | outL=stageIIin_CultivarMeans); 208 | ``` 209 | 210 | As can be seen, the macro `%get_one_big_omega` basically needs the `stageIout_CultivarMeans` object as input, the name of the (main) effect for which means were calculated (*i.e.* `Cultivar`), as well as the variables that were used in the `BY` statement in Stage I. It then produces a `stageIIin_CultivarMeans` object that serves as the dataset in Stage II .... 211 | 212 | There are two things to consider when modelling the fully efficient weighting approach in SAS: 213 | 214 | 1. The `REPEATED;` statement ... 215 | 216 | 2. The `PARMS ...(1) /HOLD=n` statement makes sure that the error variance is forced to be equal to 1. Notice that the number of parameters (and thus the number of `(1)` that are required in the statement) differ between models. However, there must always at least be one, *i.e.* the error variance, and it will always be the last one in the `PARMS` statement. In this case the model has 5 parameters, *i.e.* variance components for the random effects `Cultivar`, `Zone:Cultivar`, `Zone:Location:Cultivar` and `Zone:Location` and for the error term. 217 | 218 | ```{r, eval=FALSE, hilang="sas", purl=FALSE} 219 | PROC MIXED DATA=stageIIin_CultivarMeans; 220 | CLASS Cultivar Zone Location row; 221 | MODEL Estimate = Zone /NOTEST; 222 | RANDOM Int Zone Zone*Location / SUB=Cultivar; 223 | RANDOM Zone*Location; 224 | REPEATED row / SUB=Zone*Location TYPE=lin(1) LDATA=stageIIin_CultivarMeans; 225 | PARMS (1)(1)(1)(1)(1) / HOLD=5; 226 | RUN; 227 | ``` 228 | 229 | 230 | 231 | 232 | 233 | -------------------------------------------------------------------------------- /glmmtmbdispformula0.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Covariance structures for the error term with glmmTMB - a workaround" 3 | output: 4 | html_document: 5 | includes: 6 | in_header: header.html 7 | after_body: footer.html 8 | --- 9 | ```{r, echo=F, message=F, error=F, purl=T} 10 | pacman::p_load(conflicted, 11 | tidyverse, 12 | nlme, glmmTMB, 13 | broom.mixed, 14 | emo, flair) 15 | 16 | # package function conflicts 17 | conflict_prefer("filter", "dplyr") 18 | ``` 19 | 20 | ```{r, echo=F, purl=F} 21 | pacman::p_load(kableExtra) 22 | options(knitr.kable.NA = '') 23 | ``` 24 | 25 | 26 |

    27 | 28 | # What? 29 | 30 | | 31 | -|----------------------- 32 | `r emo::ji("slightly_smiling_face")`

    | When fitting linear mixed models, the `glmmTMB` package is nice, because it feels like `lme4` but additionally allows for [several covariance structures](https://cran.r-project.org/web/packages/glmmTMB/vignettes/covstruct.html){target="_blank"} for the random effects.

    33 | `r emo::ji("disappointed")`

    | However, this only works for random terms on the [***G***-side](https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statug_glimmix_overview05.htm&locale=en){target="_blank"} of the model and not for the error term (= [***R***-side](https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=statug&docsetTarget=statug_glimmix_overview05.htm&locale=en){target="_blank"}).

    34 | `r emo::ji("nerd_face")`

    | **But** there is a workaround! We can fix the error variance to be 0 and thus force all the variance into the ***G***-side. If we do so and also add a random ***"pseudo error term"*** that mimics the original error term, we have created a model that essentially leads to identical results.

    35 | `r emo::ji("sunglasses")`

    | Once this is clear, we can use all the available variance structures on our *pseudo error term*!

    36 | 37 | # How? 38 | 39 | ```{r hideme, echo=FALSE, purl=F} 40 | # this is never seen but needed for code below 41 | dat <- iris %>% 42 | mutate(unit = 1:n() %>% as.factor()) %>% 43 | rename(y=Sepal.Length, 44 | fixedeffects=Species, 45 | randomeffects=Sepal.Width) %>% 46 | as_tibble() 47 | ``` 48 | 49 | 1. Remove original error variance from ***R***-side via `dispformula = ~ 0`. 50 | 2. Add pseudo error variance to ***G***-side via random term. 51 | + In the simple case, this can be done via `+ (1 | unit)` where `unit` is a factor with as many levels as there are observations in the dataset. 52 | 53 |
    54 | Basically go from here... 55 | ```{r StandErrMod, include=F, purl=F} 56 | # 57 | # 58 | 59 | StandErrMod <- glmmTMB( 60 | y ~ 61 | fixedeffects + 62 | (1 | randomeffects), 63 | 64 | 65 | REML = TRUE, 66 | data = dat 67 | ) 68 | ``` 69 | ```{r, echo=F, purl=F} 70 | decorate("StandErrMod") 71 | ``` 72 |
    73 | ...to here! 74 | ```{r PseudErrMod, include=F, purl=F} 75 | dat <- dat %>% 76 | mutate(unit = as.factor(1:n())) 77 | 78 | PseudErrMod <- glmmTMB( 79 | y ~ 80 | fixedeffects + 81 | (1 | randomeffects) + 82 | (1 | unit), # Pseudo Err 83 | dispformula = ~ 0, # ErrVar = 0 84 | REML = TRUE, 85 | data = dat 86 | ) 87 | ``` 88 | ```{r, echo=F, purl=F} 89 | decorate("PseudErrMod") %>% flair_lines(c(1,2,8,9)) 90 | ``` 91 |
    92 | 93 | # Really? 94 | 95 | Here are two examples for the *pseudo-error* approach based on this dataset: 96 | 97 | ```{r, purl=T} 98 | dat <- agridat::mcconway.turnip %>% 99 | mutate(unit = 1:n()) %>% 100 | mutate_at(vars(density, unit), as.factor) 101 | ``` 102 | 103 | * **Example 1** We assume no special variance structure for the error term and thus *independent & identically distributed* errors. We compare two `glmmTMB` models - one with a standard error term and one with a *pseudo-error* term. 104 | * **Example 2** We assume a diagonal variance structure for the factor `date` and thus allow for different heterogeneous error variances / heteroscedascity per group for the effect levels of `date`. We compare a *pseudo-error*-`glmmTMB` model with `nlme::lme()` model. 105 | 106 | ## Example 1: iid 107 | 108 |
    109 | ```{r, purl=T} 110 | StandErrMod <- glmmTMB( 111 | yield ~ 112 | gen*date*density + 113 | (1 | block), 114 | 115 | 116 | REML = TRUE, 117 | data = dat 118 | ) 119 | ``` 120 |
    121 | ```{r, purl=T} 122 | PseudErrMod <- glmmTMB( 123 | yield ~ 124 | gen*date*density + 125 | (1 | block) + 126 | (1 | unit), # Pseudo Err 127 | dispformula = ~ 0, # ErrVar = 0 128 | REML = TRUE, 129 | data = dat 130 | ) 131 | ``` 132 |
    133 | 134 | The **variance component estimates** of both models are very similar. As expected the Residual variance in the *pseudo-error model* is 0 and instead there is an additional variance for the random `unit` term. 135 | 136 |
    137 | ```{r eval=FALSE, purl=T} 138 | mixedup::extract_vc(StandErrMod) 139 | ``` 140 | ```{r echo=FALSE, purl=F} 141 | mixedup::extract_vc(StandErrMod) %>% 142 | select(-effect) %>% 143 | kbl() %>% 144 | kable_paper(full_width = F, html_font = "arial", font_size = 12) 145 | ``` 146 |
    147 | ```{r eval=FALSE, purl=T} 148 | mixedup::extract_vc(PseudErrMod) 149 | ``` 150 | ```{r echo=FALSE, purl=F} 151 | mixedup::extract_vc(PseudErrMod) %>% 152 | select(-effect) %>% 153 | kbl() %>% 154 | kable_paper(full_width = F, html_font = "arial", font_size = 12) 155 | ``` 156 |
    157 | 158 | The **Likelihood**/**AIC** values are identical for both models. 159 | 160 | ```{r eval=FALSE, purl=T} 161 | AICcmodavg::aictab(list(StandErrMod, PseudErrMod), 162 | c("StandErrMod", "PseudErrMod"), 163 | second.ord = FALSE) 164 | ``` 165 | ```{r echo=FALSE, purl=F} 166 | AICcmodavg::aictab(list(StandErrMod, PseudErrMod), 167 | c("StandErrMod", "PseudErrMod"), 168 | second.ord = FALSE) %>% 169 | mutate_at(vars(Delta_AIC:LL), ~ round(., 5)) %>% 170 | as_tibble() %>% 171 | select(Modnames:Delta_AIC, LL) %>% 172 | kbl() %>% 173 | kable_paper(full_width = F, html_font = "arial", font_size = 12) 174 | ``` 175 | 176 | ## Example 2: diag 177 | 178 |
    179 | ```{r, purl=T} 180 | diag_glmmTMB <- glmmTMB( 181 | yield ~ 182 | gen*date*density + 183 | (1 | block) + 184 | diag(date + 0 | unit), 185 | dispformula = ~ 0, 186 | REML = TRUE, 187 | data = dat 188 | ) 189 | ``` 190 |
    191 | ```{r, purl=T} 192 | diag_lme <- lme( 193 | yield ~ 194 | gen*date*density, 195 | random = ~ 1 | block, 196 | weights = varIdent(form = ~ 1 | date), 197 | 198 | 199 | data = dat 200 | ) 201 | ``` 202 |
    203 | 204 | The **variance component estimates** are similar enough. 205 | 206 |
    207 | ```{r, echo=FALSE, purl=T} 208 | glmmTMB_vc <- bind_rows( 209 | 210 | diag_glmmTMB %>% 211 | tidy(effects = "ran_pars", scales = "vcov") %>% 212 | filter(group == "block") %>% 213 | mutate(grp = str_remove(term, "var__")) %>% 214 | select(group, grp, estimate) %>% 215 | rename(variance = estimate, 216 | effect = group) 217 | 218 | , 219 | 220 | diag_glmmTMB %>% 221 | mixedup::extract_cor_structure(which_cor="diag") %>% 222 | pivot_longer( cols = 2:3, values_to ="variance", names_to="grp") %>% 223 | mutate(variance = variance ^ 2) %>% 224 | rename(effect = group) 225 | 226 | , 227 | 228 | tibble(effect = "Residual", 229 | grp = NA_character_, 230 | variance = glance(diag_glmmTMB) %>% pull(sigma) %>% `^`(2)) 231 | 232 | ) 233 | ``` 234 | 235 | ```{r, echo=FALSE, purl=F} 236 | glmmTMB_vc %>% 237 | kbl() %>% 238 | kable_paper(full_width = F, html_font = "arial", font_size = 12) 239 | ``` 240 |
    241 | ```{r, echo=FALSE, purl=T} 242 | lme_vc <- bind_rows( 243 | 244 | diag_lme %>% 245 | tidy(effects = "ran_pars", scales = "vcov") %>% 246 | filter(group=="block") %>% 247 | mutate(grp = str_remove(term, "var_")) %>% 248 | select(group, grp, estimate) %>% 249 | rename(variance = estimate, 250 | effect = group) 251 | 252 | , 253 | 254 | diag_lme$modelStruct$varStruct %>% 255 | coef(unconstrained = FALSE, allCoef = TRUE) %>% 256 | enframe(name = "grp", value = "varStruct") %>% 257 | mutate(sigma = diag_lme$sigma) %>% 258 | mutate(StandardError = sigma * varStruct) %>% 259 | mutate(variance = StandardError ^ 2) %>% 260 | mutate(effect = "Residual") %>% 261 | select(effect, grp, variance) 262 | 263 | ) 264 | ``` 265 | 266 | ```{r, echo=FALSE, purl=F} 267 | lme_vc %>% 268 | kbl() %>% 269 | kable_paper(full_width = F, html_font = "arial", font_size = 12) 270 | ``` 271 |
    272 | 273 | Furthermore, even though we are comparing across different model classes, we also get similar model fit statistics. 274 | 275 |
    276 | ```{r, echo=F, purl=T} 277 | glmmTMB_fit <- diag_glmmTMB %>% 278 | glance() %>% select(logLik:BIC) 279 | ``` 280 | 281 | ```{r, echo=F, purl=F} 282 | glmmTMB_fit %>% 283 | kbl() %>% 284 | kable_paper(full_width = F, html_font = "arial", font_size = 12) 285 | ``` 286 |
    287 | ```{r, echo=F, purl=T} 288 | lme_fit <- diag_lme %>% 289 | glance() %>% select(logLik:BIC) 290 | ``` 291 | 292 | ```{r, echo=F, purl=F} 293 | lme_fit %>% 294 | kbl() %>% 295 | kable_paper(full_width = F, html_font = "arial", font_size = 12) 296 | ``` 297 |
    298 | 299 | 300 | 301 | # More Details! 302 | 303 | Check out [the GitHub issue](https://github.com/glmmTMB/glmmTMB/issues/653){target="_blank"} I've written on this topic at the `glmmTMB` repository, where [Ben Bolker](https://ms.mcmaster.ca/~bolker/){target="_blank"} - the author of this R-package - replied. Here are some key points: 304 | 305 | * This works **only for gaussian mixed models** and thus not for generalized mixed models! 306 | * As is the case in Example 1, we **sometimes get a `false convergence` warning** for the pseudo-error-model but not for the standard model. 307 | * Actually, `dispformula=~0` does not fix the residual variance to be 0, but to be a small non-zero value. 308 | + Because of this, the **variance component estimates will never be exactly identical**. 309 | + At present [it is set to sqrt(.Machine$double.eps)](https://github.com/glmmTMB/glmmTMB/blob/2b14a42bd55cd0cfeebad1f4eb7a3b2313e5d359/glmmTMB/R/glmmTMB.R#L85){target="_blank"}, which is the squareroot of the [smallest possible](https://stat.ethz.ch/R-manual/R-devel/library/base/html/zMachine.html){target="_blank"} positive floating-point number. 310 | + Ben Bolker [commented](https://github.com/glmmTMB/glmmTMB/issues/653#issuecomment-749295844){target="_blank"} that "One piece of low-hanging fruit would be to allow the small non-zero value to be user-settable via `glmmTMBControl`". 311 | * **Possible covariance structures** 312 | + Find all possible structures [here](https://cran.r-project.org/web/packages/glmmTMB/vignettes/covstruct.html){target="_blank"} 313 | + Note that `cs` is **heterogeneous** compound symmetry and there is no homogeneous compound symmetry! 314 | + As can be seen in example 2, we need a `+ 0` in the `diag(date + 0 | unit)`, since leaving it out would by default lead to estimating not only the desired heterogeneous variances, but an additional overall variance. 315 | + Currently, we **cannot have Kronecker product / direct product / varComb()** as variance structure, as confirmed in [this GitHub issue](https://github.com/glmmTMB/glmmTMB/issues/592){target="_blank"}. 316 | 317 | # Mooore Details! 318 | 319 | * If you are wondering how to **extract the variance component estimates** as I did for example 2 and you are mad that I did not show the code, [click here](https://github.com/SchmidtPaul/MMFAIR/blob/master/Rpurl/glmmtmbdispformula0.R){target="_blank"} to find the R-code of this document. 320 | * Check out the chapters on this website to see more/other uses of this approach. 321 | 322 | 323 | 324 | -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/jquery-ui.theme.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.11.4 - 2016-01-05 2 | * http://jqueryui.com 3 | * Copyright jQuery Foundation and other contributors; Licensed MIT */ 4 | 5 | .ui-widget{font-family:Arial,Helvetica,sans-serif;font-size:1em}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Arial,Helvetica,sans-serif;font-size:1em}.ui-widget-content{border:1px solid #ddd;background:#fff;color:#333}.ui-widget-content a{color:#333}.ui-widget-header{border:1px solid #ddd;background:#e9e9e9;color:#333;font-weight:bold}.ui-widget-header a{color:#333}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #c5c5c5;background:#f6f6f6;font-weight:normal;color:#454545}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#454545;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:1px solid #ccc;background:#ededed;font-weight:normal;color:#2b2b2b}.ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited,.ui-state-focus a,.ui-state-focus a:hover,.ui-state-focus a:link,.ui-state-focus a:visited{color:#2b2b2b;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #003eff;background:#007fff;font-weight:normal;color:#fff}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#fff;text-decoration:none}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #dad55e;background:#fffa90;color:#777620}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#777620}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #f1a899;background:#fddfdf;color:#5f3f3f}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#5f3f3f}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#5f3f3f}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}.ui-icon{width:16px;height:16px}.ui-icon,.ui-widget-content .ui-icon{background-image:url("images/ui-icons_444444_256x240.png")}.ui-widget-header .ui-icon{background-image:url("images/ui-icons_444444_256x240.png")}.ui-state-default .ui-icon{background-image:url("images/ui-icons_777777_256x240.png")}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url("images/ui-icons_555555_256x240.png")}.ui-state-active .ui-icon{background-image:url("images/ui-icons_ffffff_256x240.png")}.ui-state-highlight .ui-icon{background-image:url("images/ui-icons_777620_256x240.png")}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url("images/ui-icons_cc0000_256x240.png")}.ui-icon-blank{background-position:16px 16px}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-on{background-position:-96px -144px}.ui-icon-radio-off{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{border-top-left-radius:3px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{border-top-right-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{border-bottom-left-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{border-bottom-right-radius:3px}.ui-widget-overlay{background:#aaa;opacity:.3;filter:Alpha(Opacity=30)}.ui-widget-shadow{margin:0 0 0 0;padding:5px;background:#666;opacity:.3;filter:Alpha(Opacity=30);border-radius:8px} -------------------------------------------------------------------------------- /img/logo/flaviconMMFAIR.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 31 | 32 | 51 | 53 | 54 | 56 | image/svg+xml 57 | 59 | 60 | 61 | 62 | 63 | 68 | 70 | 76 | 79 | 85 | 90 | 91 | 92 | MM 103 | 108 | 114 | 120 | 126 | 132 | 138 | 144 | 150 | 156 | 162 | 168 | 174 | 180 | 183 | 190 | 197 | 203 | 204 | 205 | 206 | -------------------------------------------------------------------------------- /img/logo/hexagonMMFAIR.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 22 | 24 | 31 | 32 | 51 | 53 | 54 | 56 | image/svg+xml 57 | 59 | 60 | 61 | 62 | 63 | 68 | 70 | 72 | 78 | 81 | 87 | 92 | 93 | 94 | 99 | 105 | 111 | 117 | 123 | 129 | 135 | 141 | 147 | 153 | 159 | 165 | 171 | 174 | 181 | 188 | 194 | 195 | 196 | MMFAIR 207 | 208 | 209 | -------------------------------------------------------------------------------- /variance_structures.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Variance Structures" 3 | output: 4 | html_document: 5 | includes: 6 | after_body: footer.html 7 | --- 8 | 9 | ```{r, echo=FALSE, warning=FALSE, message=FALSE} 10 | options(knitr.kable.NA = '') 11 | # packages for better formatting tables for html output 12 | library(kableExtra) 13 | library(formattable) 14 | library(htmltools) 15 | 16 | pacman::p_load(dplyr, purrr, tibble, tidyr, # data handling 17 | ggplot2, viridis, # plot 18 | nlme, lme4, glmmTMB, sommer, # mixed modelling 19 | AICcmodavg, broom.mixed) # mixed model extractions 20 | 21 | { 22 | dat <- agridat::mcconway.turnip %>% 23 | as_tibble() %>% 24 | mutate(densf = density %>% as.factor) %>% 25 | mutate(date_densf = interaction(date, densf)) # needed for mod5 26 | 27 | mod1.nlme <- nlme::lme(fixed = yield ~ gen * date * densf, 28 | random = ~ 1|block, 29 | weights = NULL, # default, i.e. homoscedastic errors 30 | data = dat) 31 | 32 | mod4.nlme <- mod1.nlme %>% 33 | update(weights = varComb(varIdent(form=~1|date), 34 | varIdent(form=~1|densf))) 35 | 36 | mod5.nlme <- mod1.nlme %>% 37 | update(weights = varIdent(form=~1|date_densf)) 38 | 39 | mod1.nlme.VC <- tibble(grp="homoscedastic", varStruct=1) %>% 40 | mutate(sigma = mod1.nlme$sigma) %>% 41 | mutate(StandardError = sigma*varStruct) %>% 42 | mutate(Variance = StandardError^2) 43 | 44 | mod4.nlme.varStruct.A <- mod4.nlme$modelStruct$varStruct$A %>% 45 | coef(unconstrained=FALSE, allCoef=TRUE) %>% 46 | enframe(name="grpA", value="varStructA") 47 | 48 | mod4.nlme.varStruct.B <- mod4.nlme$modelStruct$varStruct$B %>% 49 | coef(unconstrained=FALSE, allCoef=TRUE) %>% 50 | enframe(name="grpB", value="varStructB") 51 | 52 | mod4.nlme.VC <- expand.grid(mod4.nlme.varStruct.A$grpA, 53 | mod4.nlme.varStruct.B$grpB, 54 | stringsAsFactors=FALSE) %>% 55 | rename(grpA=Var1, grpB=Var2) %>% 56 | left_join(x=., y=mod4.nlme.varStruct.A, by="grpA") %>% 57 | left_join(x=., y=mod4.nlme.varStruct.B, by="grpB") %>% 58 | mutate(sigma = mod4.nlme$sigma) %>% 59 | mutate(StandardError = sigma*varStructA*varStructB) %>% 60 | mutate(Variance = StandardError^2) 61 | 62 | mod5.nlme.VC <- mod5.nlme$modelStruct$varStruct %>% 63 | coef(unconstrained=FALSE, allCoef=TRUE) %>% 64 | enframe(name="grp", value="varStruct") %>% 65 | separate(grp, sep="[.]", into=c("grpA","grpB")) %>% 66 | mutate(sigma = mod5.nlme$sigma) %>% 67 | mutate(StandardError = sigma*varStruct) %>% 68 | mutate(Variance = StandardError^2) 69 | } # get nlme VC from het diag example 70 | 71 | setup <- dat %>% 72 | filter(block=="B1") %>% 73 | arrange(date, density) %>% 74 | dplyr::select(-yield) %>% 75 | mutate(label=paste0(date_densf,".",block), 76 | nID=1:n()) 77 | 78 | { 79 | mat1 <- left_join(x = setup %>% mutate(grp="homoscedastic"), 80 | y = mod1.nlme.VC %>% dplyr::select(-StandardError) , 81 | by = c("grp"="grp")) %>% 82 | left_join(x = expand.grid(X=.$nID, Y=.$nID), 83 | y = ., 84 | by = c("X"="nID")) %>% as_tibble() %>% 85 | mutate(Variance = case_when(X==Y~Variance, TRUE~NA_real_)) 86 | 87 | mat4 <- left_join(x = setup, 88 | y = mod4.nlme.VC %>% dplyr::select(-StandardError), 89 | by = c("date"="grpA", "densf"="grpB")) %>% 90 | left_join(x = expand.grid(X=.$nID, Y=.$nID), 91 | y = ., 92 | by = c("X"="nID")) %>% as_tibble() %>% 93 | mutate(Variance = case_when(X==Y~Variance, TRUE~NA_real_)) 94 | 95 | mat5 <- left_join(x = setup, 96 | y = mod5.nlme.VC %>% dplyr::select(-StandardError), 97 | by = c("date"="grpA", "densf"="grpB")) %>% 98 | left_join(x = expand.grid(X=.$nID, Y=.$nID), 99 | y = ., 100 | by = c("X"="nID")) %>% as_tibble() %>% 101 | mutate(Variance = case_when(X==Y~Variance, TRUE~NA_real_)) 102 | } # get mat1 - mat5 103 | ``` 104 | 105 | Here you will find a list of variance structures (*a.k.a* covariance structures, variance-covariance-structures, correlation structures) with short explanations and possibly examples. 106 | 107 | # IID - Independent & Identically Distributed 108 | **This covariance structure has homogeneous variances and zero correlation between elements.** 109 | 110 | Number of parameters = 1 (*i.e.* $\sigma$) 111 | 112 | $$ 113 | \left(\begin{array}{cc} 114 | \sigma^2 & 0 & 0 & 0\\ 115 | & \sigma^2 & 0 & 0\\ 116 | & & \sigma^2 & 0\\ 117 | & & & \sigma^2\\ 118 | \end{array}\right) = 119 | \left(\begin{array}{cc} 120 | 1 & 0 & 0 & 0\\ 121 | & 1 & 0 & 0\\ 122 | & & 1 & 0\\ 123 | & & & 1\\ 124 | \end{array}\right) \sigma^2 125 | $$ 126 | 127 | 128 | This is the simplest covariance structure and the default setting in most, if not all, linear modelling packages. 129 | 130 | # Diagonal 131 | **This covariance structure has heterogenous variances and zero correlation between elements.** 132 | 133 | Number of parameters: $t$ (*i.e.* $\sigma_1$, $\sigma_2$, ..., $\sigma_t$), which is the overall dimension of the covariance matrix (*e.g.* number of treatement levels). 134 | 135 | $$ 136 | \left(\begin{array}{cc} 137 | \sigma_1^2 & 0 & 0 & 0\\ 138 | & \sigma_2^2 & 0 & 0\\ 139 | & & \sigma_3^2 & 0\\ 140 | & & & \sigma_4^2\\ 141 | \end{array}\right) = 142 | \left(\begin{array}{cc} 143 | 1 & 0 & 0 & 0\\ 144 | & k_1 & 0 & 0\\ 145 | & & k_2 & 0\\ 146 | & & & k_3\\ 147 | \end{array}\right) \sigma^2 148 | $$ 149 | 150 | In our [chapter on heterogeneous error variances](heterogeneous_error_variance.html){target="_blank"}, we fit models in which we allow for different error variances for two of the treatments. Thus, the off-diagonals are all 0, but there are multiple variances on the diagonal. More specifically, in `mod5` we allows for 8 different error variances - one for each factor-level-combination of the respective factor effects `date` and `density`. This is visualized in the plot below as 8 different colors. Speaking in the [syntax of `nlme`](https://cran.r-project.org/web/packages/nlme/nlme.pdf#Rfn.nlmeStruct.1){target="_blank"}, we obtain 8 parameter estimates: 1 estimate for the [model-object's `sigma`](https://cran.r-project.org/web/packages/nlme/nlme.pdf#Rfn.nlmeObject.1){target="_blank"} (= standard deviation for error term) and 7 estimates (that are different from 1) in the [model-object's `varStruct`](https://cran.r-project.org/web/packages/nlme/nlme.pdf#Rfn.nlmeStruct.1){target="_blank"} as can be seen on the y-axis: 151 | 152 | ```{r, echo=FALSE} 153 | MAT <- mat5 154 | labs <- MAT %>% 155 | dplyr::select(X, date_densf, gen, varStruct) %>% unique 156 | 157 | ggplot(data=MAT, aes(x=X, y=Y)) + coord_fixed() + 158 | geom_tile(aes( fill=Variance), color="grey") + 159 | scale_fill_viridis(option="D", na.value="white", 160 | guide ="legend", name="Variance\nEstimate", 161 | breaks = MAT %>% pull(Variance) %>% unique %>% sort, 162 | labels = scales::number_format(accuracy = 0.01)) + 163 | scale_x_continuous(name = "date-density-combination", 164 | expand = c(0,0), 165 | breaks = labs %>% pull(X), 166 | labels = labs %>% pull(date_densf), 167 | sec.axis = sec_axis(~ ., 168 | name = "genotype", 169 | breaks = labs %>% pull(X), 170 | labels = labs %>% pull(gen))) + 171 | scale_y_continuous(name = "VarStruct date-density-combination", 172 | trans = "reverse", 173 | expand = c(0,0), 174 | breaks = labs %>% pull(X), 175 | labels = labs %>% pull(varStruct) %>% round(2)) + 176 | theme(legend.text.align = 1, 177 | axis.ticks.x = element_line(color="grey"), 178 | axis.title.x = element_text(color="grey"), 179 | axis.text.x = element_text(angle=90, hjust=1, color="grey"), 180 | legend.position = "right") 181 | ``` 182 | 183 | > In order to give a clearer picture, the variance matrix presented here was reduced to data of a single block in order to have dimensions 16x16. Since there were [4 complete blocks in the dataset](heterogeneous_error_variance.html){target="_blank"}, the entire variance matrix of the error term has dimensions 64x64. However, given that data/errors are sorted accordingly, our presented matrix is simply 1 out of 4 blocks in a [block diagonal matrix](https://www.wikiwand.com/en/Block_matrix#/Block_diagonal_matrices){target="_blank"}. 184 | 185 | # First order autoregressive AR(1) 186 | 187 | **This covariance structure has homogeneous variances, while the correlation between any two elements gets smaller the further apart they are separated (e.g. in terms of time or space).** 188 | 189 | Number of parameters: 2 (*i.e.* $\sigma$ and $\rho$). 190 | 191 | $$ 192 | \left(\begin{array}{cc} 193 | \sigma^2 & \sigma^2\rho & \sigma^2\rho^2 & \sigma^2\rho^3\\ 194 | & \sigma^2 & \sigma^2\rho & \sigma^2\rho^2\\ 195 | & & \sigma^2 & \sigma^2\rho\\ 196 | & & & \sigma^2\\ 197 | \end{array}\right) = 198 | \left(\begin{array}{cc} 199 | 1 & \rho & \rho^2 & \rho^3\\ 200 | & 1 & \rho & \rho^2\\ 201 | & & 1 & \rho\\ 202 | & & & 1\\ 203 | \end{array}\right) \sigma^2 204 | $$ 205 | 206 | As can be seen, the correlation between any two elements can be described more speficically as: it is equal to $\rho$ for adjacent elements, $\rho^2$ for elements that are separated by a third, and so on. Note that since it is a correlation, we have -1 < $\rho$ < 1 and therefore $\rho$ indeed gets smaller when squared etc. This correlation model is useful, if all time points are equally spaced. 207 | 208 | As an explicit example, take the correlation between errors of two adjacent time points, in this case weeks, to be $\rho=0.9$. The correlation between errors that are two weeks apart is then $\rho^2=0.9^2=0.81$ and when they are three weeks apart it is $\rho^3=0.9^3=0.729$ and so on. Thus, the advantage here is that correlations become smaller over time and thus we have different correlation estimates, yet only a single correlation parameter $\rho$ is fitted in the model. 209 | 210 | # Multiplicative 211 | **It is possible to combine any two or more variance structures via direct multiplication *a.k.a.* the [Kronecker product](https://www.wikiwand.com/en/Kronecker_product){target="_blank"}.** 212 | 213 | $$ 214 | \left(\begin{array}{cc} 215 | 1 & 0 \\ 216 | & k_1 \\ 217 | \end{array}\right) 218 | \otimes 219 | \left(\begin{array}{cc} 220 | 1 & 0 & 0 \\ 221 | & k_2 & 0 \\ 222 | & & k_3 \\ 223 | \end{array}\right) \sigma^2 224 | = 225 | \left(\begin{array}{cc} 226 | 1\cdot1 & 0 & 0 & 0 & 0 & 0 \\ 227 | & 1\cdot k_2 & 0 & 0 & 0 & 0 \\ 228 | & & 1\cdot k_3 & 0 & 0 & 0 \\ 229 | & & & k_1\cdot 1 & 0 & 0 \\ 230 | & & & & k_1\cdot k_2 & 0 \\ 231 | & & & & & k_1\cdot k_3 \\ 232 | \end{array}\right) \sigma^2 233 | $$ 234 | 235 | 236 | This operation on two matrices of arbitrary size resulting in a block matrix is sometimes denoted by $\otimes$. To give an example, we refer to `mod4` in the [chapter on heterogeneous error variances](heterogeneous_error_variance.html){target="_blank"}. Here, a multiplicative variance structure results from the kronecker product of two diagonal variance structures. The first diagonal variance structure allows for different variances for the 2 levels of `date`, while the second diagonal variance structure allows for different variances for the 4 levels of `density`. Their Kronecker product therefore results in 8 different variances, visualized in the plot below as 8 different colors. 237 | 238 | ```{r, echo=FALSE} 239 | MAT <- mat4 240 | labs <- MAT %>% 241 | dplyr::select(X, date_densf, gen, varStructA, varStructB) %>% unique 242 | 243 | ggplot(data=MAT, aes(x=X, y=Y)) + coord_fixed() + 244 | geom_tile(aes( fill=Variance), color="grey") + 245 | scale_fill_viridis(option="D", na.value="white", 246 | guide ="legend", name="Variance\nEstimate", 247 | breaks = MAT %>% pull(Variance) %>% unique %>% sort, 248 | labels = scales::number_format(accuracy = 0.01)) + 249 | scale_x_continuous(name = "date-density-combination", 250 | expand = c(0,0), 251 | breaks = labs %>% pull(X), 252 | labels = labs %>% pull(date_densf), 253 | sec.axis = sec_axis(~ ., 254 | name = "genotype", 255 | breaks = labs %>% pull(X), 256 | labels = labs %>% pull(gen))) + 257 | scale_y_continuous(name = "VarStruct density", 258 | trans = "reverse", 259 | expand = c(0,0), 260 | breaks = labs %>% pull(X), 261 | labels = labs %>% pull(varStructB) %>% round(2), 262 | sec.axis = sec_axis(~ ., 263 | name = "VarStruct date", 264 | breaks = labs %>% pull(X), 265 | labels = labs %>% pull(varStructA) %>% round(2))) + 266 | theme(legend.text.align = 1, 267 | axis.ticks.x = element_line(color="grey"), 268 | axis.title.x = element_text(color="grey"), 269 | axis.text.x = element_text(angle=90, hjust=1, color="grey"), 270 | legend.position = "right") 271 | ``` 272 | 273 | ## Advantage 274 | 275 | One may now ask where the difference lies between this multiplicative variance structure for `mod4` on the one hand, and the simple diagonal variance structure for all 8 `date`-`density`-combinations in `mod5` (see [diagonal section above](#Diagonal)) on the other hand. The question comes intuitively, since both lead to obtaining 8 different variance estimates for the error term. However, while the combinations for which the 8 estimates are obtained are the same, the estimates themselves are different between `mod4` and `mod5`. In order to understand this, one must realize that fewer parameters need to be estimated here for `mod4` (= 6 parameters) compared to the simple diagonal variance structure for [`mod5`](#Diagonal) (= 8 parameters) - even though both result in 8 different variance estimates! One can retrace this manually by counting the number of `varStruct` values on the y-axes of the two plots. There should be 5 values for `mod4` and 7 values for `mod5` **that are not equal to 1** and in addition, [`sigma`](https://cran.r-project.org/web/packages/nlme/nlme.pdf#Rfn.nlmeObject.1){target="_blank"} (= standard deviation for error term) itself is the *missing* parameter here. 276 | 277 | Therefore, **direct multiplication can lead to the desired structure with fewer parameters needing to be estimated**. Notice that the number of parameters penalizes the AIC and therefore has a direct impact on model selection decisions. In the underlying [chapter on heterogeneous error variances](heterogeneous_error_variance.html){target="_blank"}, `mod4` (= multiplicative) is indeed chosen over `mod5` based on the AIC. 278 | 279 | # Summary 280 | 281 | ```{r, echo=FALSE} 282 | tribble( 283 | ~`Variance Structure`, ~total, ~var, ~cor,~nlme, ~lme4, ~glmmTMB, ~sommer, ~SAS, 284 | "Identitiy", "1", "1", "0" ,"default" ,"default","default","default","VC", 285 | "Diagonal", "t", "t", "0" ,"varIdent", "--", "diag", "ds","UN(1)", 286 | "First order autoregressive ", "2", "1", "1" ,"corAR1" , "--", "ar1", "AR1","AR(1)" 287 | ) %>% 288 | kable(escape = FALSE) %>% 289 | kable_styling(bootstrap_options = c("striped", "hover", "condensed", "responsive"), 290 | full_width = FALSE) %>% 291 | add_header_above(c(" ", 292 | "number of parameters"=3, 293 | "name in package"=5)) %>% 294 | footnote(general = "t = overall dimension of the covariance matrix (e.g. number of treatement levels).") 295 | ``` 296 | 297 | 298 | # More on this 299 | 300 | [ASReml-R documentation](https://asreml.kb.vsni.co.uk/wp-content/uploads/sites/3/2018/02/ASReml-R-Reference-Manual-4.pdf#section.4.2){target="_blank"} 301 | 302 | [SAS documentation](https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_mixed_syntax14.htm&docsetVersion=14.3&locale=en#statug.mixed.repeatedstmt_type){target="_blank"} 303 | 304 | [SPSS documentation](https://www.ibm.com/support/knowledgecenter/SSLVMB_23.0.0/spss/advanced/covariance_structures.html){target="_blank"} 305 | 306 | in progress 307 | --------------------------------------------------------------------------------