1 Preparing Data

1.1 Load Libraries

## Necessary Libraries loaded.

1.2 Load Data for Organisation with 26 Ratees and 287 Raters

## Stacked data with 78 Raters including IWB loaded.

1.3 Unstack and Clean Data

## Data unstacked and prepared for Analysis. Blank cells have been filled with Column Mean.

1.4 Eliminate Items

# Making New Data Set 
ReduceBy <- c("SN06", "SN19", "SN29")
ItemsToCut <- paste(ReduceBy, collapse = ", ")
cat("Dataset reduced by items", ItemsToCut, "due to low factor loading or cross loading. \nAll behaviours stay represented.")
## Dataset reduced by items SN06, SN19, SN29 due to low factor loading or cross loading. 
## All behaviours stay represented.
# Keep full data set
dfValFull   <- dfVal
  
# Reduce data sets
dfUnstack   <- select(dfUnstack,   -c(all_of(ReduceBy)))
dfVal       <- select(dfVal,       -c(all_of(ReduceBy)))
dfValNoIWB  <- select(dfValNoIWB,  -c(all_of(ReduceBy)))

# Delete support variables
rm(ItemsToCut, ReduceBy)

# Write
setwd("~/AB PRIVATE/01 Amy/AB Amy PhD/Part 3/Data/Study3")
write.csv(dfUnstack, file = paste(today, "UnStackedData3reduced.csv"))

1.5 Make Factor and Behaviour Variables

## Behaviour and Factor Data generated out of Item Means.

2 Studying Data

2.1 Displaying Descriptive Stats

Kurtosis and Skewness are used as indication of presence of normality in the data. If the data are normal Kurtosis and Skewness are within -2 and +2. The closer the 0 the better.

# Loading necessary packages
if(! "vtable" %in% installed.packages()) { install.packages("vtable", dependencies = TRUE) }
library(vtable)
if(! "moments" %in% installed.packages()) { install.packages("moments", dependencies = TRUE) }
library(moments)

ST <- as.data.frame(sumtable(dfVal[c(01:31)], out = 'return', title='Summary Statistics by Item', digits = 3, fixed.digits = TRUE,
   summ = list(
     c('notNA(x)','mean(x)','sd(x)','min(x)', 'pctile(x)[25]', 'median(x)', 'pctile(x)[75]', 'max(x)', 'kurtosis(x)', 'skewness(x)')
   ),
   summ.names = list(
     c('N','Mean','SD','Min', '25%', 'Median', '75%', 'Max', 'Kurtosis', 'Skewness')
   )
))

