```
# NOT RUN {
#test the unidimensionality of the five factors of the bfi data set.
unidim(psychTools::bfi,psychTools::bfi.keys)
unidim(psychTools::ability,psychTools::ability.keys)
#Try a known 3 factor structure
x <- sim.minor(nfact=3,bipolar=FALSE) #this makes all the items positive
unidim(x$model)
keys.list <- list(first =c(1:4),second = 5:8,third=9:12,all=1:12)
unidim(x$model,keys.list)
x <- sim.minor(nfact=3)
unidim(x$model,keys.list) #we flip the negative items
#what about a hierarchical model?
H <- sim.hierarchical() # by default, a nice hierarchical model
H.keys <- list(First = paste0("V",1:3),Second=paste0("V",4:6),Third=paste0("V",7:9),
All = paste0("V",1:9))
unidim(H,H.keys)
# }
```

Run the code above in your browser using DataCamp Workspace