Introduction to prcr


prcr is an R package for person-centered analysis. Person-centered analyses focus on clusters, or profiles, of observations, and their change over time or differences across factors. See Bergman and El-Khouri (1999) for a description of the analytic approach. See Corpus and Wormington (2014) for an example of person-centered analysis in psychology and education.


In this example using the built-in to R mtcars data for fuel consumption and other information for 32 automobiles, the variables disp (for engine displacement, in cu. in.), qsec (for the 1/4 mile time, in seconds), and wt for weight (in 1000 lbs.) are clustered with a 2 cluster solution specified. Because the variables are in very different units, the to_scale argument is set to TRUE.


df <- mtcars

two_profile_solution <- create_profiles(df, 
                                        disp, hp, wt,
                                        n_profiles = 2, 
                                        to_scale = T)




The output has the class prcr and has slots for additional information that can be extracted from it, such as the original data with the clustering assignment added, the r-squared (for comparing the relative fit of different cluster solutions) raw clustered data (i.e., for conducting statistical tests to determine whether the cluster centroids are different from one another and for use in additional analyses) and the processed data (i.e., for creating different plots of the cluster centroids).


Comparison of R-squared values can be carried out as follows:

r_squared_output <- plot_r_squared(df, 
                                   disp, hp, wt,
                                   to_scale = T,
                                   r_squared_table = TRUE,
                                   lower_bound = 2, upper_bound = 4)

Cross-validation is now able to be carried out, in this example for the two-profile solution, although n_profiles can also be set to the character string"iterate" in order to explore cross-validation output for a range of profile solutions:

cross_validation_output <- cross_validate(df,
                                          disp, hp, wt,
                                          to_scale = TRUE,
                                          n_profiles = 2,
                                          distance_metric = "squared_euclidean",
                                          linkage = "complete", 
                                          k = 30)

Due to the very small sample size, these results are just for illustrative purposes.

Try the prcr package in your browser

Any scripts or data that you put into this service are public.

prcr documentation built on May 2, 2019, 4:01 p.m.