Computes Cronbach's alpha and prints SPSS-style reliability output including a case processing summary, overall alpha, item statistics, and item-total statistics with alpha-if-item-deleted. Built from scratch with no external package dependencies beyond base R. Handles haven-labelled variables automatically. Detects potentially reverse-coded or misfit items.
Usage
jalpha(
data,
...,
subset = NULL,
variable.id = NULL,
value.id = NULL,
case.processing.detail = NULL,
digits = NULL,
print = NULL
)Arguments
- data
A data frame.
- ...
Unquoted variable names (scale items) within
data. Use colon notation (e.g.Item1:Item6) to select a range of consecutive columns.- subset
An optional unquoted logical expression (e.g.
Group == 1) to subset cases for this call only. Applied after jcomplete and jsubset. Does not affect other function calls. Written in R syntax and checked the wayjsubset()checks a filter:subset = NOT(Age < 40), for example, is refused with the correctedsubset = !(Age < 40)shown (seejsubsetfor a translation table).- variable.id
Character or NULL. Variable label display mode: one of
"both","names","labels","legend", or"legend.bottom"."names"shows variable names only;"both"shows"name: label";"labels"shows each item's label in the Item column of the Item Statistics and Item-Total Statistics tables (best for short labels; the returned tables and the reverse-coding diagnostic keep variable names);"legend"/"legend.bottom"keep names and print a label legend after the final table. NULL (default) defers tojoutput()'svariable.idsetting. Not a logical.- value.id
Not supported by
jalpha(). The function does not display value labels, so passing this argument is an error. It exists only to return a clear message rather than reportvalue.idas a variable that was not found. Leave at NULL (default).- case.processing.detail
Per-call override of the Case Processing Summary detail tier: one of
"none","totals", or"per_code".NULL(default) uses the activejoutput()level default. The Case Processing table itself prints only when a filter or listwise deletion excluded cases; otherwise a one-line N statement takes its place. See?joutput(case.processing).- digits
Integer or NULL. Number of decimal places for continuous statistics in the output tables (range 0-7;
digits = 0prints whole numbers with no trailing decimal point). Does not affect p-values, percentages, or integer quantities (counts, N, degrees of freedom), which keep their own fixed conventions. NULL (default) defers tojoutput()'sdigitssetting (default 3).Logical or NULL.
FALSEprints nothing – no table, no title, no note – and returns the result as every call does; errors and warnings still show.TRUEprints even underjoutput("silent").NULL(the default) prints unless the level is silent. For a script that keeps many results and wants no output: seejoutput.
Value
Invisibly returns a list of class jst_alpha containing:
alpha (Cronbach's alpha), n_items, n_used,
n_excluded, item_statistics, item_total_statistics,
and sample_info (pipeline and missing data counts).
item statistics data frame, and item-total statistics data frame.
Details
A red "Reliability Analysis" title is printed first, followed by the case processing summary, overall alpha, item statistics, and item-total statistics.
See also
jstats for the package overview,
workflow conventions, and complete function listing.
Examples
# With explicit data frame
jalpha(community, Environment1, Environment2, Environment3,
Environment4, Environment5)
#> Reliability Analysis
#>
#> Case Processing Excluded Remaining
#> Original -- 103
#> Auto-listwise 19 84
#> Analysis N -- 84
#>
#> Missing data From 103 %
#> Environment1
#> Missing 12 11.7
#> Environment3
#> Missing 12 11.7
#> --------------------------------------
#>
#> Reliability Statistics
#> Cronbach's Alpha N of Items
#> ---------------- ----------
#> 0.348 5
#>
#> Item Statistics
#> Item Mean SD N
#> ------------ ----- ----- --
#> Environment1 3.131 1.180 84
#> Environment2 2.869 1.180 84
#> Environment3 3.060 1.226 84
#> Environment4 3.333 1.186 84
#> Environment5 2.762 1.470 84
#>
#> Warning: The following item is negatively correlated with the rest of the
#> scale: Environment2.
#> It may need reverse-coding, or may not belong in the scale -- check the
#> item-total table and the item wording.
#> Item-Total Statistics
#> Item Corrected Item-Total r Alpha if Item Deleted
#> ------------ ---------------------- ---------------------
#> Environment1 0.510 -0.006
#> Environment2 -0.660 0.783
#> Environment3 0.539 -0.052
#> Environment4 0.447 0.056
#> Environment5 0.455 -0.030
#>
# The data frame may also be given by name
jalpha(data = community, Environment1, Environment2, Environment3,
Environment4, Environment5)
#> Reliability Analysis
#>
#> Case Processing Excluded Remaining
#> Original -- 103
#> Auto-listwise 19 84
#> Analysis N -- 84
#>
#> Missing data From 103 %
#> Environment1
#> Missing 12 11.7
#> Environment3
#> Missing 12 11.7
#> --------------------------------------
#>
#> Reliability Statistics
#> Cronbach's Alpha N of Items
#> ---------------- ----------
#> 0.348 5
#>
#> Item Statistics
#> Item Mean SD N
#> ------------ ----- ----- --
#> Environment1 3.131 1.180 84
#> Environment2 2.869 1.180 84
#> Environment3 3.060 1.226 84
#> Environment4 3.333 1.186 84
#> Environment5 2.762 1.470 84
#>
#> Warning: The following item is negatively correlated with the rest of the
#> scale: Environment2.
#> It may need reverse-coding, or may not belong in the scale -- check the
#> item-total table and the item wording.
#> Item-Total Statistics
#> Item Corrected Item-Total r Alpha if Item Deleted
#> ------------ ---------------------- ---------------------
#> Environment1 0.510 -0.006
#> Environment2 -0.660 0.783
#> Environment3 0.539 -0.052
#> Environment4 0.447 0.056
#> Environment5 0.455 -0.030
#>
# Using juse() default
juse(community)
#> Default data frame set to: community
jalpha(Environment1, Environment2, Environment3, Environment4,
Environment5)
#> Reliability Analysis
#> Using default data frame: community
#>
#> Case Processing Excluded Remaining
#> Original -- 103
#> Auto-listwise 19 84
#> Analysis N -- 84
#>
#> Missing data From 103 %
#> Environment1
#> Missing 12 11.7
#> Environment3
#> Missing 12 11.7
#> --------------------------------------
#>
#> Reliability Statistics
#> Cronbach's Alpha N of Items
#> ---------------- ----------
#> 0.348 5
#>
#> Item Statistics
#> Item Mean SD N
#> ------------ ----- ----- --
#> Environment1 3.131 1.180 84
#> Environment2 2.869 1.180 84
#> Environment3 3.060 1.226 84
#> Environment4 3.333 1.186 84
#> Environment5 2.762 1.470 84
#>
#> Warning: The following item is negatively correlated with the rest of the
#> scale: Environment2.
#> It may need reverse-coding, or may not belong in the scale -- check the
#> item-total table and the item wording.
#> Item-Total Statistics
#> Item Corrected Item-Total r Alpha if Item Deleted
#> ------------ ---------------------- ---------------------
#> Environment1 0.510 -0.006
#> Environment2 -0.660 0.783
#> Environment3 0.539 -0.052
#> Environment4 0.447 0.056
#> Environment5 0.455 -0.030
#>