Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/h_modelsearch.R

This function peforms stepwise model search to find an optimal model that (locally) minimzes some criterion (by default, the BIC).

1 2 | ```
modelsearch(x, criterion = "bic", matrices, prunealpha = 0.01,
addalpha = 0.01, verbose, ...)
``` |

`x` |
A |

`criterion` |
String indicating the criterion to minimize. Any criterion from |

`matrices` |
Vector of strings indicating which matrices should be searched. Will default to network structures and factor loadings. |

`prunealpha` |
Minimal alpha used to consider edges to be removed |

`addalpha` |
Maximum alpha used to consider edges to be added |

`verbose` |
Logical, should messages be printed? |

`...` |
Arguments sent to |

The full algorithm is as follows:

1. Evaluate all models in which an edge is removed that has p > prunealpha, or an edge is added that has a modification index with p < addalpha

2. If none of these models improve the criterion, return the previous model and stop the algorithm

3. Update the model to the model that improved the criterion the most

4. Evaluate all other considered models that improved the criterion

5. If none of these models improve the criterion, go to 1, else go to 3

An object of the class psychonetrics (psychonetrics-class)

Sacha Epskamp

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
# Load bfi data from psych package:
library("psychTools")
data(bfi)
# Also load dplyr for the pipe operator:
library("dplyr")
# Let's take the agreeableness items, and gender:
ConsData <- bfi %>%
select(A1:A5, gender) %>%
na.omit # Let's remove missingness (otherwise use Estimator = "FIML)
# Define variables:
vars <- names(ConsData)[1:5]
# Let's fit a full GGM:
mod <- ggm(ConsData, vars = vars)
# Run model:
mod <- mod %>% runmodel
# Model search
mod <- mod %>% prune(alpha= 0.01) %>% modelsearch
``` |

psychonetrics documentation built on Oct. 26, 2021, 1:06 a.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.