formattable(ST, caption = "Summary Statistics by Item - ILS", align = c("l", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c"), list(
  Mean = color_tile("pink", "green"),
  Cosigned = formatter("span",
       style = x ~ style(
       "border-radius" = "4px",
       "padding-right" = "4px",
       "background-color" = sapply(x,bg.picker)),
       x ~ sprintf("%.2f (rank: %02d)", x, rank(-x)))
))
Summary Statistics by Item - ILS
Variable N Mean SD Min 25% Median 75% Max Kurtosis Skewness
SN01 76 6.054 1.057 2 6.000 6 7.000 7 5.902 -1.610
SN02 76 5.724 1.173 2 5.000 6 7.000 7 4.069 -1.047
SN03 76 5.849 1.041 2 5.000 6 7.000 7 4.214 -1.045
SN04 76 5.893 1.173 2 5.670 6 7.000 7 5.701 -1.539
SN05 76 5.986 1.064 2 6.000 6 7.000 7 6.490 -1.641
SN07 76 5.901 1.121 2 5.901 6 7.000 7 4.329 -1.228
SN08 76 5.806 1.041 2 5.000 6 6.250 7 4.846 -1.167
SN09 76 5.877 1.006 2 5.000 6 7.000 7 6.841 -1.487
SN10 76 5.740 1.096 2 5.000 6 6.000 7 4.312 -1.116
SN11 76 5.736 1.020 2 5.000 6 6.000 7 4.935 -1.189
SN12 76 6.013 1.039 2 6.000 6 7.000 7 5.320 -1.390
SN13 76 6.040 1.012 2 6.000 6 7.000 7 6.487 -1.632
SN14 76 6.408 0.751 4 6.000 7 7.000 7 4.092 -1.201
SN15 76 6.013 0.973 2 6.000 6 7.000 7 5.482 -1.251
SN16 76 6.184 0.934 2 6.000 6 7.000 7 6.896 -1.559
SN17 76 6.133 1.062 2 6.000 6 7.000 7 5.379 -1.478
SN18 76 5.867 1.215 2 5.000 6 7.000 7 4.380 -1.270
SN20 76 5.961 1.101 2 6.000 6 7.000 7 4.726 -1.310
SN21 76 5.946 0.992 2 6.000 6 7.000 7 5.888 -1.458
SN22 76 5.886 1.027 2 5.886 6 6.250 7 5.632 -1.472
SN23 76 6.184 0.976 2 6.000 6 7.000 7 6.383 -1.588
SN24 76 5.889 1.090 2 5.889 6 7.000 7 4.643 -1.266
SN25 76 6.027 1.107 1 6.000 6 7.000 7 7.578 -1.774
SN26 76 6.108 1.053 2 6.000 6 7.000 7 6.007 -1.599
SN27 76 5.920 1.105 2 6.000 6 7.000 7 5.462 -1.573
SN28 76 5.959 1.064 2 5.000 6 7.000 7 4.513 -1.122
SN30 76 6.243 0.921 2 6.000 6 7.000 7 7.994 -1.847
SN31 76 6.147 1.029 2 6.000 6 7.000 7 6.129 -1.629
SN32 76 5.931 1.181 2 5.931 6 7.000 7 5.105 -1.475
SN33 76 6.054 1.106 2 6.000 6 7.000 7 5.111 -1.476
SN34 76 6.027 1.019 2 6.000 6 7.000 7 5.624 -1.422
ST <- as.data.frame(sumtable(dfVal[c(32:40)], out = 'return', title='Summary Statistics by Item', digits = 3, fixed.digits = TRUE,
   summ = list(
     c('notNA(x)','mean(x)','sd(x)','min(x)', 'pctile(x)[25]', 'median(x)', 'pctile(x)[75]', 'max(x)', 'kurtosis(x)', 'skewness(x)')
   ),
   summ.names = list(
     c('N','Mean','SD','Min', '25%', 'Median', '75%', 'Max', 'Kurtosis', 'Skewness')
   )
))

formattable(ST, caption = "Summary Statistics by Item - IWB", align = c("l", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c"), list(
  Mean = color_tile("pink", "green"),
  Cosigned = formatter("span",
       style = x ~ style(
       "border-radius" = "4px",
       "padding-right" = "4px",
       "background-color" = sapply(x,bg.picker)),
       x ~ sprintf("%.2f (rank: %02d)", x, rank(-x)))
))
Summary Statistics by Item - IWB
Variable N Mean SD Min 25% Median 75% Max Kurtosis Skewness
IWB01 76 5.421 1.086 2 5 6 6.000 7 4.224 -0.958
IWB02 76 5.421 1.099 2 5 5 6.000 7 3.925 -0.709
IWB03 76 5.513 1.113 3 5 6 6.000 7 2.314 -0.296
IWB04 76 4.592 0.955 2 4 5 5.000 6 2.565 -0.312
IWB05 76 4.855 1.029 2 4 5 6.000 7 3.309 -0.521
IWB06 76 4.303 1.132 1 4 4 5.000 6 2.967 -0.447
IWB07 76 4.816 1.092 2 4 5 6.000 7 2.645 -0.496
IWB08 76 4.763 1.094 1 4 5 5.250 7 4.189 -0.689
IWB09 76 4.697 1.108 1 4 5 5.000 7 3.852 -0.803
ST <- as.data.frame(sumtable(dfBeh[c(01:11)], out = 'return', title='Summary Statistics by Behaviour', digits = 3, fixed.digits = TRUE,
   summ = list(
     c('notNA(x)','mean(x)','sd(x)','min(x)', 'pctile(x)[25]', 'median(x)', 'pctile(x)[75]', 'max(x)', 'kurtosis(x)', 'skewness(x)')
   ),
   summ.names = list(
     c('N','Mean','SD','Min', '25%', 'Median', '75%', 'Max', 'Kurtosis', 'Skewness')
   )
))

