The IPV package is a tool to create IPV charts. The original work on IPV, including the chart concepts, can be found in: Dantlgraber, M., Stieger, S., & Reips, U. D. (2019). Introducing Item Pool Visualization: A method for investigation of concepts in self-reports and psychometric tests. Methodological Innovations, 12(3), 2059799119884283.. Please cite this paper, as well as this package (Petras, N., & Dantlgraber, M. (2022). IPV: Item Pool visualization. R Package Version 1.0.0) when using the package. The package is built to enable chart creation – quick & dirty or highly customized. Please raise an issue on github in case of bugs or to make suggestions.
The package contains two sets of example data:
?self_confidence
(also available as excel spreadsheets, see
Appendix)?HEXACO
IPV uses the concept of item pools, that can be divided into smaller item (sub-)pools. The hierarchy of terms for item pools in this package is “construct” > “test” > “facet”, from large to small. The total item pool of a (psychological) construct may comprise multiple tests, which in turn may comprise multiple facets. This terminology is based on the common data structure in psychological assessment. But IPV can technically be used for any subdivision of an item pool, if multiple levels of specificity exist (see Dantlgraber et al., 2019). In other words, what is called “test” here does not need to be an actual test, etc.
ipv_est()
.Minimal example:
<- HEXACO[ ,c(2:41, 122:161)] # (1.) HEXACO is a data frame containing raw data
mydata <- ipv_est(mydata, name = "HA") # (2.) produce a formatted bundle of estimates to use
res nested_chart(res, file_name = "test.pdf") # (3.) create a chart with default formatting
There are some additional helper functions, such as the
input_...
functions, which enable you to format already
existing model estimates.
Call ?IPV
for an overview of all functions.
The ipv_est()
function is recommended for model
estimation, because it only needs raw data. It automatically estimates
the models underlying IPV charts. Its output can be plugged into the
chart functions directly.
To use this function, your data needs to be formatted as follows:
For example:
#> id value test facet item
#> 1 2 2 H Sinc Sinc1
#> 2 3 3 H Sinc Sinc1
#> 3 4 4 H Sinc Sinc1
#> 4 5 3 H Sinc Sinc1
#> 5 6 3 H Sinc Sinc1
#> 6 7 3 H Sinc Sinc1
For example:
#> H_Sinc_Sinc2 H_Sinc_Sinc3 H_Sinc_Sinc4
#> 2 2 3 1
#> 3 2 2 2
#> 4 5 5 4
H = honesty/humility (“test”)
Sinc = sincerity (a “facet” of honesty/humility)
Sinc1 = first “item” of the sincerity facet
ipv_est()
automatically determines if the data are in
wide or long format, which models to estimate, uses the lavaan package to estimate them, and
returns an object of class “IPV” with formatted results.
# nested case: honesty/humility and agreeableness as "tests" (= sub-pools)
# of an overarching "construct" (= item pool)
<- ipv_est(dat = HEXACO[ ,c(2:41, 122:161)], name = "HA")
res_HA # simple case: agreeableness only
<- ipv_est(dat = HEXACO[ ,c(122:161)], name = "A") res_A
If any factor loading is below .1 or any center distance below 0, it is set to that value and a warning (or message) is displayed. IPV does not allow negative factor loadings, which is indicated by an error. In this case, check if you have properly recoded negatively keyed items. If there remain negative factor loadings, the data does not fulfill the requirements of IPV (Dantlgraber et al., 2019).
Results are provided as an object of the class “IPV”, which is a list containing (some of) the following elements:
“lav”: the lavaan object for each estimated model (optional)
“est_raw”: estimates (factor loadings, latent correlations) structured based on the item pools, (optional)
“est”: pre-formatted list of center distances and latent correlations for IPV chart creation
You should always inspect the estimated models (“lav”) to understand
what is going on with your data. Use the lavaan functions
(e.g. lavaan::fitmeasures
, lavaan::summary
,
lavaan::lavInspect
) for this purpose.
A more thorough introduction to the formatting of the objects representing model estimates can be found in the section on the alternative workflow in the Appendix.
Use the chart functions (item_chart
,
facet_chart
, nested_chart
) to create an IPV
chart from your data.
All three IPV chart types can be created by specifying
data =
only:
<- item_chart(data = self_confidence)
mychart mychart
If the test =
argument is unspecified, the first test
will automatically be chosen.
It is advisable to use vector-based .pdf graphics output using the
file_name =
argument:
<- item_chart(data = self_confidence, test = "DSSEI", file_name = "DSSEI_item_chart.pdf") mychart
.pdf files can be zoomed and scaled indefinitely without loss of
quality. If you need .png or .jpeg graphics output, use the
dpi =
argument to find a balance between quality and file
size. The file format provided to file_name =
will be used.
By default, no file is saved. Saving manually is not recommended.
It is advisable to inspect the graphics file itself. If you inspect your results within RStudio, always use the zoom pop-out of the Plots window, otherwise charts may be heavily distorted.
Although some graphical options are automatically optimized based on the data, there are many ways to optimize the charts’ appearance (e.g. for print). For example you may use a different colour to guide attention, or re-size elements of the chart for readability.
The parameter cd_method =
allows to switch between
aggregation methods for center distances in facet charts and nested
charts. There are two options:
"aggregate"
computes the sum of the squared loadings of
all items first and in a second step computes the center distance based
on the aggregated values. This is the recommended option and the
default. It is more meaningful in cases with heterogeneous factor
loadings across items.
"mean"
first computes the center distance of each item
and in a second step computes the mean of these center distances. This
is the originally proposed option (Dantlgraber et al., 2019). It can be
intuitively derived from item charts.
The function relabel()
can be used to change any item,
facet, test, or construct name, using a before-after syntax (see
documentation).
Most graphical parameters are size parameters for single elements of
the chart, all named size_... =
, width_... =
,
or length_... =
. Those are pretty straightforward: linear
scaling parameters defaulting to 1. That means, .5 will half the size
and 2 will double it. For all chart types, there is also a global
size =
parameter, scaling all elements of the chart at
once. Use this parameter first, before you fine tune single
elements.
The parameters file_width =
and
file_height =
determine, how large the .pdf file will be,
measured in inches (1 in = 2.54 cm). The size of .png or .jpeg files in
pixels is determined by multiplying the size in inches with the dots per
inch parameter value (dpi =
).
In some cases, it may be desirable to cut the chart to the
informative area for better readability, or to zoom in on a certain
section of the chart. It is possible to create vector-based PDF versions
of sections of the chart. The parameters zoom_x =
and
zoom_y =
can be used to crop the chart to a certain area by
providing lower and upper limits on both dimensions. The aspect ratio is
automatically retained if both parameters are used. This method is
superior to a manual screenshot, because it retains maximum graphics
quality and is exactly reproducible.
For all chart types, it is possible to rotate the whole chart, using
rotate_radians =
(use fractions of \(2\pi\)) or rotate_degrees =
(use 0-360). In all charts, the parameter facet_order =
enables you to set the (counter-clockwise) order of facets. For
example:
item_chart(self_confidence, test = "DSSEI", facet_order = c("Ab", "So", "Ph", "Pb"))
In nested charts, test_order =
and
subrotate_degrees =
/subrotate_radians =
will
function likewise. Several rotate_... =
parameters can be
used to re-position single elements of the chart relative to the
origin.
The font can be changed using the font =
parameter. The
package extrafont allows
access to many more fonts. For changes to the font size, see section 4.3.
To reduce the visibility of structural elements, the
fade_... =
parameters can be used (0 = “black”, 100 =
“white”).
For the use of colours and gray tones, see this guide. All charts functions have at least one colour parameter to increase visual contrast.
The chart functions return a ggplot2 object, which can easily be combined with other geoms or entire plots. The following example uses this to show two facet charts side by side at the same scale:
library(ggplot2)
library(cowplot)
<- facet_chart(self_confidence) +
x coord_fixed(
ratio = 1,
ylim = c(-3, 3),
xlim = c(-3, 3))
#> Axis tick set to 0.1 based on the data.
#> Facet circle radius set to 0.31 based on the data.
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
<- facet_chart(self_confidence, test = "RSES") +
y coord_fixed(
ratio = 1,
ylim = c(-3, 3),
xlim = c(-3, 3))
#> Axis tick set to 0.05 based on the data.
#> Facet circle radius set to 0.211 based on the data.
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.
# Save just as any other ggplot
ggsave(filename = "test.pdf",
plot = plot_grid(plotlist = list(x, y), align = "h"),
width = 20, height = 10) # defaults are optimized for 10x10 inches per chart
You can use different colors for every second item to increase readability of item charts:
<- item_chart(
mychart data = self_confidence, test = "DSSEI",
color = "darkblue", color2 = "darkred")
mychart
The dodge =
parameter allows long facet labels to dodge
the rest of the chart horizontally:
<- self_confidence
x <- relabel(x, "So", "verylongname")
x <- item_chart(data = x, test = "DSSEI")
mychart1 <- item_chart(data = x, test = "DSSEI", dodge = 7)
mychart2
mychart1 mychart2
This works simultaneously for all labels. Labels at the top and bottom do not move, labels on the right and left move the most.
<- facet_chart(data = self_confidence, test = "DSSEI")
mychart #> Axis tick set to 0.1 based on the data.
#> Facet circle radius set to 0.31 based on the data.
mychart
As you can see in the output (and the message in the console), two
parameter values (subradius =
, and tick =
)
have been generated automatically. These can be used to improve
readability. subradius =
sets the size of the facet circles
and tick =
sets the value at which a tick mark should be
displayed.
For a simplistic version of the chart, the correlations can be
omitted, by setting cor_labels = FALSE
. It is also possible
to omit the tick marks emphasizing the center distances by setting
size_marker = 0
.
<- facet_chart(
mychart data = self_confidence,
test = "DSSEI",
cor_labels = FALSE,
size_marker = 0)
#> Axis tick set to 0.1 based on the data.
#> Facet circle radius set to 0.31 based on the data.
mychart
Due to the complexity one should not rely on default values too much:
<- nested_chart(data = self_confidence)
mychart #> Facet circle radius set to 0.211 based on the data.
#> cor_spacing set to 0.193 based on the data.
#> Relative scaling set to 3.78 based on the data.
#> Axis tick set to 0.1 based on the data.
#> dist_construct_label set to 0.5 based on the data.
mychart
There are four important options specific to nested charts:
relative_scaling =
, xarrows =
,
subrotate_... =
, and cor_spacing =
The axis scaling within the nested facet charts is potentially
different to the global axis scaling, by exactly the factor of
relative_scaling =
. This can be seen from the axis tick
marks (small dotted circles), which always indicate the same value.
relative_scaling = 1
is desirable for intuitive
understanding. Nevertheless, relative_scaling =
should be
large enough to avoid circle overlap.
# all axes have the same scaling
nested_chart(self_confidence, relative_scaling = 1, tick = 0.2, rotate_tick_label = -.2)
#> Facet circle radius set to 0.211 based on the data.
#> cor_spacing set to 0.193 based on the data.
#> dist_construct_label set to 0.5 based on the data.
# the global axis is twice as large (see dotted circles)
nested_chart(self_confidence, relative_scaling = 2, tick = 0.2, rotate_tick_label = -.2)
#> Facet circle radius set to 0.211 based on the data.
#> cor_spacing set to 0.193 based on the data.
#> dist_construct_label set to 0.5 based on the data.
In this particular case, the facet circles could be larger, including the font sizes within:
<- nested_chart(
mychart data = self_confidence,
subradius = .5,
size_facet_labels = 2,
size_cor_labels_inner = 1.5)
#> cor_spacing set to 0.28 based on the data.
#> Relative scaling set to 5.97 based on the data.
#> Axis tick set to 0.1 based on the data.
#> dist_construct_label set to 0.5 based on the data.
mychart
Note how the dynamic default for relative_scaling =
adapted
to the changes, because the test circles became larger, due to the
changes to subradius =
.
The addition of correlation arrows between facets of different tests is indicated by the IPV authors as sensible, when the correlation between these facets exceed the correlation between the respective tests. The three arrows in the current example can also be omitted in the display:
<- nested_chart(
mychart data = self_confidence,
subradius = .5,
size_facet_labels = 2,
size_cor_labels_inner = 1.5,
xarrows = FALSE)
#> cor_spacing set to 0.28 based on the data.
#> Relative scaling set to 5.97 based on the data.
#> Axis tick set to 0.1 based on the data.
#> dist_construct_label set to 0.5 based on the data.
mychart
The column names of the data frame providing the data for the arrows need to match the example.
Note that ipv_est()
generates the data frame for these
arrows automatically.
The arrows create a lot of overlap and make the chart look messy. This problem can be solved by rotating each of the nested facet charts, so the facets connected by arrows are oriented towards the center. Furthermore, the construct label should be moved out of harms way, as well as the test label of the SMTQ.
<- nested_chart(
mychart data = self_confidence,
subradius = .5,
size_facet_labels = 2,
size_cor_labels_inner = 1.5,
subrotate_degrees = c(180, 270, 90),
dist_construct_label = .7,
rotate_test_labels_degrees = c(0, 120, 0))
#> cor_spacing set to 0.28 based on the data.
#> Relative scaling set to 5.97 based on the data.
#> Axis tick set to 0.1 based on the data.
mychart
The cor_spacing =
refers to the ring around the nested
facet charts for each test, in which the correlations between the tests
are displayed. It should be large enough for the correlation labels, but
not too large to skew proportions. If the correlations are omitted
(cor_labels_tests = FALSE
), this ring is also omitted:
<- nested_chart(
mychart data = self_confidence,
subradius = .5,
size_facet_labels = 2,
size_cor_labels_inner = 1.5,
subrotate_degrees = c(180, 270, 90),
dist_construct_label = .7,
rotate_test_labels_degrees = c(0, 120, 0),
cor_labels_tests = FALSE)
#> Relative scaling set to 5.05 based on the data.
#> Axis tick set to 0.1 based on the data.
mychart
Color can be chosen for the global and the nested level independently. Increasing the line thickness makes the colors more visible.
<- nested_chart(
mychart data = self_confidence,
subradius = .5,
size_facet_labels = 2,
size_cor_labels_inner = 1.5,
subrotate_degrees = c(180, 270, 90),
dist_construct_label = .7,
rotate_construct_label_degrees = -15,
rotate_test_labels_degrees = c(0, 120, 0),
size_construct_label = 1.3,
size_test_labels = 1.2,
width_circles_inner = 1.2,
width_circles = 1.2,
width_axes_inner = 1.2,
width_axes = 1.2)
#> cor_spacing set to 0.28 based on the data.
#> Relative scaling set to 5.97 based on the data.
#> Axis tick set to 0.1 based on the data.
mychart
This is an example of the data format of the class “IPV”, which is
required for the use of the chart functions and produced by
ipv_est()
:
str(self_confidence, 2)
#> List of 2
#> $ est :List of 2
#> ..$ global:List of 2
#> ..$ tests :List of 3
#> $ xarrow:'data.frame': 3 obs. of 5 variables:
#> ..$ test1 : chr [1:3] "DSSEI" "DSSEI" "SMTQ"
#> ..$ facet1: chr [1:3] "Ab" "Ab" "Ct"
#> ..$ test2 : chr [1:3] "RSES" "SMTQ" "RSES"
#> ..$ facet2: chr [1:3] "Ps" "Cs" "Ns"
#> ..$ value : chr [1:3] ".67" ".81" ".76"
#> - attr(*, "class")= chr [1:2] "IPV" "list"
$tests$RSES
self_confidence#> NULL
Note, that factor
refers to an item pool, that was
divided into subpools (subfactor
s). In this case,
factor
refers to the Rosenberg Self-Esteem Scale, a test
that can be divided in two facets: Positive Self-Esteem (Ps), and
Negative Self-Esteem (Ns), which was reversed here. As seen below, the
same data structure applies on the global level, with
factor
referring to the overall self-confidence item pool,
comprising the three tests (subfactor
s) RSES, SMTQ, and
DSSEI.
$global
self_confidence#> NULL
cd
is short for center distance
\[\begin{equation}
cd_i = \frac{\lambda^2_{is}}{\lambda^2_{ig}} -1
\end{equation}\]
while mean_cd
is the mean center distance of the items of a
facet or test. aggregate_cd
is the center distance of a
facet or test as a whole (see cd_method
). Furthermore, the
matrix of latent correlations between subfactor
s is given
as a second item of the list.
There is a raw variant ($est_raw
in the output of
ipv_est
) of this, providing factor loadings instead of
center distances.
Using ipv_est()
will take less effort than
estimating the models yourself and reading in the estimates. For this
reason, it is recommended. On the other hand, reading in
existing estimates provides you with additional options during model
estimation, or the ability to use published estimates without access to
the raw data.
Regardless of the input mode, you will need to provide:
To spare you the task of formatting estimates by hand, there are two automated input pathways. You can either use excel files or the manual input function. In both cases, center distances are calculated automatically and the estimates are automatically checked for (obvious) errors. Negative center distances are always set to zero before mean center distances are calculated.
These functions allow you to reduce the manual work to a minimum.
They are especially useful, when your SEM estimates are already in your
R environment (e.g. because you read them from a .csv file). The
functions input_manual_nested()
and
input_manual_simple()
allow you to feed in vectors of
factor loadings, item names, etc. The correct format for plotting is
then generated automatically. Run input_manual_process()
on
the result, to automatically calculate center distances.
This is an example, where all estimates are put in completely manually
for demonstration purposes:
<- input_manual_simple(
mydata test_name = "RSES",
facet_names = c("Ns", "Ps"),
items_per_facet = 5,
item_names = c(
2, 5, 6, 8, 9,
1, 3, 4, 7, 10),
test_loadings = c(
5806, .5907, .6179, .5899, .6559,
.6005, .4932, .4476, .5033, .6431),
.facet_loadings = c(
6484, .6011, .6988, .6426, .6914,
.6422, .5835, .536, .5836, .6791),
.correlation_matrix = matrix(
data = c(1, .69,
69, 1),
.nrow = 2,
ncol = 2))
mydata#> $fls
#> factor subfactor item factor_loading subfactor_loading
#> 1 RSES Ns 2 0.5806 0.6484
#> 2 RSES Ns 5 0.5907 0.6011
#> 3 RSES Ns 6 0.6179 0.6988
#> 4 RSES Ns 8 0.5899 0.6426
#> 5 RSES Ns 9 0.6559 0.6914
#> 6 RSES Ps 1 0.6005 0.6422
#> 7 RSES Ps 3 0.4932 0.5835
#> 8 RSES Ps 4 0.4476 0.5360
#> 9 RSES Ps 7 0.5033 0.5836
#> 10 RSES Ps 10 0.6431 0.6791
#>
#> $cors
#> Ns Ps
#> Ns 1.00 0.69
#> Ps 0.69 1.00
input_manual_process(mydata)
#> $est
#> $est$global
#> $est$global$cds
#> factor subfactor item cd mean_cd aggregate_cd
#> 1 RSES RSES RSES.2 0 0 0
#> 2 RSES RSES RSES.5 0 0 0
#> 3 RSES RSES RSES.6 0 0 0
#> 4 RSES RSES RSES.8 0 0 0
#> 5 RSES RSES RSES.9 0 0 0
#> 6 RSES RSES RSES.1 0 0 0
#> 7 RSES RSES RSES.3 0 0 0
#> 8 RSES RSES RSES.4 0 0 0
#> 9 RSES RSES RSES.7 0 0 0
#> 10 RSES RSES RSES.10 0 0 0
#>
#> $est$global$cors
#> RSES
#> RSES 1
#>
#>
#> $est$tests
#> $est$tests$RSES
#> $est$tests$RSES$cds
#> factor subfactor item cd mean_cd aggregate_cd
#> 1 RSES Ns 2 0.24718807 0.1719081 0.1706512
#> 2 RSES Ns 5 0.03552244 0.1719081 0.1706512
#> 3 RSES Ns 6 0.27899664 0.1719081 0.1706512
#> 4 RSES Ns 8 0.18665548 0.1719081 0.1706512
#> 5 RSES Ns 9 0.11117763 0.1719081 0.1706512
#> 6 RSES Ps 1 0.14370647 0.2874100 0.2521100
#> 7 RSES Ps 3 0.39970201 0.2874100 0.2521100
#> 8 RSES Ps 4 0.43400090 0.2874100 0.2521100
#> 9 RSES Ps 7 0.34454922 0.2874100 0.2521100
#> 10 RSES Ps 10 0.11509134 0.2874100 0.2521100
#>
#> $est$tests$RSES$cors
#> Ns Ps
#> Ns 1.00 0.69
#> Ps 0.69 1.00
#>
#>
#>
#>
#> $est_raw
#> $est_raw$global
#> $est_raw$global$fls
#> factor subfactor item factor_loading subfactor_loading
#> 1 RSES RSES RSES.2 0.5806 0.5806
#> 2 RSES RSES RSES.5 0.5907 0.5907
#> 3 RSES RSES RSES.6 0.6179 0.6179
#> 4 RSES RSES RSES.8 0.5899 0.5899
#> 5 RSES RSES RSES.9 0.6559 0.6559
#> 6 RSES RSES RSES.1 0.6005 0.6005
#> 7 RSES RSES RSES.3 0.4932 0.4932
#> 8 RSES RSES RSES.4 0.4476 0.4476
#> 9 RSES RSES RSES.7 0.5033 0.5033
#> 10 RSES RSES RSES.10 0.6431 0.6431
#>
#> $est_raw$global$cors
#> RSES
#> RSES 1
#>
#>
#> $est_raw$tests
#> $est_raw$tests$RSES
#> $est_raw$tests$RSES$fls
#> factor subfactor item factor_loading subfactor_loading
#> 1 RSES Ns 2 0.5806 0.6484
#> 2 RSES Ns 5 0.5907 0.6011
#> 3 RSES Ns 6 0.6179 0.6988
#> 4 RSES Ns 8 0.5899 0.6426
#> 5 RSES Ns 9 0.6559 0.6914
#> 6 RSES Ps 1 0.6005 0.6422
#> 7 RSES Ps 3 0.4932 0.5835
#> 8 RSES Ps 4 0.4476 0.5360
#> 9 RSES Ps 7 0.5033 0.5836
#> 10 RSES Ps 10 0.6431 0.6791
#>
#> $est_raw$tests$RSES$cors
#> Ns Ps
#> Ns 1.00 0.69
#> Ps 0.69 1.00
#>
#>
#>
#>
#> $xarrow
#> [1] NA
#>
#> attr(,"class")
#> [1] "IPV" "list"
For nested cases, use the function
input_manual_nested()
, and add the individual tests using
input_manual_simple()
. Then you can run
input_manual_processs()
as in the simple case. You can find
a (lengthy) example below.
Excel files have the advantage that you can simply copy and paste
your SEM estimates into spreadsheets and the input function of the IPV
package (input_excel()
) does the rest. The files need to be
structured as in the example, that you can find here:
system.file("extdata", "IPV_global.xlsx", package = "IPV", mustWork = TRUE)
system.file("extdata", "IPV_DSSEI.xlsx", package = "IPV", mustWork = TRUE)
system.file("extdata", "IPV_SMTQ.xlsx", package = "IPV", mustWork = TRUE)
system.file("extdata", "IPV_RSES.xlsx", package = "IPV", mustWork = TRUE)
As you can see, there is a file for each test, and a global file. You might want to use a copy as your template, so you can just fill in your values. Open a file to see how it works.
On sheet 1 you need to provide the factor loadings from your SEM
estimation results, on sheet 2 you need to provide the named and
complete latent correlation matrix. On sheet 1, “factor” contains a
single factor name and “factor_loading” the factor loadings of items on
that factor (not squared). “subfactor” contains the names of grouped
factors and “subfactor_loading” the factor loadings of items on these
factors (not squared). “item” contains the item names. Therefore, each
row contains the full information on the respective item.
Read these excel sheets using input_excel. In the example:
<- system.file("extdata", "IPV_global.xlsx", package = "IPV", mustWork = TRUE)
global <- c(system.file("extdata", "IPV_DSSEI.xlsx", package = "IPV", mustWork = TRUE),
tests system.file("extdata", "IPV_SMTQ.xlsx", package = "IPV", mustWork = TRUE),
system.file("extdata", "IPV_RSES.xlsx", package = "IPV", mustWork = TRUE))
<- input_excel(global = global, tests = tests)
mydata #> New names:
#> Negative center distance adjusted to 0
#> New names:
#> New names:
#> Negative center distance adjusted to 0
#> New names:
#> Negative center distance adjusted to 0
#> New names:
#> New names:
#> New names:
#> New names:
#> • `` -> `...1`
The data will be prepared automatically, including the calculation of center distances. If any factor loading is below .1 or any center distance below 0, it is set to that value and a warning or message is displayed. IPV does not allow negative factor loadings, which is indicated by an error. If possible, recode your data appropriately.
In nested charts, tests do not need to have facets. If you use input
by excel, use NA
instead of providing a file name.
<- system.file("extdata", "IPV_global.xlsx", package = "IPV", mustWork = TRUE)
global <- c(system.file("extdata", "IPV_DSSEI.xlsx", package = "IPV", mustWork = TRUE),
tests system.file("extdata", "IPV_SMTQ.xlsx", package = "IPV", mustWork = TRUE),
NA)
<- input_excel(global = global, tests = tests) mydata
If you use manual input, do not provide data on facetless tests with
input_manual_simple()
. Any further treatment of facetless
tests is handled automatically.
Note that all values that are put in manually for presentation purposes here could be read from an arbitrarily formatted R object. Copying values manually from another source is error-prone and therefore not recommended.
# first the global level
<- input_manual_nested(
mydata construct_name = "Self-Confidence",
test_names = c("DSSEI", "SMTQ", "RSES"),
items_per_test = c(20, 14, 10),
item_names = c(
1, 5, 9, 13, 17, # DSSEI
3, 7, 11, 15, 19, # DSSEI
16, 4, 12, 8, 20, # DSSEI
2, 6, 10, 14, 18, # DSSEI
11, 13, 14, 1, 5, 6, # SMTQ
3, 10, 12, 8, # SMTQ
7, 2, 4, 9, # SMTQ
1, 3, 4, 7, 10, # RSES
2, 5, 6, 8, 9), # RSES
construct_loadings = c(
5189, .6055, .618 , .4074, .4442,
.5203, .2479, .529 , .554 , .5144,
.3958, .5671, .5559, .4591, .4927,
.3713, .5941, .4903, .5998, .6616,
.4182, .2504, .4094, .3977, .5177, .4603,
.3271, .261 , .3614, .4226,
.2076, .3375, .5509, .3495,
.5482, .4627, .4185, .4185, .5319,
.4548, .4773, .4604, .4657, .4986),
.test_loadings = c(
5694, .6794, .6615, .4142, .4584, # DSSEI
.5554, .2165, .5675, .5649, .4752, # DSSEI
.443 , .6517, .6421, .545 , .5266, # DSSEI
.302 , .6067, .5178, .5878, .6572, # DSSEI
.4486, .3282, .4738, .4567, .5986, .5416, # SMTQ
.3602, .2955, .3648, .4814, # SMTQ
.2593, .4053, .61 , .4121, # SMTQ
.6005, .4932, .4476, .5033, .6431, # RSES
.5806, .5907, .6179, .5899, .6559), # RSES
.correlation_matrix = matrix(
data = c(
1 , .73, .62,
73, 1, .75,
.62, .75, 1),
.nrow = 3,
ncol = 3))
# then add tests individually
# test 1
$tests$RSES <- input_manual_simple(
mydatatest_name = "RSES",
facet_names = c("Ns", "Ps"),
items_per_facet = c(5, 5),
item_names = c(
2, 5, 6, 8, 9,
1, 3, 4, 7, 10),
test_loadings = c(
5806, .5907, .6179, .5899, .6559,
.6005, .4932, .4476, .5033, .6431),
.facet_loadings = c(
6484, .6011, .6988, .6426, .6914,
.6422, .5835, .536, .5836, .6791),
.correlation_matrix = matrix(
data = c(
1, .69,
69, 1),
.nrow = 2,
ncol = 2))
# test 2
$tests$DSSEI <- input_manual_simple(
mydatatest_name = "DSSEI",
facet_names = c("Ab", "Pb", "Ph", "So"),
items_per_facet = 5,
item_names = c(
2, 6, 10, 14, 18,
16, 4, 12, 8, 20,
3, 7, 11, 15, 19,
1, 5, 9, 13, 17),
test_loadings = c(
302 , .6067, .5178, .5878, .6572,
.443 , .6517, .6421, .545 , .5266,
.5554, .2165, .5675, .5649, .4752,
.5694, .6794, .6615, .4142, .4584),
.facet_loadings = c(
3347, .6537, .6078, .684 , .735 ,
.6861, .8746, .7982, .7521, .6794,
.7947, .3737, .819 , .7099, .5785,
.7293, .8284, .7892, .3101, .4384),
.correlation_matrix = matrix(
data = c(
1, .49, .66, .76,
49, 1, .37, .54,
.66, .37, 1, .53,
.76, .54, .53, 1),
.nrow = 4,
ncol = 4))
# test 3
$tests$SMTQ <- input_manual_simple(
mydatatest_name = "SMTQ",
facet_names = c("Cf", "Cs", "Ct"),
items_per_facet = c(6, 4, 4),
item_names = c(
11, 13, 14, 1, 5, 6,
3, 10, 12, 8,
7, 2, 4, 9),
test_loadings = c(
4486, .3282, .4738, .4567, .5986, .5416,
.3602, .2955, .3648, .4814,
.2593, .4053, .61 , .4121),
.facet_loadings = c(
4995, .3843, .5399, .4562, .6174, .6265,
.4601, .3766, .4744, .5255,
.3546, .5038, .7429, .4342),
.correlation_matrix = matrix(
data = c(
1, .71, .62,
71, 1, .59,
.62, .59, 1),
.nrow = 3,
ncol = 3))
# finally process (as in a simple case)
<- input_manual_process(mydata)
my_processed_data #> Negative center distance adjusted to 0
#> Negative center distance adjusted to 0
#> Negative center distance adjusted to 0
my_processed_data#> $est
#> $est$global
#> $est$global$cds
#> factor subfactor item cd mean_cd aggregate_cd
#> 1 Self-Confidence DSSEI DSSEI.1 0.20411394 0.1327392 0.1135489
#> 2 Self-Confidence DSSEI DSSEI.5 0.25899148 0.1327392 0.1135489
#> 3 Self-Confidence DSSEI DSSEI.9 0.14573122 0.1327392 0.1135489
#> 4 Self-Confidence DSSEI DSSEI.13 0.03366102 0.1327392 0.1135489
#> 5 Self-Confidence DSSEI DSSEI.17 0.06495709 0.1327392 0.1135489
#> 6 Self-Confidence DSSEI DSSEI.3 0.13947316 0.1327392 0.1135489
#> 7 Self-Confidence DSSEI DSSEI.7 0.00000000 0.1327392 0.1135489
#> 8 Self-Confidence DSSEI DSSEI.11 0.15085441 0.1327392 0.1135489
#> 9 Self-Confidence DSSEI DSSEI.15 0.03973729 0.1327392 0.1135489
#> 10 Self-Confidence DSSEI DSSEI.19 0.00000000 0.1327392 0.1135489
#> 11 Self-Confidence DSSEI DSSEI.16 0.25272537 0.1327392 0.1135489
#> 12 Self-Confidence DSSEI DSSEI.4 0.32061476 0.1327392 0.1135489
#> 13 Self-Confidence DSSEI DSSEI.12 0.33417252 0.1327392 0.1135489
#> 14 Self-Confidence DSSEI DSSEI.8 0.40921877 0.1327392 0.1135489
#> 15 Self-Confidence DSSEI DSSEI.20 0.14234316 0.1327392 0.1135489
#> 16 Self-Confidence DSSEI DSSEI.2 0.00000000 0.1327392 0.1135489
#> 17 Self-Confidence DSSEI DSSEI.6 0.04286690 0.1327392 0.1135489
#> 18 Self-Confidence DSSEI DSSEI.10 0.11532209 0.1327392 0.1135489
#> 19 Self-Confidence DSSEI DSSEI.14 0.00000000 0.1327392 0.1135489
#> 20 Self-Confidence DSSEI DSSEI.18 0.00000000 0.1327392 0.1135489
#> 21 Self-Confidence SMTQ SMTQ.11 0.15066918 0.3341203 0.3027064
#> 22 Self-Confidence SMTQ SMTQ.13 0.71794203 0.3341203 0.3027064
#> 23 Self-Confidence SMTQ SMTQ.14 0.33935109 0.3341203 0.3027064
#> 24 Self-Confidence SMTQ SMTQ.1 0.31871468 0.3341203 0.3027064
#> 25 Self-Confidence SMTQ SMTQ.5 0.33695594 0.3341203 0.3027064
#> 26 Self-Confidence SMTQ SMTQ.6 0.38444390 0.3341203 0.3027064
#> 27 Self-Confidence SMTQ SMTQ.3 0.21262447 0.3341203 0.3027064
#> 28 Self-Confidence SMTQ SMTQ.10 0.28184040 0.3341203 0.3027064
#> 29 Self-Confidence SMTQ SMTQ.12 0.01890422 0.3341203 0.3027064
#> 30 Self-Confidence SMTQ SMTQ.8 0.29763690 0.3341203 0.3027064
#> 31 Self-Confidence SMTQ SMTQ.7 0.56009245 0.3341203 0.3027064
#> 32 Self-Confidence SMTQ SMTQ.2 0.44213412 0.3341203 0.3027064
#> 33 Self-Confidence SMTQ SMTQ.4 0.22606678 0.3341203 0.3027064
#> 34 Self-Confidence SMTQ SMTQ.9 0.39030751 0.3341203 0.3027064
#> 35 Self-Confidence RSES RSES.1 0.19990803 0.4685707 0.4677902
#> 36 Self-Confidence RSES RSES.3 0.13617999 0.4685707 0.4677902
#> 37 Self-Confidence RSES RSES.4 0.14390308 0.4685707 0.4677902
#> 38 Self-Confidence RSES RSES.7 0.44631515 0.4685707 0.4677902
#> 39 Self-Confidence RSES RSES.10 0.46183057 0.4685707 0.4677902
#> 40 Self-Confidence RSES RSES.2 0.62972058 0.4685707 0.4677902
#> 41 Self-Confidence RSES RSES.5 0.53162016 0.4685707 0.4677902
#> 42 Self-Confidence RSES RSES.6 0.80121585 0.4685707 0.4677902
#> 43 Self-Confidence RSES RSES.8 0.60451698 0.4685707 0.4677902
#> 44 Self-Confidence RSES RSES.9 0.73049645 0.4685707 0.4677902
#>
#> $est$global$cors
#> DSSEI SMTQ RSES
#> DSSEI 1.00 0.73 0.62
#> SMTQ 0.73 1.00 0.75
#> RSES 0.62 0.75 1.00
#>
#>
#> $est$tests
#> $est$tests$DSSEI
#> $est$tests$DSSEI$cds
#> factor subfactor item cd mean_cd aggregate_cd
#> 1 DSSEI Ab 2 0.2282804 0.2743874 0.2738012
#> 2 DSSEI Ab 6 0.1609379 0.2743874 0.2738012
#> 3 DSSEI Ab 10 0.3778353 0.2743874 0.2738012
#> 4 DSSEI Ab 14 0.3541072 0.2743874 0.2738012
#> 5 DSSEI Ab 18 0.2507761 0.2743874 0.2738012
#> 6 DSSEI Pb 16 1.3986528 0.8627867 0.8039587
#> 7 DSSEI Pb 4 0.8010406 0.8627867 0.8039587
#> 8 DSSEI Pb 12 0.5453189 0.8627867 0.8039587
#> 9 DSSEI Pb 8 0.9044000 0.8627867 0.8039587
#> 10 DSSEI Pb 20 0.6645214 0.8627867 0.8039587
#> 11 DSSEI Ph 3 1.0473622 1.0341577 0.8657735
#> 12 DSSEI Ph 7 1.9794108 1.0341577 0.8657735
#> 13 DSSEI Ph 11 1.0827449 1.0341577 0.8657735
#> 14 DSSEI Ph 15 0.5792512 1.0341577 0.8657735
#> 15 DSSEI Ph 19 0.4820193 1.0341577 0.8657735
#> 16 DSSEI So 1 0.6405048 0.3101167 0.3266159
#> 17 DSSEI So 5 0.4867197 0.3101167 0.3266159
#> 18 DSSEI So 9 0.4233590 0.3101167 0.3266159
#> 19 DSSEI So 13 0.0000000 0.3101167 0.3266159
#> 20 DSSEI So 17 0.0000000 0.3101167 0.3266159
#>
#> $est$tests$DSSEI$cors
#> Ab Pb Ph So
#> Ab 1.00 0.49 0.66 0.76
#> Pb 0.49 1.00 0.37 0.54
#> Ph 0.66 0.37 1.00 0.53
#> So 0.76 0.54 0.53 1.00
#>
#>
#> $est$tests$SMTQ
#> $est$tests$SMTQ$cds
#> factor subfactor item cd mean_cd aggregate_cd
#> 1 SMTQ Cf 11 0.23980233 0.2185428 0.1986201
#> 2 SMTQ Cf 13 0.37108259 0.2185428 0.1986201
#> 3 SMTQ Cf 14 0.29848382 0.2185428 0.1986201
#> 4 SMTQ Cf 1 0.00000000 0.2185428 0.1986201
#> 5 SMTQ Cf 5 0.06379961 0.2185428 0.1986201
#> 6 SMTQ Cf 6 0.33808850 0.2185428 0.1986201
#> 7 SMTQ Cs 3 0.63161260 0.5346459 0.4688794
#> 8 SMTQ Cs 10 0.62422302 0.5346459 0.4688794
#> 9 SMTQ Cs 12 0.69114054 0.5346459 0.4688794
#> 10 SMTQ Cs 8 0.19160761 0.5346459 0.4688794
#> 11 SMTQ Ct 7 0.87013272 0.5021480 0.4480744
#> 12 SMTQ Ct 2 0.54512322 0.5021480 0.4480744
#> 13 SMTQ Ct 4 0.48320454 0.5021480 0.4480744
#> 14 SMTQ Ct 9 0.11013146 0.5021480 0.4480744
#>
#> $est$tests$SMTQ$cors
#> Cf Cs Ct
#> Cf 1.00 0.71 0.62
#> Cs 0.71 1.00 0.59
#> Ct 0.62 0.59 1.00
#>
#>
#> $est$tests$RSES
#> $est$tests$RSES$cds
#> factor subfactor item cd mean_cd aggregate_cd
#> 1 RSES Ns 2 0.24718807 0.1719081 0.1706512
#> 2 RSES Ns 5 0.03552244 0.1719081 0.1706512
#> 3 RSES Ns 6 0.27899664 0.1719081 0.1706512
#> 4 RSES Ns 8 0.18665548 0.1719081 0.1706512
#> 5 RSES Ns 9 0.11117763 0.1719081 0.1706512
#> 6 RSES Ps 1 0.14370647 0.2874100 0.2521100
#> 7 RSES Ps 3 0.39970201 0.2874100 0.2521100
#> 8 RSES Ps 4 0.43400090 0.2874100 0.2521100
#> 9 RSES Ps 7 0.34454922 0.2874100 0.2521100
#> 10 RSES Ps 10 0.11509134 0.2874100 0.2521100
#>
#> $est$tests$RSES$cors
#> Ns Ps
#> Ns 1.00 0.69
#> Ps 0.69 1.00
#>
#>
#>
#>
#> $est_raw
#> $est_raw$global
#> $est_raw$global$fls
#> factor subfactor item factor_loading subfactor_loading
#> 1 Self-Confidence DSSEI DSSEI.1 0.5189 0.5694
#> 2 Self-Confidence DSSEI DSSEI.5 0.6055 0.6794
#> 3 Self-Confidence DSSEI DSSEI.9 0.6180 0.6615
#> 4 Self-Confidence DSSEI DSSEI.13 0.4074 0.4142
#> 5 Self-Confidence DSSEI DSSEI.17 0.4442 0.4584
#> 6 Self-Confidence DSSEI DSSEI.3 0.5203 0.5554
#> 7 Self-Confidence DSSEI DSSEI.7 0.2479 0.2165
#> 8 Self-Confidence DSSEI DSSEI.11 0.5290 0.5675
#> 9 Self-Confidence DSSEI DSSEI.15 0.5540 0.5649
#> 10 Self-Confidence DSSEI DSSEI.19 0.5144 0.4752
#> 11 Self-Confidence DSSEI DSSEI.16 0.3958 0.4430
#> 12 Self-Confidence DSSEI DSSEI.4 0.5671 0.6517
#> 13 Self-Confidence DSSEI DSSEI.12 0.5559 0.6421
#> 14 Self-Confidence DSSEI DSSEI.8 0.4591 0.5450
#> 15 Self-Confidence DSSEI DSSEI.20 0.4927 0.5266
#> 16 Self-Confidence DSSEI DSSEI.2 0.3713 0.3020
#> 17 Self-Confidence DSSEI DSSEI.6 0.5941 0.6067
#> 18 Self-Confidence DSSEI DSSEI.10 0.4903 0.5178
#> 19 Self-Confidence DSSEI DSSEI.14 0.5998 0.5878
#> 20 Self-Confidence DSSEI DSSEI.18 0.6616 0.6572
#> 21 Self-Confidence SMTQ SMTQ.11 0.4182 0.4486
#> 22 Self-Confidence SMTQ SMTQ.13 0.2504 0.3282
#> 23 Self-Confidence SMTQ SMTQ.14 0.4094 0.4738
#> 24 Self-Confidence SMTQ SMTQ.1 0.3977 0.4567
#> 25 Self-Confidence SMTQ SMTQ.5 0.5177 0.5986
#> 26 Self-Confidence SMTQ SMTQ.6 0.4603 0.5416
#> 27 Self-Confidence SMTQ SMTQ.3 0.3271 0.3602
#> 28 Self-Confidence SMTQ SMTQ.10 0.2610 0.2955
#> 29 Self-Confidence SMTQ SMTQ.12 0.3614 0.3648
#> 30 Self-Confidence SMTQ SMTQ.8 0.4226 0.4814
#> 31 Self-Confidence SMTQ SMTQ.7 0.2076 0.2593
#> 32 Self-Confidence SMTQ SMTQ.2 0.3375 0.4053
#> 33 Self-Confidence SMTQ SMTQ.4 0.5509 0.6100
#> 34 Self-Confidence SMTQ SMTQ.9 0.3495 0.4121
#> 35 Self-Confidence RSES RSES.1 0.5482 0.6005
#> 36 Self-Confidence RSES RSES.3 0.4627 0.4932
#> 37 Self-Confidence RSES RSES.4 0.4185 0.4476
#> 38 Self-Confidence RSES RSES.7 0.4185 0.5033
#> 39 Self-Confidence RSES RSES.10 0.5319 0.6431
#> 40 Self-Confidence RSES RSES.2 0.4548 0.5806
#> 41 Self-Confidence RSES RSES.5 0.4773 0.5907
#> 42 Self-Confidence RSES RSES.6 0.4604 0.6179
#> 43 Self-Confidence RSES RSES.8 0.4657 0.5899
#> 44 Self-Confidence RSES RSES.9 0.4986 0.6559
#>
#> $est_raw$global$cors
#> DSSEI SMTQ RSES
#> DSSEI 1.00 0.73 0.62
#> SMTQ 0.73 1.00 0.75
#> RSES 0.62 0.75 1.00
#>
#>
#> $est_raw$tests
#> $est_raw$tests$DSSEI
#> $est_raw$tests$DSSEI$fls
#> factor subfactor item factor_loading subfactor_loading
#> 1 DSSEI Ab 2 0.3020 0.3347
#> 2 DSSEI Ab 6 0.6067 0.6537
#> 3 DSSEI Ab 10 0.5178 0.6078
#> 4 DSSEI Ab 14 0.5878 0.6840
#> 5 DSSEI Ab 18 0.6572 0.7350
#> 6 DSSEI Pb 16 0.4430 0.6861
#> 7 DSSEI Pb 4 0.6517 0.8746
#> 8 DSSEI Pb 12 0.6421 0.7982
#> 9 DSSEI Pb 8 0.5450 0.7521
#> 10 DSSEI Pb 20 0.5266 0.6794
#> 11 DSSEI Ph 3 0.5554 0.7947
#> 12 DSSEI Ph 7 0.2165 0.3737
#> 13 DSSEI Ph 11 0.5675 0.8190
#> 14 DSSEI Ph 15 0.5649 0.7099
#> 15 DSSEI Ph 19 0.4752 0.5785
#> 16 DSSEI So 1 0.5694 0.7293
#> 17 DSSEI So 5 0.6794 0.8284
#> 18 DSSEI So 9 0.6615 0.7892
#> 19 DSSEI So 13 0.4142 0.3101
#> 20 DSSEI So 17 0.4584 0.4384
#>
#> $est_raw$tests$DSSEI$cors
#> Ab Pb Ph So
#> Ab 1.00 0.49 0.66 0.76
#> Pb 0.49 1.00 0.37 0.54
#> Ph 0.66 0.37 1.00 0.53
#> So 0.76 0.54 0.53 1.00
#>
#>
#> $est_raw$tests$SMTQ
#> $est_raw$tests$SMTQ$fls
#> factor subfactor item factor_loading subfactor_loading
#> 1 SMTQ Cf 11 0.4486 0.4995
#> 2 SMTQ Cf 13 0.3282 0.3843
#> 3 SMTQ Cf 14 0.4738 0.5399
#> 4 SMTQ Cf 1 0.4567 0.4562
#> 5 SMTQ Cf 5 0.5986 0.6174
#> 6 SMTQ Cf 6 0.5416 0.6265
#> 7 SMTQ Cs 3 0.3602 0.4601
#> 8 SMTQ Cs 10 0.2955 0.3766
#> 9 SMTQ Cs 12 0.3648 0.4744
#> 10 SMTQ Cs 8 0.4814 0.5255
#> 11 SMTQ Ct 7 0.2593 0.3546
#> 12 SMTQ Ct 2 0.4053 0.5038
#> 13 SMTQ Ct 4 0.6100 0.7429
#> 14 SMTQ Ct 9 0.4121 0.4342
#>
#> $est_raw$tests$SMTQ$cors
#> Cf Cs Ct
#> Cf 1.00 0.71 0.62
#> Cs 0.71 1.00 0.59
#> Ct 0.62 0.59 1.00
#>
#>
#> $est_raw$tests$RSES
#> $est_raw$tests$RSES$fls
#> factor subfactor item factor_loading subfactor_loading
#> 1 RSES Ns 2 0.5806 0.6484
#> 2 RSES Ns 5 0.5907 0.6011
#> 3 RSES Ns 6 0.6179 0.6988
#> 4 RSES Ns 8 0.5899 0.6426
#> 5 RSES Ns 9 0.6559 0.6914
#> 6 RSES Ps 1 0.6005 0.6422
#> 7 RSES Ps 3 0.4932 0.5835
#> 8 RSES Ps 4 0.4476 0.5360
#> 9 RSES Ps 7 0.5033 0.5836
#> 10 RSES Ps 10 0.6431 0.6791
#>
#> $est_raw$tests$RSES$cors
#> Ns Ps
#> Ns 1.00 0.69
#> Ps 0.69 1.00
#>
#>
#>
#>
#> $xarrow
#> [1] NA
#>
#> attr(,"class")
#> [1] "IPV" "list"