Dataset is DC0 and DC1 analyze phase only

Need obs to be independent, will address dependence data for students with DC1, etc. later

137 obs and 8 variables

1. Data screening/clean up (short):

a.  Exclude missing cases from the dataset.
b.  Exclude the group variable from the analysis.
nonmissing_data <- na.omit(task_value_DC0_and_DC1_analyze)
# one row removed due to missing data

#Need to make sure the dataset for the parallel analysis only has the variables from the scale questions (no ID and categorical vars)
final <- dplyr::select(nonmissing_data, "X7._Enjoyment", "X8._Importance", "X9._Interesting", "X10._Confident")

2. Run an EFA analysis on the openness to experience scale

a. Number of factors:

    i.  Parallel Analysis: 1 factor
    ii. Scree plot: 1 factor
    iii. Eigenvalues:
    
#Parallel analysis and Scree Plot
parallel <- fa.parallel(final, fm="ml") #don't use fa with updated psych package?

## Parallel analysis suggests that the number of factors =  1  and the number of components =  1
#Call the eigenvalues from parellel analysis
parallel$fa.values
## [1]  2.358534538  0.028088121 -0.005620014 -0.022039183
#then count the number of values over 1 and over 0.7 (two different cutoffs used in literature)
#over 1: 1 factor
#over 0.7: 1 factor

b. Simple structure:

    i.  Set up: run with an oblimin rotation and ML as the type of math.
    ii. Run the analysis excluding questions as they do not load. (still working on this)
onefactor <- fa(final, nfactors = 1, rotate = "oblimin", fm = "ml")
onefactor
## Factor Analysis using method =  ml
## Call: fa(r = final, nfactors = 1, rotate = "oblimin", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
##                  ML1   h2   u2 com
## X7._Enjoyment   0.81 0.66 0.34   1
## X8._Importance  0.76 0.57 0.43   1
## X9._Interesting 0.88 0.78 0.22   1
## X10._Confident  0.59 0.35 0.65   1
## 
##                 ML1
## SS loadings    2.36
## Proportion Var 0.59
## 
## Mean item complexity =  1
## Test of the hypothesis that 1 factor is sufficient.
## 
## The degrees of freedom for the null model are  6  and the objective function was  1.75 with Chi Square of  232.33
## The degrees of freedom for the model are 2  and the objective function was  0 
## 
## The root mean square of the residuals (RMSR) is  0.01 
## The df corrected root mean square of the residuals is  0.02 
## 
## The harmonic number of observations is  136 with the empirical chi square  0.19  with prob <  0.91 
## The total number of observations was  136  with Likelihood Chi Square =  0.43  with prob <  0.81 
## 
## Tucker Lewis Index of factoring reliability =  1.021
## RMSEA index =  0  and the 90 % confidence intervals are  0 0.105
## BIC =  -9.4
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy             
##                                                    ML1
## Correlation of (regression) scores with factors   0.94
## Multiple R square of scores with factors          0.88
## Minimum correlation of possible factor scores     0.76
fa.diagram(onefactor)

Still working on this section

c. Adequate:

    i.  Include fit indices:
        1.  RMSR:
        2.  RMSEA:
        3.  TLI:
        4.  CFI:
    ii. Include reliability:
    iii.    Name your factors: