Turn a psych::alpha() object into HTML tables.

knit_print.alpha(x, indent = "#####", ...)

Arguments

x

a psych alpha object

indent

add # to this to make the headings in the components lower-level. defaults to beginning at h5

...

ignored

Examples

example("alpha", "psych")
#> #> Attaching package: ‘psych’
#> The following object is masked _by_ ‘.GlobalEnv’: #> #> bfi
#> The following object is masked from ‘package:codebook’: #> #> bfi
#> The following object is masked from ‘package:testthat’: #> #> describe
#> #> alpha> set.seed(42) #keep the same starting values #> #> alpha> #four congeneric measures #> alpha> r4 <- sim.congeneric() #> #> alpha> alpha(r4) #> #> Reliability analysis #> Call: alpha(x = r4) #> #> raw_alpha std.alpha G6(smc) average_r S/N median_r #> 0.74 0.74 0.69 0.42 2.9 0.41 #> #> Reliability if an item is dropped: #> raw_alpha std.alpha G6(smc) average_r S/N var.r med.r #> V1 0.62 0.62 0.53 0.36 1.7 0.0036 0.35 #> V2 0.66 0.66 0.57 0.39 1.9 0.0081 0.40 #> V3 0.70 0.70 0.62 0.44 2.3 0.0120 0.40 #> V4 0.74 0.74 0.66 0.49 2.8 0.0049 0.48 #> #> Item statistics #> r r.cor r.drop #> V1 0.81 0.74 0.64 #> V2 0.78 0.67 0.57 #> V3 0.73 0.59 0.51 #> V4 0.68 0.50 0.43 #> #> alpha> #nine hierarchical measures -- should actually use omega #> alpha> r9 <- sim.hierarchical() #> #> alpha> alpha(r9) #> #> Reliability analysis #> Call: alpha(x = r9) #> #> raw_alpha std.alpha G6(smc) average_r S/N median_r #> 0.76 0.76 0.76 0.26 3.2 0.25 #> #> Reliability if an item is dropped: #> raw_alpha std.alpha G6(smc) average_r S/N var.r med.r #> V1 0.71 0.71 0.70 0.24 2.5 0.0067 0.22 #> V2 0.72 0.72 0.71 0.25 2.6 0.0085 0.23 #> V3 0.74 0.74 0.73 0.26 2.8 0.0101 0.25 #> V4 0.73 0.73 0.72 0.25 2.7 0.0106 0.23 #> V5 0.74 0.74 0.73 0.26 2.9 0.0112 0.24 #> V6 0.75 0.75 0.74 0.27 3.0 0.0113 0.25 #> V7 0.75 0.75 0.74 0.27 3.0 0.0129 0.25 #> V8 0.76 0.76 0.75 0.28 3.1 0.0118 0.26 #> V9 0.77 0.77 0.76 0.29 3.3 0.0099 0.28 #> #> Item statistics #> r r.cor r.drop #> V1 0.72 0.71 0.61 #> V2 0.67 0.63 0.54 #> V3 0.61 0.55 0.47 #> V4 0.65 0.59 0.51 #> V5 0.59 0.52 0.45 #> V6 0.53 0.43 0.38 #> V7 0.56 0.46 0.40 #> V8 0.50 0.39 0.34 #> V9 0.45 0.32 0.28 #> #> alpha> # examples of two independent factors that produce reasonable alphas #> alpha> #this is a case where alpha is a poor indicator of unidimensionality #> alpha> #> alpha> two.f <- sim.item(8) #> #> alpha> #specify which items to reverse key by name #> alpha> alpha(two.f,keys=c("V3","V4","V5","V6"))
#> Warning: NaNs produced
#> #> Reliability analysis #> Call: alpha(x = two.f, keys = c("V3", "V4", "V5", "V6")) #> #> raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r #> -0.58 -0.58 -0.17 -0.048 -0.37 0.11 -0.0042 0.29 -0.023 #> #> lower alpha upper 95% confidence boundaries #> -0.8 -0.58 -0.37 #> #> Reliability if an item is dropped: #> raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r #> V1 -0.54 -0.53 -0.147 -0.052 -0.35 0.106 0.053 -0.0285 #> V2 -0.52 -0.52 -0.149 -0.051 -0.34 0.105 0.051 -0.0188 #> V3 -0.37 -0.36 -0.041 -0.039 -0.27 0.094 0.052 -0.0098 #> V4 -0.40 -0.37 -0.049 -0.040 -0.27 0.097 0.052 -0.0188 #> V5 -0.49 -0.48 -0.119 -0.049 -0.32 0.103 0.052 -0.0271 #> V6 -0.56 -0.56 -0.172 -0.054 -0.36 0.107 0.052 -0.0188 #> V7 -0.39 -0.40 -0.083 -0.043 -0.29 0.097 0.049 -0.0271 #> V8 -0.57 -0.57 -0.177 -0.055 -0.36 0.109 0.053 -0.0285 #> #> Item statistics #> n raw.r std.r r.cor r.drop mean sd #> V1 500 0.33 0.33 NaN -0.112 0.01170 1.01 #> V2 500 0.32 0.32 NaN -0.123 -0.00183 1.00 #> V3 500 0.24 0.21 NaN -0.219 -0.04114 1.05 #> V4 500 0.22 0.22 NaN -0.204 -0.04698 0.99 #> V5 500 0.30 0.30 NaN -0.144 0.00021 1.01 #> V6 500 0.34 0.34 NaN -0.100 -0.00965 1.00 #> V7 500 0.23 0.24 NaN -0.205 0.02217 1.00 #> V8 500 0.33 0.35 NaN -0.091 0.03198 0.96 #> #> alpha> #by location #> alpha> alpha(two.f,keys=c(3,4,5,6))
#> Warning: NaNs produced
#> #> Reliability analysis #> Call: alpha(x = two.f, keys = c(3, 4, 5, 6)) #> #> raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r #> -0.58 -0.58 -0.17 -0.048 -0.37 0.11 -0.0042 0.29 -0.023 #> #> lower alpha upper 95% confidence boundaries #> -0.8 -0.58 -0.37 #> #> Reliability if an item is dropped: #> raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r #> V1 -0.54 -0.53 -0.147 -0.052 -0.35 0.106 0.053 -0.0285 #> V2 -0.52 -0.52 -0.149 -0.051 -0.34 0.105 0.051 -0.0188 #> V3 -0.37 -0.36 -0.041 -0.039 -0.27 0.094 0.052 -0.0098 #> V4 -0.40 -0.37 -0.049 -0.040 -0.27 0.097 0.052 -0.0188 #> V5 -0.49 -0.48 -0.119 -0.049 -0.32 0.103 0.052 -0.0271 #> V6 -0.56 -0.56 -0.172 -0.054 -0.36 0.107 0.052 -0.0188 #> V7 -0.39 -0.40 -0.083 -0.043 -0.29 0.097 0.049 -0.0271 #> V8 -0.57 -0.57 -0.177 -0.055 -0.36 0.109 0.053 -0.0285 #> #> Item statistics #> n raw.r std.r r.cor r.drop mean sd #> V1 500 0.33 0.33 NaN -0.112 0.01170 1.01 #> V2 500 0.32 0.32 NaN -0.123 -0.00183 1.00 #> V3 500 0.24 0.21 NaN -0.219 -0.04114 1.05 #> V4 500 0.22 0.22 NaN -0.204 -0.04698 0.99 #> V5 500 0.30 0.30 NaN -0.144 0.00021 1.01 #> V6 500 0.34 0.34 NaN -0.100 -0.00965 1.00 #> V7 500 0.23 0.24 NaN -0.205 0.02217 1.00 #> V8 500 0.33 0.35 NaN -0.091 0.03198 0.96 #> #> alpha> #automatic reversal base upon first component #> alpha> alpha(two.f,check.keys=TRUE) #note that the median is much less than the average R
#> Warning: Some items were negatively correlated with total scale and were automatically reversed. #> This is indicated by a negative sign for the variable name.
#> #> Reliability analysis #> Call: alpha(x = two.f, check.keys = TRUE) #> #> raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r #> 0.58 0.58 0.62 0.15 1.4 0.029 0.072 0.51 0.051 #> #> lower alpha upper 95% confidence boundaries #> 0.53 0.58 0.64 #> #> Reliability if an item is dropped: #> raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r #> V1 0.55 0.55 0.58 0.15 1.2 0.031 0.032 0.056 #> V2 0.53 0.53 0.57 0.14 1.1 0.033 0.034 0.029 #> V3- 0.55 0.55 0.58 0.15 1.2 0.031 0.031 0.056 #> V4- 0.55 0.54 0.58 0.15 1.2 0.032 0.032 0.056 #> V5- 0.56 0.56 0.59 0.15 1.3 0.031 0.030 0.056 #> V6- 0.56 0.56 0.59 0.15 1.3 0.031 0.030 0.056 #> V7 0.53 0.53 0.56 0.14 1.1 0.033 0.031 0.041 #> V8 0.56 0.57 0.59 0.16 1.3 0.030 0.030 0.047 #> #> Item statistics #> n raw.r std.r r.cor r.drop mean sd #> V1 500 0.50 0.50 0.38 0.28 0.0117 1.01 #> V2 500 0.55 0.55 0.46 0.34 -0.0018 1.00 #> V3- 500 0.50 0.50 0.39 0.27 0.1443 1.05 #> V4- 500 0.51 0.51 0.41 0.30 0.1502 0.99 #> V5- 500 0.48 0.48 0.36 0.26 0.1030 1.01 #> V6- 500 0.48 0.48 0.36 0.26 0.1128 1.00 #> V7 500 0.56 0.56 0.48 0.35 0.0222 1.00 #> V8 500 0.45 0.46 0.33 0.23 0.0320 0.96 #> #> alpha> #this suggests (correctly) that the 1 factor model is probably wrong #> alpha> #an example with discrete item responses -- show the frequencies #> alpha> items <- sim.congeneric(N=500,short=FALSE,low=-2,high=2, #> alpha+ categorical=TRUE) #500 responses to 4 discrete items with 5 categories #> #> alpha> a4 <- alpha(items$observed) #item response analysis of congeneric measures #> #> alpha> a4 #> #> Reliability analysis #> Call: alpha(x = items$observed) #> #> raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r #> 0.73 0.73 0.68 0.4 2.7 0.02 -0.013 0.76 0.4 #> #> lower alpha upper 95% confidence boundaries #> 0.69 0.73 0.77 #> #> Reliability if an item is dropped: #> raw_alpha std.alpha G6(smc) average_r S/N alpha se var.r med.r #> V1 0.61 0.61 0.52 0.34 1.6 0.031 0.0063 0.32 #> V2 0.64 0.64 0.55 0.37 1.8 0.028 0.0097 0.37 #> V3 0.68 0.68 0.60 0.41 2.1 0.025 0.0134 0.37 #> V4 0.73 0.73 0.65 0.48 2.8 0.021 0.0036 0.47 #> #> Item statistics #> n raw.r std.r r.cor r.drop mean sd #> V1 500 0.80 0.80 0.73 0.62 0.050 1.00 #> V2 500 0.77 0.77 0.67 0.57 -0.022 1.03 #> V3 500 0.72 0.73 0.58 0.50 -0.028 0.99 #> V4 500 0.67 0.66 0.46 0.40 -0.050 1.05 #> #> Non missing response frequency for each item #> -2 -1 0 1 2 miss #> V1 0.06 0.24 0.38 0.25 0.07 0 #> V2 0.07 0.26 0.35 0.25 0.07 0 #> V3 0.05 0.27 0.38 0.22 0.07 0 #> V4 0.10 0.22 0.39 0.22 0.07 0 #> #> alpha> #summary just gives Alpha #> alpha> summary(a4) #> #> Reliability analysis #> raw_alpha std.alpha G6(smc) average_r S/N ase mean sd median_r #> 0.73 0.73 0.68 0.4 2.7 0.02 -0.013 0.76 0.4
knitr::knit_print(a4)
#> #> #> #> #> ##### Reliability #> #> ##### 95% Confidence Interval #> #> ```r #> if (!is.null(x$total$ase)) { #> pander::pander(data.frame(lower = x$total$raw_alpha - 1.96 * x$total$ase, #> estimate = x$total$raw_alpha, #> upper = x$total$raw_alpha + 1.96 * #> x$total$ase)) #> } #> ``` #> #> #> --------------------------- #> lower estimate upper #> ------- ---------- -------- #> 0.688 0.7272 0.7664 #> --------------------------- #> #> #> ```r #> pander::pander(x$total) #> ``` #> #> #> ------------------------------------------------------------------------- #> raw_alpha std.alpha G6(smc) average_r S/N ase mean #> ----------- ----------- --------- ----------- ------- --------- --------- #> 0.7272 0.7285 0.6795 0.4015 2.684 0.01999 -0.0125 #> ------------------------------------------------------------------------- #> #> Table: Table continues below #> #> #> ------------------- #> sd median_r #> -------- ---------- #> 0.7556 0.4004 #> ------------------- #> #> ##### Reliability if an item is dropped: #> #> #> ```r #> rownames(x$alpha.drop) <- recursive_escape(rownames(x$alpha.drop)) #> pander::pander(x$alpha.drop) #> ``` #> #> #> ------------------------------------------------------------------------- #> &nbsp; raw_alpha std.alpha G6(smc) average_r S/N alpha se #> -------- ----------- ----------- --------- ----------- ------- ---------- #> **V1** 0.6067 0.6079 0.5158 0.3407 1.55 0.03056 #> #> **V2** 0.6368 0.6386 0.5532 0.3707 1.767 0.0283 #> #> **V3** 0.6785 0.6802 0.6022 0.4148 2.127 0.02514 #> #> **V4** 0.7348 0.7346 0.6532 0.4799 2.768 0.02055 #> ------------------------------------------------------------------------- #> #> Table: Table continues below #> #> #> ---------------------------- #> &nbsp; var.r med.r #> -------- ---------- -------- #> **V1** 0.006293 0.3248 #> #> **V2** 0.009712 0.3741 #> #> **V3** 0.01342 0.3741 #> #> **V4** 0.003643 0.4675 #> ---------------------------- #> #> ##### Item statistics #> #> #> ```r #> rownames(x$item.stats) <- recursive_escape(rownames(x$item.stats)) #> pander::pander(x$item.stats) #> ``` #> #> #> -------------------------------------------------------------------- #> &nbsp; n raw.r std.r r.cor r.drop mean sd #> -------- ----- -------- -------- -------- -------- -------- -------- #> **V1** 500 0.8014 0.8039 0.7276 0.6169 0.05 1.005 #> #> **V2** 500 0.7746 0.7735 0.6717 0.5658 -0.022 1.029 #> #> **V3** 500 0.722 0.729 0.5844 0.4957 -0.028 0.9885 #> #> **V4** 500 0.6714 0.6632 0.4641 0.4001 -0.05 1.052 #> -------------------------------------------------------------------- #> #> ##### Non missing response frequency for each item #> #> #> ```r #> rownames(x$response.freq) <- recursive_escape(rownames(x$response.freq)) #> pander::pander(x$response.freq) #> ``` #> #> #> ------------------------------------------------------- #> &nbsp; -2 -1 0 1 2 miss #> -------- ------- ------- ------- ------- ------- ------ #> **V1** 0.056 0.238 0.38 0.252 0.074 0 #> #> **V2** 0.07 0.264 0.35 0.25 0.066 0 #> #> **V3** 0.054 0.274 0.384 0.222 0.066 0 #> #> **V4** 0.096 0.22 0.392 0.222 0.07 0 #> -------------------------------------------------------