## Load Thurstone's Box data from the fungible library
library(fungible)
data(Box26)
## Create a matrix from Thurstone's solution
## Used as a target matrix to sort columns of the estimated solution
ThurstoneSolution <- matrix(c( .95, .01, .01,
.02, .92, .01,
.02, .05, .91,
.59, .64, -.03,
.60, .00, .62,
-.04, .60, .58,
.81, .38, .01,
.35, .79, .01,
.79, -.01, .41,
.40, -.02, .79,
-.04, .74, .40,
-.02, .41, .74,
.74, -.77, .06,
-.74, .77, -.06,
.74, .02, -.73,
-.74, -.02, .73,
-.07, .80, -.76,
.07, -.80, .76,
.51, .70, -.03,
.56, -.04, .69,
-.02, .60, .58,
.50, .69, -.03,
.52, -.01, .68,
-.01, .60, .55,
.43, .46, .45,
.31, .51, .46), nrow = 26, ncol = 3,
byrow=TRUE)
## Example 1: Multiple solution sets.
## Ignore warnings about non-positive definite sample correlation matrix
suppressWarnings(
fout <- faMain(R = Box26,
numFactors = 3,
facMethod = 'faregLS',
rotate = 'infomaxQ',
targetMatrix = ThurstoneSolution,
rotateControl =
list(numberStarts = 25, ## increase in real problem
standardize = 'none'),
Seed = 123)
)
## Summarize the factor analytic output
summary(object = fout,
digits = 2,
Set = 2,
HPthreshold = .10,
PrintLevel = 1,
DiagnosticsLevel = 2)
## Example 2: Bootstrap Illustration
## Step 1: In an initial analysis, confirm that all rotations converge
## to a single minimum complexity value.
## Step 2: If Step 1 is satisfied then generate bootstrap samples.
## Load Amazon box data
data("AmzBoxes")
## Convert box dimensions into Thurstone's indicators
BoxData <-
GenerateBoxData(AmzBoxes[, 2:4], ## Select columns 2, 3, & 4
BoxStudy = 26, ## 26 indicators
Reliability = 0.75, ## Add unreliability
SampleSize = 200, ## Add sampling error
ModApproxErrVar = 0.1, ## Add model approx error
NMinorFac = 50, ## Number of minor factors
epsTKL = 0.2, ## Spread of minor factor influence
SeedErrorFactors = 1, ## Reproducible starting seed
SeedMinorFactors = 2, ## Reproducible starting seed
PRINT = FALSE, ## Suppress some output
LB = FALSE, ## Do not set lower-bounds
LBVal = 1, ## Lower bound value (ignored)
Constant = 0) ## Do not add constant to data
## Analyze new box data with added measurement error
fout <- faMain(X = BoxData$BoxDataE,
numFactors = 3,
facMethod = 'fapa',
rotate = 'infomaxQ',
targetMatrix = ThurstoneSolution,
bootstrapSE = FALSE,
rotateControl =
list(numberStarts = 25, ## increase in real problem
standardize = 'CM'),
Seed = 1)
## Summarize factor analytic output
sout <- summary(object = fout,
Set = 1,
PrintLevel = 1)
## Generate bootstrap samples
fout <- faMain(X = BoxData$BoxDataE,
numFactors = 3,
facMethod = 'fapa',
rotate = 'infomaxQ',
targetMatrix = ThurstoneSolution,
bootstrapSE = TRUE,
numBoot = 25, ## increase in real problem
rotateControl =
list(numberStarts = 1,
standardize = 'CM'),
Seed = 1)
## Summarize factor analytic output with bootstraps
sout <- summary(object = fout,
Set = 1,
PrintLevel = 2)
## To print a specific solution without computing diagnostics and
## summary information, use the print function.
print(fout,
Set = 1)
Run the code above in your browser using DataLab