|
84 | 84 | #' dem60 =~ y1 + y2 + y3
|
85 | 85 | #' dem60 ~ ind60 "
|
86 | 86 | #' model <- lavaan::sem(structure, data = PoliticalDemocracy)
|
87 |
| -#' # interpret(model) # Not working until new performance is up |
| 87 | +#' interpret(model) |
88 | 88 | #' }
|
| 89 | +#' |
89 | 90 | #' @references
|
90 | 91 | #' - Awang, Z. (2012). A handbook on SEM. Structural equation modeling.
|
91 | 92 | #'
|
@@ -246,137 +247,19 @@ interpret.lavaan <- function(x, ...) {
|
246 | 247 | #' @rdname interpret_gfi
|
247 | 248 | #' @export
|
248 | 249 | interpret.performance_lavaan <- function(x, ...) {
|
249 |
| - table <- data.frame(Name = c(), Value = c(), Interpretation = c(), Threshold = c()) |
250 |
| - |
251 |
| - # GFI |
252 |
| - if ("GFI" %in% names(x)) { |
253 |
| - table <- rbind( |
254 |
| - table, |
255 |
| - data.frame( |
256 |
| - Name = "GFI", |
257 |
| - Value = x$GFI, |
258 |
| - Interpretation = interpret_gfi(x$GFI), |
259 |
| - Threshold = 0.95 |
260 |
| - ) |
261 |
| - ) |
262 |
| - } |
263 |
| - |
264 |
| - # AGFI |
265 |
| - if ("AGFI" %in% names(x)) { |
266 |
| - table <- rbind( |
267 |
| - table, |
268 |
| - data.frame( |
269 |
| - Name = "AGFI", |
270 |
| - Value = x$AGFI, |
271 |
| - Interpretation = interpret_agfi(x$AGFI), |
272 |
| - Threshold = 0.90 |
273 |
| - ) |
274 |
| - ) |
275 |
| - } |
276 |
| - |
277 |
| - # NFI |
278 |
| - if ("NFI" %in% names(x)) { |
279 |
| - table <- rbind( |
280 |
| - table, |
281 |
| - data.frame( |
282 |
| - Name = "NFI", |
283 |
| - Value = x$NFI, |
284 |
| - Interpretation = interpret_nfi(x$NFI, rules = "byrne1994"), |
285 |
| - Threshold = 0.90 |
286 |
| - ) |
287 |
| - ) |
288 |
| - } |
289 |
| - |
290 |
| - # NNFI |
291 |
| - if ("NNFI" %in% names(x)) { |
292 |
| - table <- rbind( |
293 |
| - table, |
294 |
| - data.frame( |
295 |
| - Name = "NNFI", |
296 |
| - Value = x$NNFI, |
297 |
| - Interpretation = interpret_nnfi(x$NNFI, rules = "byrne1994"), |
298 |
| - Threshold = 0.90 |
299 |
| - ) |
300 |
| - ) |
301 |
| - } |
302 |
| - |
303 |
| - # CFI |
304 |
| - if ("CFI" %in% names(x)) { |
305 |
| - table <- rbind( |
306 |
| - table, |
307 |
| - data.frame( |
308 |
| - Name = "CFI", |
309 |
| - Value = x$CFI, |
310 |
| - Interpretation = interpret_cfi(x$CFI), |
311 |
| - Threshold = 0.90 |
312 |
| - ) |
313 |
| - ) |
314 |
| - } |
315 |
| - |
316 |
| - # RMSEA |
317 |
| - if ("RMSEA" %in% names(x)) { |
318 |
| - table <- rbind( |
319 |
| - table, |
320 |
| - data.frame( |
321 |
| - Name = "RMSEA", |
322 |
| - Value = x$RMSEA, |
323 |
| - Interpretation = interpret_rmsea(x$RMSEA), |
324 |
| - Threshold = 0.05 |
325 |
| - ) |
326 |
| - ) |
327 |
| - } |
328 |
| - |
329 |
| - # SRMR |
330 |
| - if ("SRMR" %in% names(x)) { |
331 |
| - table <- rbind( |
332 |
| - table, |
333 |
| - data.frame( |
334 |
| - Name = "SRMR", |
335 |
| - Value = x$SRMR, |
336 |
| - Interpretation = interpret_srmr(x$SRMR), |
337 |
| - Threshold = 0.08 |
338 |
| - ) |
339 |
| - ) |
340 |
| - } |
341 |
| - |
342 |
| - # RFI |
343 |
| - if ("RFI" %in% names(x)) { |
344 |
| - table <- rbind( |
345 |
| - table, |
346 |
| - data.frame( |
347 |
| - Name = "RFI", |
348 |
| - Value = x$RFI, |
349 |
| - Interpretation = interpret_rfi(x$RFI), |
350 |
| - Threshold = 0.90 |
351 |
| - ) |
352 |
| - ) |
353 |
| - } |
354 |
| - |
355 |
| - # IFI |
356 |
| - if ("IFI" %in% names(x)) { |
357 |
| - table <- rbind( |
358 |
| - table, |
359 |
| - data.frame( |
360 |
| - Name = "IFI", |
361 |
| - Value = x$IFI, |
362 |
| - Interpretation = interpret_ifi(x$IFI), |
363 |
| - Threshold = 0.90 |
364 |
| - ) |
365 |
| - ) |
366 |
| - } |
367 |
| - |
368 |
| - # IFI |
369 |
| - if ("PNFI" %in% names(x)) { |
370 |
| - table <- rbind( |
371 |
| - table, |
372 |
| - data.frame( |
373 |
| - Name = "PNFI", |
374 |
| - Value = x$PNFI, |
375 |
| - Interpretation = interpret_pnfi(x$PNFI), |
376 |
| - Threshold = 0.50 |
377 |
| - ) |
| 250 | + mfits <- c("GFI", "AGFI", "NFI", "NNFI", |
| 251 | + "CFI", "RMSEA", "SRMR", "RFI", |
| 252 | + "IFI", "PNFI") |
| 253 | + mfits <- intersect(names(x), mfits) |
| 254 | + |
| 255 | + table <- lapply(mfits, function(ind_name) { |
| 256 | + .interpret_ind <- match.fun(paste0("interpret_", tolower(ind_name))) |
| 257 | + data.frame( |
| 258 | + Name = ind_name, |
| 259 | + Value = x[[ind_name]], |
| 260 | + Interpretation = .interpret_ind(x[[ind_name]]) |
378 | 261 | )
|
379 |
| - } |
| 262 | + }) |
380 | 263 |
|
381 |
| - table |
| 264 | + do.call(rbind, table) |
382 | 265 | }
|
0 commit comments