|
| 1 | +--- |
| 2 | +output: |
| 3 | + github_document: |
| 4 | + html_preview: false |
| 5 | +--- |
| 6 | +```{r, echo = FALSE} |
| 7 | +knitr::opts_chunk$set( |
| 8 | + collapse = TRUE, |
| 9 | + comment = "#>", |
| 10 | + fig.path = "README-" |
| 11 | +) |
| 12 | +``` |
| 13 | + |
| 14 | +# ShortForm |
| 15 | +[](http://cran.r-project.org/package=ShortForm) |
| 16 | +[](http://travis-ci.org/AnthonyRaborn/ShortForm) |
| 17 | + |
| 18 | +Automatic Short Form Creation for scales. Currently, only the Ant Colony Algorithm is implemented. The original R imnplementation for this algorithm is from Leite, Huang, & Marcoulides (2008) <doi:10.1080/00273170802285743>. |
| 19 | + |
| 20 | +## Installation |
| 21 | +```{r gh-installation, eval = FALSE} |
| 22 | +# install.packages("devtools") |
| 23 | +devtools::install_github("AnthonyRaborn/ShortForm") # the developmental version |
| 24 | +install.packages("ShortForm") # the CRAN-approved version |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +Here is a (slightly modified) example from the help documentation using lavaan. |
| 30 | + |
| 31 | +```{r example, eval = FALSE} |
| 32 | +# using simulated test data and the default values for lavaan.model.specs |
| 33 | +# (with one exception), fit a 20-item short form |
| 34 | +# first, read in the original or "full" model |
| 35 | +data(exampleAntModel) # a character vector for a lavaan model |
| 36 | +
|
| 37 | +# then, create the list of the items by the factors |
| 38 | +# in this case, all items load onto the general 'Ability' factor |
| 39 | +list.items <- list(c('Item1','Item2','Item3','Item4','Item5', |
| 40 | +'Item6','Item7','Item8','Item9','Item10', |
| 41 | +'Item11','Item12','Item13','Item14','Item15', |
| 42 | +'Item16','Item17','Item18','Item19','Item20', |
| 43 | +'Item21','Item22','Item23','Item24','Item25', |
| 44 | +'Item26','Item27','Item28','Item29','Item30', |
| 45 | +'Item31','Item32','Item33','Item34','Item35', |
| 46 | +'Item36','Item37','Item38','Item39','Item40', |
| 47 | +'Item41','Item42','Item43','Item44','Item45', |
| 48 | +'Item46','Item47','Item48','Item49','Item50', |
| 49 | +'Item51','Item52','Item53','Item54','Item55','Item56')) |
| 50 | +
|
| 51 | +# load the data |
| 52 | +data(simulated_test_data) |
| 53 | +# finally, call the function with some minor changes to the default values. |
| 54 | +# since the data is binary, let lavaan know by putting the items in the |
| 55 | +# 'orderd' element of the lavaan.model.specs list. |
| 56 | +abilityShortForm = antcolony.lavaan(data = simulated_test_data, |
| 57 | +ants = 5, evaporation = 0.7, antModel = exampleAntModel, |
| 58 | +list.items = list.items, full = 56, i.per.f = 20, |
| 59 | +lavaan.model.specs = list(model.type = "cfa", auto.var = T, estimator = "default", ordered = unlist(list.items), int.ov.free = TRUE, int.lv.free = FALSE, auto.fix.first = TRUE, auto.fix.single = TRUE, auto.cov.lv.x = TRUE, auto.th = TRUE, auto.delta = TRUE, auto.cov.y = TRUE) |
| 60 | +factors = 'Ability', steps = 3, fit.indices = c('cfi', 'rmsea'), |
| 61 | +fit.statistics.test = "(cfi > 0.95)&(rmsea < 0.05)", |
| 62 | +summaryfile = 'summary.txt', |
| 63 | +feedbackfile = 'iteration.html', |
| 64 | +max.run = 500) |
| 65 | +abilityShortForm[[1]] # print the results of the final short form |
| 66 | +``` |
| 67 | + |
| 68 | +A similar example can be found in the `antcolony.mplus` function, but requires you to have a valid Mplus installation on the computer. |
0 commit comments