I am trying to run an exploratory analysis using PCA to determine the factorial structure of a scale. The packages I am using are:
library(GPArotation) # required for `principal` to work
library(psych)
The function is:
principal()
I would like to apply an adjustment weight based on participants’ gender.
Here is a sample of my dataset:
GPS_01 GPS_03 GPS_04 GPS_05 GPS_07 GPS_08 GPS_10 GPS_11 GPS_12 GPS_13 GPS_14 GPS_15 GPS_17 GPS_18 GPS_19 gender_pscore
1 1 1 2 2 4 1 3 2 1 1 3 1 2 2 4 0.62
2 1 1 1 1 2 1 1 1 1 1 3 2 3 2 1 2.78
3 1 1 1 1 1 1 1 1 1 1 2 1 2 2 1 0.62
4 1 1 2 2 1 1 1 1 1 1 3 1 1 4 1 0.62
5 4 4 4 4 5 5 4 5 4 4 5 2 5 5 4 0.62
6 1 1 1 1 1 1 1 1 1 1 2 2 3 2 2 0.62
7 1 1 1 1 1 1 2 1 1 1 3 2 4 3 2 0.62
8 1 3 1 1 1 1 3 1 2 1 4 1 4 3 2 0.62
9 3 3 3 5 3 1 4 2 3 1 2 1 5 2 3 0.62
10 1 2 1 1 2 2 1 2 1 2 4 2 2 3 2 0.62
11 1 4 1 1 3 4 1 2 3 1 2 2 3 2 3 0.62
12 1 1 1 1 5 2 1 5 1 3 5 4 5 4 5 0.62
13 1 2 1 1 1 4 1 4 1 3 5 1 4 2 5 0.62
14 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.62
15 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0.62
16 1 1 1 1 1 1 2 2 1 1 3 1 1 1 4 0.62
17 2 2 1 2 2 2 4 4 1 4 3 1 2 3 4 0.62
18 1 1 2 2 1 1 1 1 2 1 2 1 2 2 1 0.62
19 1 2 1 1 3 3 1 3 1 1 4 1 3 3 4 0.62
20 1 1 1 2 1 1 2 1 1 1 3 1 2 1 1 2.78
or an even smaller subset of your original data (if easier)
data<-structure(list(GPS_01 = c(1L, 1L, 1L, 1L, 4L, 1L), GPS_03 = c(1L,
1L, 1L, 1L, 4L, 1L), GPS_04 = c(2L, 1L, 1L, 2L, 4L, 1L), GPS_05 = c(2L,
1L, 1L, 2L, 4L, 1L), GPS_07 = c(4L, 2L, 1L, 1L, 5L, 1L), GPS_08 = c(1L,
1L, 1L, 1L, 5L, 1L), GPS_10 = c(3L, 1L, 1L, 1L, 4L, 1L), GPS_11 = c(2L,
1L, 1L, 1L, 5L, 1L), GPS_12 = c(1L, 1L, 1L, 1L, 4L, 1L), GPS_13 = c(1L,
1L, 1L, 1L, 4L, 1L), GPS_14 = c(3L, 3L, 2L, 3L, 5L, 2L), GPS_15 = c(1L,
2L, 1L, 1L, 2L, 2L), GPS_17 = c(2L, 3L, 2L, 1L, 5L, 3L), GPS_18 = c(2L,
2L, 2L, 4L, 5L, 2L), GPS_19 = c(4L, 1L, 1L, 1L, 4L, 2L), gender_pscore = c(0.62,
2.78, 0.62, 0.62, 0.62, 0.62)), row.names = c(NA, 6L), class = "data.frame")
Here the code I used:
pc <- principal(data[,1:15], nfactors = 3, rotate ="oblimin",weights ="gender_pscore")
I always get the same issue:
Error in (function (L, Tmat = diag(ncol(L)), gam = 0, normalize = FALSE, :
unused argument (weights = "gender_pscore")
Error in array(x, c(length(x), 1L), if (!is.null(names(x))) list(names(x), :
'data' must be of a vector type, was 'NULL'
In addition: Warning message:
In data[,1:20], nfactors = 3, rotate = "oblimin", :
The requested transformaton failed, Promax was used instead as an oblique transformation
I am quite new to using R, so not sure how to solve this issue.
The problems disappear when I remove the weights ="gender_pscore"
. But in this case, I can no longer apply an adjustment weight to my factorial analyses based on participants’ gender.