test_that("test_alpha", { scores_mat <- matrix(c( NaN, 1, 0, 0, 0, 0, 0, 0, NaN, 0, 0, 0, 2, 0, 0, 1, NaN, 0, 0, 0, 0, 0, 0, 0, NaN, 0, 0, 0, 1, 0, 0, 0, NaN, 0, 0, 0, 0, 0, 1, 2, NaN, 0, 0, 0, 0, 0, 0, 0, NaN, 1, 0, 0, 0, 0, 0, 1, NaN, 1, 0, 0, 0, 0, 0, 1, NaN, 0, 1, 0, 0, 0, 1, 0, NaN, 1, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 1, 1, 2, 0, 1, 0, 2, 0, 0, 0, 2, 1, 0, 0, 0, 0, 1, 1, 0, 2, 0, 1, 0, 0, 0, 0, 1, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 2, 1, 2, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ), nrow = 50, ncol = 4, byrow = TRUE) unknown_info = unknown_loc(scores_mat) unknown_value <- c(3, 3, 4, 4, 1, 4, 2, 0, 1, 0) generate_scores_mat_bernoulli(50, 10, 20, 2) # Assigning the values to variables in R n <- 10 A <- matrix(c( -0.0196, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, -0.0196, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, -0.0196, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, -0.0196, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, -0.0196, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, -0.0196, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, -0.0196, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, -0.0196, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, -0.0196, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, 0.0004, -0.0196 ), nrow = 10, byrow = TRUE) b <- c(0.00553469, -0.01528163, -0.01528163, -0.01528163, -0.01528163, -0.01528163, 0.00553469, 0.00553469, 0.00553469, 0.02635102) c <- -0.2378938775510202 x_max <- 4 # Call the qp_solver function in R result <- qp_solver(n, A, b, c, x_max) # Input Data alpha <- 0.5 n_person <- 50 # sigma_x_info A_mat_x <- matrix(c( # First row 0.04, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, # Second row -0.00081633, 0.04, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, # Third row -0.00081633, -0.00081633, 0.04, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, # Fourth row -0.00081633, -0.00081633, -0.00081633, 0.04, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, # Fifth row -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, # Sixth row -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04, -0.00081633, -0.00081633, -0.00081633, -0.00081633, # Seventh row -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04, -0.00081633, -0.00081633, -0.00081633, # Eighth row -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04, -0.00081633, -0.00081633, # Ninth row -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04, -0.00081633, # Tenth row -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 ), nrow = 10, byrow = TRUE) b_array_x <- rep(-0.01469388, 10) c_scaler_x <- 1.3861224489795916 sigma_x_info <- list(A_mat_x, b_array_x, c_scaler_x) # sigma_y_info A_mat_y <- A_mat_x # Same as A_mat_x in this case b_array_y <- c( -0.01795918, -0.05877551, -0.05877551, -0.05877551, -0.05877551, -0.05877551, -0.01795918, -0.01795918, -0.01795918, 0.02285714 ) c_scaler_y <- 2.2514285714285713 sigma_y_info <- list(A_mat_y, b_array_y, c_scaler_y) alpha_type <- 'min' score_max <- 4 num_try <- 1 # Run the examine_alpha_bound function result <- examine_alpha_bound( alpha = alpha, n_person = n_person, sigma_x_info = sigma_x_info, sigma_y_info = sigma_y_info, alpha_type = alpha_type, score_max = score_max, num_try = num_try ) # Define the parameters n_person <- 50 sigma_x_info <- list( matrix(c( 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 ), nrow = 10, byrow = TRUE), c(-0.01469388, -0.01469388, -0.01469388, -0.01469388, -0.01469388, -0.01469388, -0.01469388, -0.01469388, -0.01469388, -0.01469388), 1.3861224489795916 ) sigma_y_info <- list( matrix(c( 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 , -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, -0.00081633, 0.04 ), nrow = 10, byrow = TRUE), c(-0.01795918, -0.05877551, -0.05877551, -0.05877551, -0.05877551, -0.05877551, -0.01795918, -0.01795918, -0.01795918, 0.02285714), 2.2514285714285713 ) score_max <- 4 alpha_lb <- 0.0 alpha_ub <- 1.0 tol <- 0.001 num_try <- 1 result <- compute_alpha_min( n_person, sigma_x_info, sigma_y_info, score_max = score_max, alpha_lb = alpha_lb, alpha_ub = alpha_ub, tol = tol, num_try = num_try ) result <- compute_alpha_max( n_person, sigma_x_info, sigma_y_info, score_max = score_max, alpha_lb = alpha_lb, alpha_ub = alpha_ub, tol = tol, num_try = num_try ) score_max = 2 scores_mat_bernoulli = generate_scores_mat_bernoulli( 50, 10, 20, score_max ) result = cronbachs_alpha( scores_mat_bernoulli, score_max, enum_all = FALSE ) scores_df <- missalpha::sample scores_mat <- as.matrix(scores_df) result <- cronbachs_alpha(scores_mat, 4, enum_all = FALSE) summary(result) print(result$alpha_min_opt) print(result$alpha_max_opt) all_result = display_all(scores_mat = scores_mat,score_max = 2) summary(all_result) })