formattable(ST, caption = "Summary Statistics by Behaviour - ILS", align = c("l", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c"), list(
  Mean = color_tile("pink", "green"),
  Cosigned = formatter("span",
       style = x ~ style(
       "border-radius" = "4px",
       "padding-right" = "4px",
       "background-color" = sapply(x,bg.picker)),
       x ~ sprintf("%.2f (rank: %02d)", x, rank(-x)))
))
Summary Statistics by Behaviour - ILS
Variable N Mean SD Min 25% Median 75% Max Kurtosis Skewness
B01 76 5.889 1.057 2.000 5.500 6.000 6.500 7 5.149 -1.417
B02 76 5.910 1.001 2.000 5.658 6.000 6.667 7 5.737 -1.427
B03 76 5.861 0.973 2.000 5.594 6.000 6.417 7 6.096 -1.458
B04 76 5.830 0.973 2.000 5.583 6.000 6.333 7 5.866 -1.475
B05 76 6.202 0.768 3.667 6.000 6.333 7.000 7 4.290 -1.130
B06 76 6.013 1.007 2.000 5.667 6.000 7.000 7 5.549 -1.436
B07 76 5.994 0.929 2.000 5.750 6.125 6.562 7 6.790 -1.698
B08 76 6.008 0.983 1.667 5.667 6.333 6.667 7 7.183 -1.742
B09 76 5.940 1.036 2.000 5.500 6.000 7.000 7 5.216 -1.360
B10 76 6.195 0.937 2.000 6.000 6.122 7.000 7 7.772 -1.886
B11 76 6.004 1.007 2.000 5.667 6.000 7.000 7 5.905 -1.537
ST <- as.data.frame(sumtable(dfFac, out = 'return', title='Summary Statistics by Factor', digits = 3, fixed.digits = TRUE,
   summ = list(
     c('notNA(x)','mean(x)','sd(x)','min(x)', 'pctile(x)[25]', 'median(x)', 'pctile(x)[75]', 'max(x)', 'kurtosis(x)', 'skewness(x)')
   ),
   summ.names = list(
     c('N','Mean','SD','Min', '25%', 'Median', '75%', 'Max', 'Kurtosis', 'Skewness')
   )
))

formattable(ST, caption = "Summary Statistics by Factor - ILS and IWB", align = c("l", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c"), list(
  Mean = color_tile("pink", "green"),
  Cosigned = formatter("span",
       style = x ~ style(
       "border-radius" = "4px",
       "padding-right" = "4px",
       "background-color" = sapply(x,bg.picker)),
       x ~ sprintf("%.2f (rank: %02d)", x, rank(-x)))
))
Summary Statistics by Factor - ILS and IWB
Variable N Mean SD Min 25% Median 75% Max Kurtosis Skewness
Head 76 5.871 0.954 2.000 5.611 6.000 6.477 7.000 6.364 -1.541
Heart 76 6.108 0.841 2.833 5.792 6.167 6.833 7.000 5.610 -1.405
Hand 76 6.020 0.935 1.929 5.768 6.078 6.714 7.000 7.280 -1.784
IWB 76 4.931 0.864 1.889 4.556 5.000 5.667 6.222 4.256 -1.048
ST <- as.data.frame(sumtable(dfFac[c(01:03)], out = 'return', title='Summary Statistics by Factor', digits = 3, fixed.digits = TRUE,
   summ = list(
     c('notNA(x)','mean(x)','sd(x)','min(x)', 'pctile(x)[25]', 'median(x)', 'pctile(x)[75]', 'max(x)', 'kurtosis(x)', 'skewness(x)')
   ),
   summ.names = list(
     c('N','Mean','SD','Min', '25%', 'Median', '75%', 'Max', 'Kurtosis', 'Skewness')
   )
))

