library(lavaan)
## This is lavaan 0.5-18
## lavaan is BETA software! Please report any bugs.
library(semPlot)
library(dplyr)
##
## Attaching package: 'dplyr'
##
## The following objects are masked from 'package:stats':
##
## filter, lag
##
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(GPArotation)
library(psych)
library(car)
##
## Attaching package: 'car'
##
## The following object is masked from 'package:psych':
##
## logit
library(ggplot2)
##
## Attaching package: 'ggplot2'
##
## The following object is masked from 'package:psych':
##
## %+%
library(GGally)
##
## Attaching package: 'GGally'
##
## The following object is masked from 'package:dplyr':
##
## nasa
all_surveys<-read.csv("allsurveysYT1.csv")
all_surveys<-tbl_df(all_surveys)
all_surveys
## Source: local data frame [670 x 178]
##
## X Dataset Gender Age Grade PERMA_1 PERMA_2 PERMA_3 PERMA_4 PERMA_5
## 1 1 NA 2 7 12 6 8 7 9 2
## 2 2 NA 2 6 12 9 7 9 11 13
## 3 3 NA 2 9 10 2 3 2 2 13
## 4 4 NA 1 7 12 9 9 7 8 4
## 5 5 NA 2 7 12 8 6 8 7 4
## 6 6 NA 2 7 12 8 6 7 6 6
## 7 7 NA 2 6 12 7 5 9 8 4
## 8 8 NA 2 8 11 7 8 11 5 4
## 9 9 NA 2 9 10 5 5 5 5 5
## 10 10 NA 2 7 12 7 9 9 11 2
## .. .. ... ... ... ... ... ... ... ... ...
## Variables not shown: PERMA_6 (int), PERMA_7 (int), PERMA_8 (int), PERMA_9
## (int), PERMA_10 (int), PERMA_11 (int), PERMA_12 (int), PERMA_13 (int),
## PERMA_14 (int), PERMA_15 (int), PERMA_16 (int), PERMA_17 (int),
## Dataset.1 (lgl), Gender.1 (int), Age.1 (int), Grade.1 (int), ASDQII_1
## (int), ASDQII_2 (int), ASDQII_3 (int), ASDQII_4 (int), ASDQII_5 (int),
## ASDQII_6 (int), ASDQII_7 (int), ASDQII_8 (int), ASDQII_9 (int),
## ASDQII_10 (int), ASDQII_11 (int), ASDQII_12 (int), ASDQII_13 (int),
## ASDQII_14 (int), ASDQII_15 (int), ASDQII_16 (int), ASDQII_17 (int),
## ASDQII_18 (int), ASDQII_19 (int), ASDQII_20 (int), CPS_1 (int), CPS_2
## (int), CPS_3 (int), CPS_4 (int), CPS_5 (int), CPS_6 (int), CPS_7 (int),
## CPS_8 (int), CPS_9 (int), CPS_10 (int), MLQ_1 (int), MLQ_2 (int), MLQ_3
## (int), MLQ_4 (int), MLQ_5 (int), MLQ_6 (int), MLQ_7 (int), MLQ_8 (int),
## MLQ_9 (int), MLQ_10 (int), LET_1 (int), LET_2 (int), LET_3 (int), LET_4
## (int), LET_5 (int), LET_6 (int), PWB_1 (int), PWB_2 (int), PWB_3 (int),
## PWB_4 (int), PWB_5 (int), PWB_6 (int), PWB_7 (int), PWB_8 (int), PWB_9
## (int), APSI_1 (int), APSI_2 (int), APSI_3 (int), APSI_4 (int), APSI_5
## (int), APSI_6 (int), APSI_7 (int), APSI_8 (int), HAPPI.1_1 (int),
## HAPPI.2_1 (int), HAPPI.3_1 (int), HAPPI.4_1 (int), RES.1 (int), RES.2
## (int), RES.3 (int), SDQI_1 (int), SDQI_2 (int), SDQI_3 (int), SDQI_4
## (int), SDQI_5 (int), SDQI_6 (int), SDQI_7 (int), SDQI_8 (int), SDQI_9
## (int), SDQI_9.1 (int), LOT.R_1 (int), LOT.R_2 (int), LOT.R_3 (int),
## LOT.R_4 (int), LOT.R_5 (int), LOT.R_6 (int), LOT.R_7 (int), LOT.R_8
## (int), LOT.R_9 (int), LOT.R_10 (int), LS_1 (int), LS_2 (int), LS_3
## (int), LS_4 (int), LS_5 (int), Dataset.2 (lgl), Gender.2 (int), Age.2
## (int), Grade.2 (int), SDQIII_1 (int), SDQIII_2 (int), SDQIII_3 (int),
## SDQIII_4 (int), SDQIII_5 (int), SDQIII_6 (int), SDQIII_7 (int), SDQIII_8
## (int), SDQIII_9 (int), SDQIII_10 (int), Dataset.3 (lgl), Gender.3 (int),
## Age.3 (int), Grade.3 (int), SDQIIP_1 (int), SDQIIP_2 (int), SDQIIP_3
## (int), SDQIIP_4 (int), SDQIIP_5 (int), SDQIIP_6 (int), SDQIIP_7 (int),
## SDQIIP_8 (int), Dataset.4 (lgl), Gender.4 (int), Age.4 (int), Grade.4
## (int), GRIT_4 (int), GRIT_5 (int), GRIT_6 (int), GRIT_7 (int), GRIT_8
## (int), GRIT_9 (int), GRIT_10 (int), GRIT_11 (int), Dataset.5 (lgl),
## Gender.5 (int), Age.5 (int), Grade.5 (int), B5F_1 (int), B5F_2 (int),
## B5F_3 (int), B5F_4 (int), B5F_5 (int), B5F_6 (int), B5F_7 (int), B5F_8
## (int), B5F_9 (int), B5F_10 (int), B5F_11 (int), B5F_12 (int), B5F_13
## (int), B5F_14 (int), B5F_15 (int)
GRIT<-select(all_surveys, GRIT_4, GRIT_5, GRIT_6, GRIT_7, GRIT_8, GRIT_9, GRIT_10, GRIT_11)
GRIT<- data.frame(apply(GRIT,2, as.numeric))
GRIT<-tbl_df(GRIT)
GRIT
## Source: local data frame [670 x 8]
##
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## 1 15 16 16 17 16 17 18 18
## 2 15 15 15 17 16 17 16 16
## 3 15 15 14 16 16 17 18 18
## 4 17 15 17 17 15 15 16 17
## 5 16 17 17 17 16 16 18 18
## 6 17 16 16 17 14 17 17 17
## 7 16 15 16 16 17 16 18 17
## 8 16 16 16 16 16 16 17 17
## 9 15 15 15 15 15 17 17 17
## 10 15 14 15 15 18 17 17 17
## .. ... ... ... ... ... ... ... ...
As only one factor
one.factor = 'GRIT =~ GRIT_4 + GRIT_5 + GRIT_6 + GRIT_7 + GRIT_8 + GRIT_9 + GRIT_10 + GRIT_11
'
Two Factor, Positive and Nagative Model
first.model= ' Consistency =~ GRIT_4 + GRIT_5 + GRIT_6 + GRIT_7
Preserverence =~ GRIT_8 + GRIT_9 + GRIT_10 + GRIT_11
'
Bifactor Models (similar to Models 6, 7 & 8 in Marsh, Scalas & Nagengast, 2010)
bifactor.model = 'GRIT =~ GRIT_4 + GRIT_5 + GRIT_6 + GRIT_7 + GRIT_8 + GRIT_9 + GRIT_10 + GRIT_11
Consistency =~ GRIT_4 + GRIT_5 + GRIT_6 + GRIT_7
Preserverence =~ GRIT_8 + GRIT_9 + GRIT_10 + GRIT_11
GRIT ~~ 0*Consistency
GRIT ~~ 0*Preserverence
Consistency~~0*Preserverence
'
Running the models
one.fit=cfa(one.factor, data=GRIT, missing = "fiml", std.lv = T)
## Warning in lav_data_full(data = data, group = group, group.label = group.label, : lavaan WARNING: some cases are empty and will be removed:
## 13 14 15 19 24 25 26 27 28 31 32 33 34 36 38 40 41 43 50 54 55 58 59 65 69 72 73 74 75 76 77 79 80 82 83 86 87 89 90 91 92 95 97 98 100 103 105 106 107 110 111 113 115 117 118 120 123 125 126 127 129 130 131 132 133 137 141 143 146 148 149 150 152 155 158 159 168 169 170 171 173 174 177 178 183 184 185 187 189 190 192 194 195 201 203 207 212 213 214 215 218 219 220 223 225 228 230 233 236 237 239 242 243 247 251 253 254 255 257 258 260 263 264 265 267 268 269 270 271 272 273 274 275 276 277 278 279 280 282 283 284 287 288 289 292 293 300 301 302 303 304 305 306 307 308 309 310 311 313 319 320 321 322 323 324 325 326 327 328 330 331 332 333 334 335 337 339 347 348 349 350 351 355 356 357 358 359 360 362 363 365 366 367 368 370 371 373 375 376 377 378 379 381 384 385 388 389 393 394 396 398 442 443 444 445 446 447 448 449 450 451 452 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
two.fit=cfa(first.model, data=GRIT, missing = "fiml", std.lv = T)
## Warning in lav_data_full(data = data, group = group, group.label = group.label, : lavaan WARNING: some cases are empty and will be removed:
## 13 14 15 19 24 25 26 27 28 31 32 33 34 36 38 40 41 43 50 54 55 58 59 65 69 72 73 74 75 76 77 79 80 82 83 86 87 89 90 91 92 95 97 98 100 103 105 106 107 110 111 113 115 117 118 120 123 125 126 127 129 130 131 132 133 137 141 143 146 148 149 150 152 155 158 159 168 169 170 171 173 174 177 178 183 184 185 187 189 190 192 194 195 201 203 207 212 213 214 215 218 219 220 223 225 228 230 233 236 237 239 242 243 247 251 253 254 255 257 258 260 263 264 265 267 268 269 270 271 272 273 274 275 276 277 278 279 280 282 283 284 287 288 289 292 293 300 301 302 303 304 305 306 307 308 309 310 311 313 319 320 321 322 323 324 325 326 327 328 330 331 332 333 334 335 337 339 347 348 349 350 351 355 356 357 358 359 360 362 363 365 366 367 368 370 371 373 375 376 377 378 379 381 384 385 388 389 393 394 396 398 442 443 444 445 446 447 448 449 450 451 452 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
bifactor.fit=cfa(bifactor.model, data=GRIT, missing = "fiml", orthogonal = TRUE, std.lv = T)
## Warning in lav_data_full(data = data, group = group, group.label = group.label, : lavaan WARNING: some cases are empty and will be removed:
## 13 14 15 19 24 25 26 27 28 31 32 33 34 36 38 40 41 43 50 54 55 58 59 65 69 72 73 74 75 76 77 79 80 82 83 86 87 89 90 91 92 95 97 98 100 103 105 106 107 110 111 113 115 117 118 120 123 125 126 127 129 130 131 132 133 137 141 143 146 148 149 150 152 155 158 159 168 169 170 171 173 174 177 178 183 184 185 187 189 190 192 194 195 201 203 207 212 213 214 215 218 219 220 223 225 228 230 233 236 237 239 242 243 247 251 253 254 255 257 258 260 263 264 265 267 268 269 270 271 272 273 274 275 276 277 278 279 280 282 283 284 287 288 289 292 293 300 301 302 303 304 305 306 307 308 309 310 311 313 319 320 321 322 323 324 325 326 327 328 330 331 332 333 334 335 337 339 347 348 349 350 351 355 356 357 358 359 360 362 363 365 366 367 368 370 371 373 375 376 377 378 379 381 384 385 388 389 393 394 396 398 442 443 444 445 446 447 448 449 450 451 452 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670
Create pictures of models
#One Factor
semPaths(one.fit, whatLabels = "std", layout = "tree", title=T)
#Two Factors Positive and Nagative
semPaths(two.fit, whatLabels = "std", layout = "tree")
#Bifactor Models (similar to Models 6, 7 & 8 in Marsh, Scalas & Nagengast, 2010)
semPaths(bifactor.fit, whatLabels = "std", layout = "tree")
Summaries
summary(one.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after 24 iterations
##
## Used Total
## Number of observations 231 670
##
## Number of missing patterns 1
##
## Estimator ML
## Minimum Function Test Statistic 243.359
## Degrees of freedom 20
## P-value (Chi-square) 0.000
##
## Parameter estimates:
##
## Information Observed
## Standard Errors Standard
##
## Estimate Std.err Z-value P(>|z|) Std.lv Std.all
## Latent variables:
## GRIT =~
## GRIT_4 0.538 0.070 7.640 0.000 0.538 0.512
## GRIT_5 0.733 0.076 9.708 0.000 0.733 0.624
## GRIT_6 1.007 0.068 14.840 0.000 1.007 0.871
## GRIT_7 0.765 0.067 11.363 0.000 0.765 0.701
## GRIT_8 -0.578 0.073 -7.936 0.000 -0.578 -0.537
## GRIT_9 -0.359 0.081 -4.446 0.000 -0.359 -0.317
## GRIT_10 -0.167 0.068 -2.473 0.013 -0.167 -0.182
## GRIT_11 -0.236 0.065 -3.655 0.000 -0.236 -0.265
##
## Intercepts:
## GRIT_4 16.052 0.069 232.033 0.000 16.052 15.267
## GRIT_5 16.216 0.077 209.677 0.000 16.216 13.796
## GRIT_6 16.121 0.076 211.986 0.000 16.121 13.948
## GRIT_7 16.515 0.072 229.762 0.000 16.515 15.117
## GRIT_8 16.342 0.071 230.602 0.000 16.342 15.173
## GRIT_9 16.169 0.075 216.940 0.000 16.169 14.274
## GRIT_10 16.706 0.061 275.655 0.000 16.706 18.137
## GRIT_11 17.091 0.059 291.772 0.000 17.091 19.197
## GRIT 0.000 0.000 0.000
##
## Variances:
## GRIT_4 0.816 0.082 0.816 0.738
## GRIT_5 0.844 0.090 0.844 0.611
## GRIT_6 0.322 0.071 0.322 0.241
## GRIT_7 0.608 0.068 0.608 0.509
## GRIT_8 0.826 0.085 0.826 0.712
## GRIT_9 1.154 0.110 1.154 0.900
## GRIT_10 0.820 0.077 0.820 0.967
## GRIT_11 0.737 0.070 0.737 0.930
## GRIT 1.000 1.000 1.000
##
## R-Square:
##
## GRIT_4 0.262
## GRIT_5 0.389
## GRIT_6 0.759
## GRIT_7 0.491
## GRIT_8 0.288
## GRIT_9 0.100
## GRIT_10 0.033
## GRIT_11 0.070
summary(two.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after 16 iterations
##
## Used Total
## Number of observations 231 670
##
## Number of missing patterns 1
##
## Estimator ML
## Minimum Function Test Statistic 85.901
## Degrees of freedom 19
## P-value (Chi-square) 0.000
##
## Parameter estimates:
##
## Information Observed
## Standard Errors Standard
##
## Estimate Std.err Z-value P(>|z|) Std.lv Std.all
## Latent variables:
## Consistency =~
## GRIT_4 0.543 0.072 7.579 0.000 0.543 0.517
## GRIT_5 0.752 0.078 9.681 0.000 0.752 0.639
## GRIT_6 1.024 0.070 14.589 0.000 1.024 0.886
## GRIT_7 0.777 0.068 11.511 0.000 0.777 0.712
## Preserverence =~
## GRIT_8 0.711 0.075 9.429 0.000 0.711 0.660
## GRIT_9 0.683 0.078 8.799 0.000 0.683 0.603
## GRIT_10 0.659 0.062 10.538 0.000 0.659 0.715
## GRIT_11 0.637 0.059 10.725 0.000 0.637 0.716
##
## Covariances:
## Consistency ~~
## Preserverence -0.342 0.080 -4.280 0.000 -0.342 -0.342
##
## Intercepts:
## GRIT_4 16.052 0.069 232.033 0.000 16.052 15.267
## GRIT_5 16.216 0.077 209.677 0.000 16.216 13.796
## GRIT_6 16.121 0.076 211.986 0.000 16.121 13.948
## GRIT_7 16.515 0.072 229.762 0.000 16.515 15.117
## GRIT_8 16.342 0.071 230.602 0.000 16.342 15.173
## GRIT_9 16.169 0.075 216.940 0.000 16.169 14.274
## GRIT_10 16.706 0.061 275.655 0.000 16.706 18.137
## GRIT_11 17.091 0.059 291.772 0.000 17.091 19.197
## Consistency 0.000 0.000 0.000
## Preserverence 0.000 0.000 0.000
##
## Variances:
## GRIT_4 0.810 0.083 0.810 0.733
## GRIT_5 0.817 0.093 0.817 0.591
## GRIT_6 0.287 0.082 0.287 0.215
## GRIT_7 0.589 0.069 0.589 0.494
## GRIT_8 0.654 0.085 0.654 0.564
## GRIT_9 0.816 0.092 0.816 0.636
## GRIT_10 0.415 0.059 0.415 0.489
## GRIT_11 0.386 0.054 0.386 0.488
## Consistency 1.000 1.000 1.000
## Preserverence 1.000 1.000 1.000
##
## R-Square:
##
## GRIT_4 0.267
## GRIT_5 0.409
## GRIT_6 0.785
## GRIT_7 0.506
## GRIT_8 0.436
## GRIT_9 0.364
## GRIT_10 0.511
## GRIT_11 0.512
summary(bifactor.fit, standardized = TRUE, rsquare=TRUE)
## lavaan (0.5-18) converged normally after 35 iterations
##
## Used Total
## Number of observations 231 670
##
## Number of missing patterns 1
##
## Estimator ML
## Minimum Function Test Statistic 32.842
## Degrees of freedom 12
## P-value (Chi-square) 0.001
##
## Parameter estimates:
##
## Information Observed
## Standard Errors Standard
##
## Estimate Std.err Z-value P(>|z|) Std.lv Std.all
## Latent variables:
## GRIT =~
## GRIT_4 0.356 0.087 4.083 0.000 0.356 0.338
## GRIT_5 0.364 0.109 3.335 0.001 0.364 0.309
## GRIT_6 0.656 0.171 3.837 0.000 0.656 0.568
## GRIT_7 0.500 0.153 3.261 0.001 0.500 0.458
## GRIT_8 -0.839 0.191 -4.402 0.000 -0.839 -0.779
## GRIT_9 -0.406 0.106 -3.813 0.000 -0.406 -0.358
## GRIT_10 -0.127 0.108 -1.166 0.243 -0.127 -0.137
## GRIT_11 -0.301 0.100 -3.015 0.003 -0.301 -0.338
## Consistency =~
## GRIT_4 0.452 0.091 4.963 0.000 0.452 0.429
## GRIT_5 0.717 0.102 7.026 0.000 0.717 0.610
## GRIT_6 0.741 0.171 4.334 0.000 0.741 0.641
## GRIT_7 0.596 0.145 4.106 0.000 0.596 0.546
## Preserverence =~
## GRIT_8 0.357 0.137 2.604 0.009 0.357 0.331
## GRIT_9 0.507 0.112 4.529 0.000 0.507 0.447
## GRIT_10 0.848 0.135 6.294 0.000 0.848 0.921
## GRIT_11 0.513 0.106 4.833 0.000 0.513 0.576
##
## Covariances:
## GRIT ~~
## Consistency 0.000 0.000 0.000
## Preserverence 0.000 0.000 0.000
## Consistency ~~
## Preserverence 0.000 0.000 0.000
##
## Intercepts:
## GRIT_4 16.052 0.069 232.033 0.000 16.052 15.267
## GRIT_5 16.216 0.077 209.677 0.000 16.216 13.796
## GRIT_6 16.121 0.076 211.986 0.000 16.121 13.948
## GRIT_7 16.515 0.072 229.762 0.000 16.515 15.117
## GRIT_8 16.342 0.071 230.602 0.000 16.342 15.173
## GRIT_9 16.169 0.075 216.940 0.000 16.169 14.274
## GRIT_10 16.706 0.061 275.655 0.000 16.706 18.137
## GRIT_11 17.091 0.059 291.772 0.000 17.091 19.197
## GRIT 0.000 0.000 0.000
## Consistency 0.000 0.000 0.000
## Preserverence 0.000 0.000 0.000
##
## Variances:
## GRIT_4 0.775 0.087 0.775 0.701
## GRIT_5 0.735 0.134 0.735 0.532
## GRIT_6 0.356 0.083 0.356 0.267
## GRIT_7 0.588 0.072 0.588 0.493
## GRIT_8 0.330 0.237 0.330 0.284
## GRIT_9 0.862 0.099 0.862 0.672
## GRIT_10 0.113 0.218 0.113 0.133
## GRIT_11 0.439 0.072 0.439 0.554
## GRIT 1.000 1.000 1.000
## Consistency 1.000 1.000 1.000
## Preserverence 1.000 1.000 1.000
##
## R-Square:
##
## GRIT_4 0.299
## GRIT_5 0.468
## GRIT_6 0.733
## GRIT_7 0.507
## GRIT_8 0.716
## GRIT_9 0.328
## GRIT_10 0.867
## GRIT_11 0.446
Residual correlations
correl.1 = residuals(one.fit, type="cor")
correl.1
## $type
## [1] "cor.bollen"
##
## $cor
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## GRIT_4 0.000
## GRIT_5 0.187 0.000
## GRIT_6 -0.009 0.004 0.000
## GRIT_7 -0.046 0.002 0.036 0.000
## GRIT_8 0.014 0.099 0.021 0.039 0.000
## GRIT_9 0.082 0.047 0.029 0.103 0.254 0.000
## GRIT_10 0.153 0.100 0.045 0.115 0.314 0.405 0.000
## GRIT_11 0.089 0.134 0.048 0.049 0.317 0.287 0.528 0.000
##
## $mean
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## 0 0 0 0 0 0 0 0
#View(correl.1$cor)
correl = residuals(two.fit, type="cor")
correl
## $type
## [1] "cor.bollen"
##
## $cor
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## GRIT_4 0.000
## GRIT_5 0.175 0.000
## GRIT_6 -0.021 -0.019 0.000
## GRIT_7 -0.056 -0.016 0.016 0.000
## GRIT_8 -0.144 -0.092 -0.247 -0.177 0.000
## GRIT_9 0.026 -0.019 -0.064 0.027 0.026 0.000
## GRIT_10 0.187 0.143 0.104 0.161 -0.061 0.031 0.000
## GRIT_11 0.080 0.125 0.033 0.037 -0.013 -0.061 0.065 0.000
##
## $mean
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## 0 0 0 0 0 0 0 0
correl3 = residuals(bifactor.fit, type="cor")
correl3
## $type
## [1] "cor.bollen"
##
## $cor
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## GRIT_4 0.000
## GRIT_5 0.139 0.000
## GRIT_6 -0.031 -0.019 0.000
## GRIT_7 -0.077 -0.036 0.037 0.000
## GRIT_8 0.003 0.005 -0.005 0.019 0.000
## GRIT_9 0.041 -0.040 -0.044 0.045 -0.002 0.000
## GRIT_10 0.107 0.029 -0.035 0.050 -0.001 0.002 0.000
## GRIT_11 0.068 0.073 0.009 0.017 0.006 -0.007 0.000 0.000
##
## $mean
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## 0 0 0 0 0 0 0 0
zscore correlation anything over 1.96 is going to be statistically significant at the .05 level
zcorrels10 = residuals(one.fit, type = "standardized")
zcorrels10$cov
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## GRIT_4 NA
## GRIT_5 4.183 NA
## GRIT_6 -0.662 0.480 0.000
## GRIT_7 -1.418 0.070 NA NA
## GRIT_8 0.339 2.853 1.826 1.254 NA
## GRIT_9 1.646 1.072 1.835 2.756 4.733 0.000
## GRIT_10 2.915 2.205 3.325 2.922 5.552 6.068 NA
## GRIT_11 1.755 3.066 3.517 1.282 5.662 4.588 7.379 NA
zcorrels = residuals(two.fit, type = "standardized")
zcorrels$cov
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## GRIT_4 0.000
## GRIT_5 4.440 NA
## GRIT_6 -1.981 -2.789 NA
## GRIT_7 -1.997 -0.784 NA NA
## GRIT_8 -2.512 -1.788 -6.305 -3.552 NA
## GRIT_9 0.459 -0.355 -1.532 0.539 1.169 NA
## GRIT_10 3.349 2.807 3.067 3.402 -3.031 1.384 NA
## GRIT_11 1.445 2.496 1.030 0.783 -0.724 -2.581 NA NA
zcorrels5 = residuals(bifactor.fit, type = "standardized")
zcorrels5$cov
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## GRIT_4 NA
## GRIT_5 NA NA
## GRIT_6 -2.391 -2.447 NA
## GRIT_7 -2.879 -1.911 NA NA
## GRIT_8 NA NA NA NA NA
## GRIT_9 0.785 -0.768 NA 1.527 NA NA
## GRIT_10 2.006 0.536 NA 1.305 NA NA 0.000
## GRIT_11 1.330 1.386 0.536 0.464 NA NA -0.281 0.000
Modification indicies
modindices(one.fit, sort. = TRUE, minimum.value = 3.84)
## lhs op rhs mi epc sepc.lv sepc.all sepc.nox
## 1 GRIT_10 ~~ GRIT_11 73.120 0.442 0.442 0.539 0.539
## 2 GRIT_9 ~~ GRIT_10 44.712 0.434 0.434 0.416 0.416
## 3 GRIT_8 ~~ GRIT_11 38.558 0.334 0.334 0.348 0.348
## 4 GRIT_8 ~~ GRIT_10 35.875 0.338 0.338 0.341 0.341
## 5 GRIT_8 ~~ GRIT_9 25.899 0.344 0.344 0.282 0.282
## 6 GRIT_9 ~~ GRIT_11 23.558 0.300 0.300 0.297 0.297
## 7 GRIT_4 ~~ GRIT_5 22.782 0.295 0.295 0.238 0.238
## 8 GRIT_6 ~~ GRIT_7 16.707 0.309 0.309 0.245 0.245
## 9 GRIT_5 ~~ GRIT_11 8.475 0.162 0.162 0.155 0.155
## 10 GRIT_4 ~~ GRIT_10 8.189 0.160 0.160 0.165 0.165
## 11 GRIT_7 ~~ GRIT_10 7.508 0.141 0.141 0.140 0.140
## 12 GRIT_5 ~~ GRIT_8 6.749 0.163 0.163 0.129 0.129
## 13 GRIT_7 ~~ GRIT_9 6.727 0.161 0.161 0.130 0.130
## 14 GRIT_6 ~~ GRIT_11 5.684 0.118 0.118 0.115 0.115
## 15 GRIT_6 ~~ GRIT_10 4.683 0.111 0.111 0.104 0.104
## 16 GRIT_5 ~~ GRIT_10 4.469 0.123 0.123 0.114 0.114
modindices(two.fit, sort. = TRUE, minimum.value = 3.84)
## lhs op rhs mi epc sepc.lv sepc.all sepc.nox
## 1 Consistency =~ GRIT_8 35.075 -0.429 -0.429 -0.399 -0.399
## 2 GRIT_4 ~~ GRIT_5 22.248 0.294 0.294 0.238 0.238
## 3 Consistency =~ GRIT_10 18.758 0.266 0.266 0.288 0.288
## 4 GRIT_10 ~~ GRIT_11 17.589 0.231 0.231 0.281 0.281
## 5 GRIT_8 ~~ GRIT_10 9.825 -0.191 -0.191 -0.193 -0.193
## 6 GRIT_6 ~~ GRIT_7 8.728 0.318 0.318 0.252 0.252
## 7 GRIT_9 ~~ GRIT_11 6.778 -0.151 -0.151 -0.150 -0.150
## 8 GRIT_6 ~~ GRIT_8 6.282 -0.117 -0.117 -0.094 -0.094
## 9 GRIT_5 ~~ GRIT_6 6.003 -0.237 -0.237 -0.174 -0.174
## 10 Preserverence =~ GRIT_6 5.365 -0.176 -0.176 -0.152 -0.152
## 11 GRIT_4 ~~ GRIT_10 5.254 0.103 0.103 0.106 0.106
modindices(bifactor.fit, sort. = TRUE, minimum.value = 3.84)
## lhs op rhs mi epc sepc.lv sepc.all sepc.nox
## 1 GRIT_4 ~~ GRIT_5 21.447 0.308 0.308 0.249 0.249
## 2 GRIT_6 ~~ GRIT_7 21.447 0.420 0.420 0.333 0.333
## 3 GRIT_4 ~~ GRIT_8 7.039 -0.242 -0.242 -0.213 -0.213
## 4 GRIT_5 ~~ GRIT_6 6.366 -0.280 -0.280 -0.206 -0.206
## 5 GRIT_4 ~~ GRIT_7 6.366 -0.142 -0.142 -0.123 -0.123
## 6 Preserverence =~ GRIT_6 4.852 -0.153 -0.153 -0.133 -0.133
## 7 GRIT_6 ~~ GRIT_10 4.112 -0.095 -0.095 -0.090 -0.090
## 8 GRIT_5 ~~ GRIT_7 4.010 -0.164 -0.164 -0.127 -0.127
## 9 GRIT_4 ~~ GRIT_6 4.010 -0.128 -0.128 -0.105 -0.105
Fit Measures
fitmeasures(one.fit)
## npar fmin chisq
## 24.000 0.527 243.359
## df pvalue baseline.chisq
## 20.000 0.000 599.035
## baseline.df baseline.pvalue cfi
## 28.000 0.000 0.609
## tli nnfi rfi
## 0.452 0.452 0.431
## nfi pnfi ifi
## 0.594 0.424 0.614
## rni logl unrestricted.logl
## 0.609 -2547.295 -2425.615
## aic bic ntotal
## 5142.590 5225.208 231.000
## bic2 rmsea rmsea.ci.lower
## 5149.141 0.220 0.196
## rmsea.ci.upper rmsea.pvalue rmr
## 0.245 0.000 0.145
## rmr_nomean srmr srmr_bentler
## 0.160 0.146 0.146
## srmr_bentler_nomean srmr_bollen srmr_bollen_nomean
## 0.162 0.146 0.162
## srmr_mplus srmr_mplus_nomean cn_05
## 0.146 0.162 30.815
## cn_01 gfi agfi
## 36.658 0.999 0.999
## pgfi mfi ecvi
## 0.454 0.617 NA
fitmeasures(two.fit)
## npar fmin chisq
## 25.000 0.186 85.901
## df pvalue baseline.chisq
## 19.000 0.000 599.035
## baseline.df baseline.pvalue cfi
## 28.000 0.000 0.883
## tli nnfi rfi
## 0.827 0.827 0.789
## nfi pnfi ifi
## 0.857 0.581 0.885
## rni logl unrestricted.logl
## 0.883 -2468.566 -2425.615
## aic bic ntotal
## 4987.132 5073.193 231.000
## bic2 rmsea rmsea.ci.lower
## 4993.957 0.123 0.098
## rmsea.ci.upper rmsea.pvalue rmr
## 0.151 0.000 0.092
## rmr_nomean srmr srmr_bentler
## 0.102 0.082 0.082
## srmr_bentler_nomean srmr_bollen srmr_bollen_nomean
## 0.090 0.082 0.090
## srmr_mplus srmr_mplus_nomean cn_05
## 0.082 0.090 82.060
## cn_01 gfi agfi
## 98.322 1.000 0.999
## pgfi mfi ecvi
## 0.432 0.865 NA
fitmeasures(bifactor.fit)
## npar fmin chisq
## 32.000 0.071 32.842
## df pvalue baseline.chisq
## 12.000 0.001 599.035
## baseline.df baseline.pvalue cfi
## 28.000 0.000 0.964
## tli nnfi rfi
## 0.915 0.915 0.872
## nfi pnfi ifi
## 0.945 0.405 0.964
## rni logl unrestricted.logl
## 0.964 -2442.036 -2425.615
## aic bic ntotal
## 4948.073 5058.230 231.000
## bic2 rmsea rmsea.ci.lower
## 4956.808 0.087 0.052
## rmsea.ci.upper rmsea.pvalue rmr
## 0.123 0.042 0.043
## rmr_nomean srmr srmr_bentler
## 0.048 0.038 0.038
## srmr_bentler_nomean srmr_bollen srmr_bollen_nomean
## 0.042 0.038 0.042
## srmr_mplus srmr_mplus_nomean cn_05
## 0.038 0.042 148.890
## cn_01 gfi agfi
## 185.401 1.000 1.000
## pgfi mfi ecvi
## 0.273 0.956 NA
```
all_surveys<-read.csv("allsurveysYT1.csv")
all_surveys<-tbl_df(all_surveys)
all_surveys
## Source: local data frame [670 x 178]
##
## X Dataset Gender Age Grade PERMA_1 PERMA_2 PERMA_3 PERMA_4 PERMA_5
## 1 1 NA 2 7 12 6 8 7 9 2
## 2 2 NA 2 6 12 9 7 9 11 13
## 3 3 NA 2 9 10 2 3 2 2 13
## 4 4 NA 1 7 12 9 9 7 8 4
## 5 5 NA 2 7 12 8 6 8 7 4
## 6 6 NA 2 7 12 8 6 7 6 6
## 7 7 NA 2 6 12 7 5 9 8 4
## 8 8 NA 2 8 11 7 8 11 5 4
## 9 9 NA 2 9 10 5 5 5 5 5
## 10 10 NA 2 7 12 7 9 9 11 2
## .. .. ... ... ... ... ... ... ... ... ...
## Variables not shown: PERMA_6 (int), PERMA_7 (int), PERMA_8 (int), PERMA_9
## (int), PERMA_10 (int), PERMA_11 (int), PERMA_12 (int), PERMA_13 (int),
## PERMA_14 (int), PERMA_15 (int), PERMA_16 (int), PERMA_17 (int),
## Dataset.1 (lgl), Gender.1 (int), Age.1 (int), Grade.1 (int), ASDQII_1
## (int), ASDQII_2 (int), ASDQII_3 (int), ASDQII_4 (int), ASDQII_5 (int),
## ASDQII_6 (int), ASDQII_7 (int), ASDQII_8 (int), ASDQII_9 (int),
## ASDQII_10 (int), ASDQII_11 (int), ASDQII_12 (int), ASDQII_13 (int),
## ASDQII_14 (int), ASDQII_15 (int), ASDQII_16 (int), ASDQII_17 (int),
## ASDQII_18 (int), ASDQII_19 (int), ASDQII_20 (int), CPS_1 (int), CPS_2
## (int), CPS_3 (int), CPS_4 (int), CPS_5 (int), CPS_6 (int), CPS_7 (int),
## CPS_8 (int), CPS_9 (int), CPS_10 (int), MLQ_1 (int), MLQ_2 (int), MLQ_3
## (int), MLQ_4 (int), MLQ_5 (int), MLQ_6 (int), MLQ_7 (int), MLQ_8 (int),
## MLQ_9 (int), MLQ_10 (int), LET_1 (int), LET_2 (int), LET_3 (int), LET_4
## (int), LET_5 (int), LET_6 (int), PWB_1 (int), PWB_2 (int), PWB_3 (int),
## PWB_4 (int), PWB_5 (int), PWB_6 (int), PWB_7 (int), PWB_8 (int), PWB_9
## (int), APSI_1 (int), APSI_2 (int), APSI_3 (int), APSI_4 (int), APSI_5
## (int), APSI_6 (int), APSI_7 (int), APSI_8 (int), HAPPI.1_1 (int),
## HAPPI.2_1 (int), HAPPI.3_1 (int), HAPPI.4_1 (int), RES.1 (int), RES.2
## (int), RES.3 (int), SDQI_1 (int), SDQI_2 (int), SDQI_3 (int), SDQI_4
## (int), SDQI_5 (int), SDQI_6 (int), SDQI_7 (int), SDQI_8 (int), SDQI_9
## (int), SDQI_9.1 (int), LOT.R_1 (int), LOT.R_2 (int), LOT.R_3 (int),
## LOT.R_4 (int), LOT.R_5 (int), LOT.R_6 (int), LOT.R_7 (int), LOT.R_8
## (int), LOT.R_9 (int), LOT.R_10 (int), LS_1 (int), LS_2 (int), LS_3
## (int), LS_4 (int), LS_5 (int), Dataset.2 (lgl), Gender.2 (int), Age.2
## (int), Grade.2 (int), SDQIII_1 (int), SDQIII_2 (int), SDQIII_3 (int),
## SDQIII_4 (int), SDQIII_5 (int), SDQIII_6 (int), SDQIII_7 (int), SDQIII_8
## (int), SDQIII_9 (int), SDQIII_10 (int), Dataset.3 (lgl), Gender.3 (int),
## Age.3 (int), Grade.3 (int), SDQIIP_1 (int), SDQIIP_2 (int), SDQIIP_3
## (int), SDQIIP_4 (int), SDQIIP_5 (int), SDQIIP_6 (int), SDQIIP_7 (int),
## SDQIIP_8 (int), Dataset.4 (lgl), Gender.4 (int), Age.4 (int), Grade.4
## (int), GRIT_4 (int), GRIT_5 (int), GRIT_6 (int), GRIT_7 (int), GRIT_8
## (int), GRIT_9 (int), GRIT_10 (int), GRIT_11 (int), Dataset.5 (lgl),
## Gender.5 (int), Age.5 (int), Grade.5 (int), B5F_1 (int), B5F_2 (int),
## B5F_3 (int), B5F_4 (int), B5F_5 (int), B5F_6 (int), B5F_7 (int), B5F_8
## (int), B5F_9 (int), B5F_10 (int), B5F_11 (int), B5F_12 (int), B5F_13
## (int), B5F_14 (int), B5F_15 (int)
GRIT<-select(all_surveys, GRIT_4, GRIT_5, GRIT_6, GRIT_7, GRIT_8, GRIT_9, GRIT_10, GRIT_11)
GRIT<- data.frame(apply(GRIT,2, as.numeric))
GRIT<-tbl_df(GRIT)
GRIT
## Source: local data frame [670 x 8]
##
## GRIT_4 GRIT_5 GRIT_6 GRIT_7 GRIT_8 GRIT_9 GRIT_10 GRIT_11
## 1 15 16 16 17 16 17 18 18
## 2 15 15 15 17 16 17 16 16
## 3 15 15 14 16 16 17 18 18
## 4 17 15 17 17 15 15 16 17
## 5 16 17 17 17 16 16 18 18
## 6 17 16 16 17 14 17 17 17
## 7 16 15 16 16 17 16 18 17
## 8 16 16 16 16 16 16 17 17
## 9 15 15 15 15 15 17 17 17
## 10 15 14 15 15 18 17 17 17
## .. ... ... ... ... ... ... ... ...
Target Rotation
## $loadings
##
## Loadings:
## MR1 MR2
## 1 0.566
## 2 0.668
## 3 0.826 -0.114
## 4 0.712
## 5 -0.310 0.554
## 6 0.571
## 7 0.194 0.825
## 8 0.734
##
## MR1 MR2
## SS loadings 2.098 1.872
## Proportion Var 0.262 0.234
## Cumulative Var 0.262 0.496
##
## $score.cor
## [,1] [,2]
## [1,] 1.0000000 -0.2455202
## [2,] -0.2455202 1.0000000
##
## $TLI
## [1] 0.8942695
##
## $RMSEA
## RMSEA lower upper confidence
## 0.09820353 0.07995500 0.11646961 0.10000000
## Factor Analysis using method = minres
## Call: fa(r = GRIT, nfactors = 2, rotate = "TargetQ", Target = Targ_key)
## Standardized loadings (pattern matrix) based upon correlation matrix
## MR1 MR2 h2 u2 com
## 1 0.57 0.07 0.31 0.69 1.0
## 2 0.67 0.05 0.43 0.57 1.0
## 3 0.83 -0.11 0.75 0.25 1.0
## 4 0.71 -0.02 0.51 0.49 1.0
## 5 -0.31 0.55 0.49 0.51 1.6
## 6 -0.06 0.57 0.35 0.65 1.0
## 7 0.19 0.83 0.63 0.37 1.1
## 8 0.06 0.73 0.52 0.48 1.0
##
## MR1 MR2
## SS loadings 2.11 1.88
## Proportion Var 0.26 0.24
## Cumulative Var 0.26 0.50
## Proportion Explained 0.53 0.47
## Cumulative Proportion 0.53 1.00
##
## With factor correlations of
## MR1 MR2
## MR1 1.00 -0.26
## MR2 -0.26 1.00
##
## Mean item complexity = 1.1
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 28 and the objective function was 2.59 with Chi Square of 1725.79
## The degrees of freedom for the model are 13 and the objective function was 0.14
##
## The root mean square of the residuals (RMSR) is 0.04
## The df corrected root mean square of the residuals is 0.06
##
## The harmonic number of observations is 231 with the empirical chi square 20.64 with prob < 0.08
## The total number of observations was 670 with MLE Chi Square = 96.17 with prob < 9.1e-15
##
## Tucker Lewis Index of factoring reliability = 0.894
## RMSEA index = 0.098 and the 90 % confidence intervals are 0.08 0.116
## BIC = 11.58
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## MR1 MR2
## Correlation of scores with factors 0.92 0.90
## Multiple R square of scores with factors 0.84 0.81
## Minimum correlation of possible factor scores 0.68 0.62
CFI
1-((out_targetQ$STATISTIC - out_targetQ$dof)/(out_targetQ$null.chisq- out_targetQ$null.dof))
## [1] 0.9510108