R package to analyse Q methodology data
Would you like to send the author an enquiry about Q methodology? Read this first.The function qmethod()
runs the full analysis with the default loadings and with automatic flagging.
To run more advanced analysis and assess the results at each step, you can run the analysis function by function. For example, to change the automatic flags manually (manual flagging), invert or manipulate Q-sort loadings, continue reading.
The following is sample code to run the analysis function by function. To adapt it to your data, replace lipset[[1]]
with your dataset, and adjust the value of factors
.
data(lipset) # Sample data
library(qmethod)
# Set the number of factors to extract and rotate
factors <- 3
# The following runs Q analysis and keeps only
# the default factor loadings only:
mloa <- qmethod(lipset[[1]],
nfactors = factors,
extraction = "PCA", # Also "centroid"
rotation = "varimax", # Also "none"
forced = TRUE)$loa
mloa # Inspect the loadings
This example inverts the sign of the first factor. To invert other factors, replace 1 with the number of the factor to invert.
mloa[1] <- -mloa[1]
Perform an automatic pre-flagging and inspect.
# Automatic flagging:
mflagged <- qflag(loa = mloa, nstat = 33)
# Inspect the automatic flags:
mflagged
Note: For an easier inspection of flags, see how to print the loadings next to the flags in Step 8 of the Cookbook.
This example eliminates the flag for Q-sort FR9 in factor 3.
mflagged["FR9", 3] <- FALSE
# Create a vector of flags for each factor
# ('TRUE' for flagged Q-sorts):
flags1 <- c(FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE)
flags2 <- c( TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE)
flags3 <- c(FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE)
# Bind the vectors together:
mflagged <- data.frame(flags1, flags2, flags3)
# Set the Q-sort names (not necessary, but useful):
rownames(mflagged) <- rownames(mloa)
results <- qzscores(lipset[[1]],
nfactors = factors,
forced = TRUE,
flagged = mflagged, # Modified flags
loa = mloa) # Modified loadings
results # See your results
results[[8]] <- qdc(lipset[[1]],
nfactors = factors,
zsc = results[[5]],
sed = as.data.frame(results[[7]][[3]]))
names(results)[8] <- "qdc"
results # See your results