prcr update

Written by: Josh Rosenberg

Primary Source:  Joshua M. Rosenberg – May 17, 2017

The R package for person-oriented analysis (prcr) is updated (it’s now version 0.1.4).

In particular, it was not clear how to use the profile assignments (i.e., what cluster each response is in) in subsequent analyses. So, the update now returns two different representations of the profile assignments, or which profile is associated with each observation: a) the original “data.frame” with the profile assignment added in one variable and b) the original “data.frame” with the profile assignments added in dummy-coded form (i.e., one variable for each profile which is “1” when the observation is associated with the profile and “0” otherwise).

This required changing how the variables used to create the profiles are specified. While before every variable in the “data.frame” was used, so subsetting the “data.frame” before using it, now the whole “data.frame” is the first argument to “create_profiles()”, and variable used to create the profiles are named (unquoted).

Here’s an example with built-in data in which the variables “df”, “disp”, and “hp” are selected:

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

Information about the output (it’s saved to “two_profile_solution”, but it can be any name) can still be viewed with the following methods:

summary(two_profile_solution)
plot(two_profile_solution)

The two representations of the profile assignments can then be used via the “.data” and “data_with_dummy_codes” slots in the output, the first with profile assignment in one variable, the second with the profile assignments in dummy-coded form:

two_profile_solution$.data
two_profile_solution$data_with_dummy_codes

There is also now a function to compare R2 values, here using the same variables as above (“mpg”, “hp”, and “qsec”), comparing 2 to 4 profile solutions:

plot_r_squared(df, mpg, wt, hp, qsec, to_center = TRUE, lower_bound = 2, upper_bound = 4)

Sometimes a “data.frame” is more useful, so the optional argument “r_squared_table” can be set to “TRUE” to return one instead:

plot_r_squared(df, mpg, wt, hp, qsec, to_center = TRUE, lower_bound = 2, upper_bound = 4, r_squared_table = TRUE)

The update can be installed using install.packages("prcr") in R.

The following two tabs change content below.
Joshua M. Rosenberg is a Ph.D. student in the Educational Psychology and Educational Technology program at Michigan State University. In his research, Joshua focuses on how social and cultural factors affect teaching and learning with technologies, in order to better understand and design learning environments that support learning for all students. Joshua currently serves as the associate chair for the Technological Pedagogical Content Knowledge (TPACK) Special Interest Group in the Society for Information Technology and Teacher Education. Joshua was previously a high school science teacher, and holds degrees in education (M.A.) and biology (B.S.).

Latest posts by Josh Rosenberg (see all)