formattable(ST, caption = "Summary Statistics by Factor - ILS", align = c("l", "c", "c", "c", "c", "c", "c", "c", "c", "c", "c"), list(
  Mean = color_tile("pink", "green"),
  Cosigned = formatter("span",
       style = x ~ style(
       "border-radius" = "4px",
       "padding-right" = "4px",
       "background-color" = sapply(x,bg.picker)),
       x ~ sprintf("%.2f (rank: %02d)", x, rank(-x)))
))
Summary Statistics by Factor - ILS
Variable N Mean SD Min 25% Median 75% Max Kurtosis Skewness
Head 76 5.871 0.954 2.000 5.611 6.000 6.477 7 6.364 -1.541
Heart 76 6.108 0.841 2.833 5.792 6.167 6.833 7 5.610 -1.405
Hand 76 6.020 0.935 1.929 5.768 6.078 6.714 7 7.280 -1.784

2.2 Calculate Cronbach’s Alpha

Cronbach’s Alpha is an indicator for scale reliability. Raw alpha is sensitive to differences in the item variances. Standardized alpha is based upon the correlations rather than the covariances. Standardized alpha is based on the assumption that all of the items have equal variances, which is often false in practice. We use raw alpha to evaluate the scales. A level of 0.7 and above is acceptable, whereas 0.8 should be achieved in research. When making important data driven decisions, 0.9 marks a minimum. If Guttman’s Lambda 6 (G6) is higher than Alpha, factor shows unequal item loadings.

# Loading necessary packages
if(! "psych" %in% installed.packages()) { install.packages("psych", dependencies = TRUE) }
library(psych)

# Cronbach's Alpha
cAlpha  <- psych::alpha(x = dfValFull[c(1,2)])
alphaDT <- data.table(variable = "Envision Change", id = "B01", cAlpha$total)
cAlpha  <- psych::alpha(x = dfValFull[c(3,4,5)])
alphaDT <- rbind(alphaDT, data.table(variable = "Promote Change", id = "B02", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(7,8,9)])
alphaDT <- rbind(alphaDT, data.table(variable = "Manage Change", id = "B03", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(10,11,12)])
alphaDT <- rbind(alphaDT, data.table(variable = "Drive Innovation", id = "B04", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(14,15,16)])
alphaDT <- rbind(alphaDT, data.table(variable = "Build Relationship", id = "B05", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(13,17,18)])
alphaDT <- rbind(alphaDT, data.table(variable = "Support Others", id = "B06", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(20,21,22,23)])
alphaDT <- rbind(alphaDT, data.table(variable = "Make Decision", id = "B07", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(24,25,26)])
alphaDT <- rbind(alphaDT, data.table(variable = "Make Things Happen", id = "B08", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(27,28)])
alphaDT <- rbind(alphaDT, data.table(variable = "Solve Problems Creatively", id = "B09", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(30,31)])
alphaDT <- rbind(alphaDT, data.table(variable = "Take Responsibility", id = "B10", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(32,33,34)])
alphaDT <- rbind(alphaDT, data.table(variable = "Demonstrate Team Leadership", id = "B11", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(01:05,07:12)])
alphaDT <- rbind(alphaDT, data.table(variable = "Head", id = "Hed", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(13:18)])
alphaDT <- rbind(alphaDT, data.table(variable = "Heart", id = "Hrt", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(20:28,30:34)])
alphaDT <- rbind(alphaDT, data.table(variable = "Hand", id = "Hnd", cAlpha$total))
cAlpha  <- psych::alpha(x = dfVal)
alphaDT <- rbind(alphaDT, data.table(variable = "ILS", id = "ILS", cAlpha$total))
cAlpha  <- psych::alpha(x = dfValFull[c(35:43)])
alphaDT <- rbind(alphaDT, data.table(variable = "Innovative Work Behaviour", id = "IWB", cAlpha$total))

