--- title: "10. Comparing methods" output: rmarkdown::html_vignette: toc: true vignette: > %\VignetteIndexEntry{10. Comparing methods} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r setup, include=FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message = FALSE, warning = FALSE, fig.width = 7, fig.height = 5.5 ) ``` ```{r libraries} library(idiographic) data(srl) vars <- c("efficacy", "value", "planning", "monitoring", "effort") ``` `compare_idiographic()` runs several estimators on the same data and stacks their summaries into **one comparison table**, so you read estimators against each other instead of assembling the comparison by hand. Each estimator's own arguments are passed through `estimator_args`. Here we compare the two single-person temporal estimators on `Grace`. ```{r compare} cmp <- compare_idiographic( srl, vars = vars, id = "name", estimators = c("var", "graphical_var"), estimator_args = list( var = list(subject = "Grace", scale = TRUE), graphical_var = list(subject = "Grace", n_lambda = 8, gamma = 0) ) ) cmp ``` The comparison itself is a tidy `data.frame`: ```{r compare-table} as.data.frame(cmp) ``` Add more estimators by extending `estimators` and `estimator_args`. The group methods (`mlvar`, `usem`, `gimme`) are accepted too — they are heavier, so the full template below is shown but not run here: ```{r compare-full, eval=FALSE} students <- subset(srl, name %in% c("Grace", "Eve", "Aisha", "Alice", "Bob", "Diana", "Frank", "Heidi")) compare_idiographic( students, vars = vars, id = "name", estimators = c("var", "graphical_var", "mlvar", "usem", "gimme"), estimator_args = list( var = list(subject = "Grace", scale = TRUE), graphical_var = list(subject = "Grace", n_lambda = 8, gamma = 0), mlvar = list(standardize = TRUE), usem = list(time = "day", temporal = "ar", contemporaneous = "all", residual_cov = TRUE, trim = TRUE, seed = 1), gimme = list(time = "day", ar = TRUE, seed = 1) ) ) ```