## define parameters
k <- 4
lower <- 1
upper <- 5
## scale properties
n <- 64
mean <- 3.0
sd <- 0.85
## create scale
set.seed(42)
meanScale <- lfast(
n = n, mean = mean, sd = sd,
lowerbound = lower, upperbound = upper,
items = k
)
summatedScale <- meanScale * k
## create new items
newItems <- makeItemsScale(
scale = summatedScale,
lowerbound = lower, upperbound = upper,
items = k
)
### test new items
# str(newItems)
# alpha(data = newItems) |> round(2)
## very low variance usually gives higher Cronbach's Alpha
mydat_20 <- makeItemsScale(
scale = summatedScale,
lowerbound = lower, upperbound = upper,
items = k, alpha = 0.8, variance = 0.20
)
### test new data frame
# str(mydat_20)
# moments <- data.frame(
# means = apply(mydat_20, MARGIN = 2, FUN = mean) |> round(3),
# sds = apply(mydat_20, MARGIN = 2, FUN = sd) |> round(3)
# ) |> t()
# moments
# cor(mydat_20) |> round(2)
# alpha(data = mydat_20) |> round(2)
## default alpha (0.8) and higher variance (0.8)
mydat_80 <- makeItemsScale(
scale = summatedScale,
lowerbound = lower, upperbound = upper,
items = k, variance = 0.80
)
### test new dataframe
# str(mydat_80)
# moments <- data.frame(
# means = apply(mydat_80, MARGIN = 2, FUN = mean) |> round(3),
# sds = apply(mydat_80, MARGIN = 2, FUN = sd) |> round(3)
# ) |> t()
# moments
# cor(mydat_80) |> round(2)
# alpha(data = mydat_80) |> round(2)
Run the code above in your browser using DataLab