alphaDT$LCL       <- alphaDT$raw_alpha - 2 * alphaDT$ase
alphaDT$UCL       <- alphaDT$raw_alpha + 2 * alphaDT$ase
# alphaDT$StdAlpha   <- alphaDT$std.alpha

# Remove columns
alphaDT <- alphaDT[,-c("S/N", "std.alpha", "average_r", "median_r", "ase")]

# Rename columns
setnames(alphaDT, "variable", "Variable")
setnames(alphaDT, "id", "ID")
setnames(alphaDT, "raw_alpha", "Raw Alpha")
setnames(alphaDT, "G6(smc)", "G6")
setnames(alphaDT, "mean", "Mean")
setnames(alphaDT, "sd", "SD")
# setnames(alphaDT, "StdAlpha", "Std Alpha")

options("digits" = 3) 

# Show Cronbach's alpha table
improvement_formatter <- formatter("span", font.weight = "bold")
alphaDT <- alphaDT  %>% mutate(across(`Raw Alpha`:UCL, ~ formattable::comma(., digits = 3)))
formattable(alphaDT, 
  align = c("l","c","c","c","c","c","c","c"),
  list(
    `Indicator Name` = formatter("span", style = ~ style(color = "grey",font.weight = "bold")), 
    `Raw Alpha`      = formattable::color_tile("pink","lightgreen"),
    `Improvement`    = improvement_formatter)
)
Variable ID Raw Alpha G6 Mean SD LCL UCL
Envision Change B01 0.885 0.798 5.889 1.057 0.833 0.937
Promote Change B02 0.902 0.864 5.910 1.001 0.863 0.941
Manage Change B03 0.909 0.872 5.861 0.973 0.874 0.945
Drive Innovation B04 0.916 0.882 5.830 0.973 0.882 0.949
Build Relationship B05 0.826 0.779 6.202 0.768 0.761 0.892
Support Others B06 0.903 0.875 6.013 1.007 0.865 0.942
Make Decision B07 0.928 0.914 5.994 0.929 0.901 0.955
Make Things Happen B08 0.892 0.846 6.008 0.983 0.849 0.935
Solve Problems Creatively B09 0.904 0.825 5.940 1.036 0.860 0.948
Take Responsibility B10 0.915 0.848 6.195 0.937 0.877 0.953
Demonstrate Team Leadership B11 0.899 0.872 6.004 1.007 0.858 0.940
Head Hed 0.972 0.975 5.871 0.954 0.963 0.982
Heart Hrt 0.916 0.916 6.108 0.841 0.889 0.944
Hand Hnd 0.979 0.984 6.020 0.935 0.971 0.986
ILS ILS 0.989 0.996 5.747 0.883 0.985 0.992
Innovative Work Behaviour IWB 0.930 0.930 4.931 0.864 0.906 0.954
# Write Cronbach's Alpha
setwd("~/AB PRIVATE/01 Amy/AB Amy PhD/Part 3/Data/Study3")
write.csv(alphaDT, file = paste(today, "CronbachAlpha.csv"))

3 Showing Graphs of Data

3.1 Plot Histograms of all Variables

# Setting working Directory
setwd("~/AB PRIVATE/01 Amy/AB Amy PhD/Part 3/Data/Study3")

# Prepare PDF
if (makePDF) {
  pdf(paste(today, "Hist.pdf"), width = 25, height = 16)
}
par(mar=c(7, 1, 7, 1))
par(oma=c(1, 1, 1, 1))
par(mfrow=c(2, 2), mai=c(2, 1, 2, 1))

