Factor analysis (PCA)

full_factor(dataset, vars, method = "PCA", hcor = FALSE, nr_fact = 1,
  rotation = "varimax", data_filter = "", envir = parent.frame())

Arguments

dataset

Dataset

vars

Variables to include in the analysis

method

Factor extraction method to use

hcor

Use polycor::hetcor to calculate the correlation matrix

nr_fact

Number of factors to extract

rotation

Apply varimax rotation or no rotation ("varimax" or "none")

data_filter

Expression entered in, e.g., Data > View to filter the dataset in Radiant. The expression should be a string (e.g., "price > 10000")

envir

Environment to extract data from

Value

A list with all variables defined in the function as an object of class full_factor

Details

See https://radiant-rstats.github.io/docs/multivariate/full_factor.html for an example in Radiant

See also

summary.full_factor to summarize results

plot.full_factor to plot results

Examples

full_factor(shopping, "v1:v6") %>% str()
#> List of 16 #> $ floadings :'data.frame': 6 obs. of 1 variable: #> ..$ PC1: num [1:6] 0.9602 -0.0084 0.9227 -0.223 -0.9149 ... #> $ cscm : num [1:6, 1] 0.36039 -0.00315 0.34632 -0.0837 -0.34337 ... #> $ m : Named num [1:6] 0.9602 -0.0084 0.9227 -0.223 -0.9149 ... #> ..- attr(*, "names")= chr [1:6] "v1" "v2" "v3" "v4" ... #> $ fres :List of 28 #> ..$ values : num [1:6] 2.664 2.15 0.473 0.433 0.217 ... #> ..$ rotation : chr "varimax" #> ..$ n.obs : logi NA #> ..$ communality : Named num [1:6] 9.22e-01 7.06e-05 8.51e-01 4.97e-02 8.37e-01 ... #> .. ..- attr(*, "names")= chr [1:6] "v1" "v2" "v3" "v4" ... #> ..$ loadings : 'loadings' num [1:6, 1] 0.9602 -0.0084 0.9227 -0.223 -0.9149 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:6] "v1" "v2" "v3" "v4" ... #> .. .. ..$ : chr "PC1" #> ..$ fit : num 0.583 #> ..$ fit.off : num 0.655 #> ..$ fn : chr "principal" #> ..$ Call : language psych::principal(r = cmat, nfactors = nrFac, rotate = rotation, scores = FALSE, oblique.scores = FALSE) #> ..$ uniquenesses: Named num [1:6] 0.0779 0.9999 0.1485 0.9503 0.163 ... #> .. ..- attr(*, "names")= chr [1:6] "v1" "v2" "v3" "v4" ... #> ..$ complexity : Named num [1:6] 1 1 1 1 1 1 #> .. ..- attr(*, "names")= chr [1:6] "v1" "v2" "v3" "v4" ... #> ..$ chi : num NA #> ..$ EPVAL : num NA #> ..$ R2 : Named num 1 #> .. ..- attr(*, "names")= chr "PC1" #> ..$ objective : num 1.69 #> ..$ residual : num [1:6, 1:6] 0.07794 0.03361 -0.04823 0.11011 0.00307 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:6] "v1" "v2" "v3" "v4" ... #> .. .. ..$ : chr [1:6] "v1" "v2" "v3" "v4" ... #> ..$ rms : num 0.267 #> ..$ factors : int 1 #> ..$ dof : num 9 #> ..$ null.dof : num 15 #> ..$ null.model : num 4.13 #> ..$ criteria : Named num [1:3] 1.69 NA NA #> .. ..- attr(*, "names")= chr [1:3] "objective" "" "" #> ..$ PVAL : logi NA #> ..$ weights : num [1:6, 1] 0.36039 -0.00315 0.34632 -0.0837 -0.34337 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:6] "v1" "v2" "v3" "v4" ... #> .. .. ..$ : chr "PC1" #> ..$ r.scores : num [1, 1] 1 #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr "PC1" #> .. .. ..$ : chr "PC1" #> ..$ Vaccounted : num [1:2, 1] 2.664 0.444 #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:2] "SS loadings" "Proportion Var" #> .. .. ..$ : chr "PC1" #> ..$ Structure : 'loadings' num [1:6, 1] 0.9602 -0.0084 0.9227 -0.223 -0.9149 ... #> .. ..- attr(*, "dimnames")=List of 2 #> .. .. ..$ : chr [1:6] "v1" "v2" "v3" "v4" ... #> .. .. ..$ : chr "PC1" #> ..$ scores : num [1:20, 1] 1.2546 -1.1585 1.4166 0.0974 -1.2608 ... #> ..- attr(*, "class")= chr [1:2] "psych" "principal" #> $ cmat : num [1:6, 1:6] 1 0.0255 0.8378 -0.104 -0.8754 ... #> ..- attr(*, "dimnames")=List of 2 #> .. ..$ : chr [1:6] "v1" "v2" "v3" "v4" ... #> .. ..$ : chr [1:6] "v1" "v2" "v3" "v4" ... #> $ nrFac : num 1 #> $ nrObs : int 20 #> $ anyCategorical: Named logi [1:6] FALSE FALSE FALSE FALSE FALSE FALSE #> ..- attr(*, "names")= chr [1:6] "v1" "v2" "v3" "v4" ... #> $ df_name : chr "shopping" #> $ dataset :Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 20 obs. of 6 variables: #> ..$ v1: num [1:20] 6 2 7 4 1 6 5 7 2 3 ... #> ..$ v2: num [1:20] 4 3 2 6 3 4 3 3 4 5 ... #> ..$ v3: num [1:20] 7 1 6 4 2 6 6 7 3 3 ... #> ..$ v4: num [1:20] 3 4 4 5 2 3 3 4 3 6 ... #> ..$ v5: num [1:20] 2 5 1 3 6 3 3 1 6 4 ... #> ..$ v6: num [1:20] 3 4 3 6 4 4 4 4 3 6 ... #> $ vars : chr [1:6] "v1" "v2" "v3" "v4" ... #> $ method : chr "PCA" #> $ hcor : logi FALSE #> $ nr_fact : num 1 #> $ rotation : chr "varimax" #> $ data_filter : chr "" #> - attr(*, "class")= chr [1:2] "full_factor" "list"