hist(dfFac$Head, prob = T, xlim = c(1, 7), col = "lightblue", xlab= "", ylab="", cex.lab = 2.5, cex.axis = 2.5, cex.main = 3.0, main = "Histogram of Head", breaks = 10)

hist(dfFac$Heart, prob = T, xlim = c(1, 7), col = "#ffcc00", xlab= "", ylab="", cex.lab = 2.5, cex.axis = 2.5, cex.main = 3.0, main = "Histogram of Heart", breaks = 10)

hist(dfFac$Hand, prob = T, xlim = c(1, 7), col = "lightgreen", xlab= "", ylab="", cex.lab = 2.5, cex.axis = 2.5, cex.main = 3.0, main = "Histogram of Hand", breaks = 10)

hist(dfFac$IWB, prob = T, xlim = c(1, 7), col = "pink", xlab= "", ylab="", cex.lab = 2.5, cex.axis = 2.5, cex.main = 3.0, main = "Histogram of IWB", breaks = 10)

if (makePDF) {
  dev.off()
}

3.2 Show Error Plot of Items per Factor

Error plots give an idea of potential misfitting items (questions/statements) per factor (variable.)

# Setting working Directory
setwd("~/AB PRIVATE/01 Amy/AB Amy PhD/Part 3/Data/Study3")

# Prepare PDF
if (makePDF) {
  pdf(paste(today, "Error.pdf"), width = 25, height = 25)
}
par(mar=c(2, 1, 2, 1))
par(oma=c(1, 1, 1, 1))
par(mfrow=c(2, 2))
layout.matrix <- matrix(c(0, 2, 3, 1), nrow = 2, ncol = 2)

# Create mean scores and confidence intervals
error.dots(dfHead, eyes = TRUE, sort = FALSE, main = "Head - Mean Confidence Interval", xlim = c(1, 7), lcolor = "blue", cex = 1.5, cex.main = 1, pch = 19, color = "blue")

error.dots(dfHeart, eyes = TRUE, sort = FALSE, main = "Heart - Mean Confidence Interval", xlim = c(1, 7), lcolor = "darkgreen", cex = 1.5, cex.main = 1, pch = 19, color = "#CC6633")

error.dots(dfHand, eyes = TRUE, sort = FALSE, main = "Hand - Mean Confidence Interval", xlim = c(1, 7), lcolor = "magenta", cex = 1.5, cex.main = 1, pch = 19, color = "darkgreen")

error.dots(dfIWB, eyes = TRUE, sort = FALSE, main = "IWB - Mean Confidence Interval", xlim = c(1, 7), lcolor = "red", cex = 1.5, cex.main = 1, pch = 19, color = "red")

if (makePDF) {
  dev.off()
}

3.3 Show Item List

# Make Item Data Table
improvement_formatter <- formatter("span", font.weight = "bold")
formattable(dfItems[1:31,], caption = "List of Items at ILS",
  align = c("c","l","l", "c"),
  list(
    `Indicator Name` = formatter("span", style = ~ style(color = "grey",font.weight = "bold")), 
    `Mean` = formattable::color_tile("pink","lightgreen"),
    `Improvement` = improvement_formatter)
)
List of Items at ILS
Item Behavior Statement
SN01 Protected Protected
formattable(dfItems[32:40,], caption = "List of Items at IWB",
  align = c("c","l","l", "c"),  
  list(
    `Indicator Name` = formatter("span", style = ~ style(color = "grey",font.weight = "bold")), 
    `Mean` = formattable::color_tile("pink","lightgreen"),
    `Improvement` = improvement_formatter)
)
List of Items at IWB
Item Behavior Statement
IWB01 Protected Protected

3.4 Plot Correlation Matrix of Items

dfMatrix <- cor(dfVal)
corrplot.mixed(dfMatrix, lower = 'number', upper = 'pie', number.cex = 0.7, cl.cex = 1.0, tl.cex = 0.5)