PLS SEM KKC Package

Segmentation of Partial Least Square Structural Equation Modeling Using Kernel K-Means Clustering (PLS SEM KKC) is the development of a new method in PLS SEM segmentation that uses non-linear clustering methods. Segmentation is carried out based on residual values of measurement and structural PLS SEM modeling which often exhibit non-linear separability and thus require a non-linear separable, thus requiring a non-linear PLS SEM segmentation. Main contribution of this study is the integration of kernel-based clustering into PLS SEM segmentation. Method effectively addresses unobserved heterogeneity by capturing non-linear residual patterns, leading to more accurate modelsSegmentation of Partial Least Square Structural Equation Modeling Using Kernel K-Means Clustering (PLS SEM KKC) is the development of a new method in PLS SEM segmentation that uses non-linear clustering methods. Segmentation is carried out based on residual values of measurement and structural PLS SEM modeling which often exhibit non-linear separability and thus require a non-linear separable, thus requiring a non-linear PLS SEM segmentation. Main contribution of this study is the integration of kernel-based clustering into PLS SEM segmentation. Method effectively addresses unobserved heterogeneity by capturing non-linear residual patterns, leading to more accurate models.

This package is an extension of the ResiPLS package, which develops SEMPLS analysis with segmentation using Kernel K-Means. If you are interested in this package, please contact me at ().

The following are the functions built into the SEMPLSKKC Package:

import_dari_excel = function(file_path="data.xlsx") {
  library(readxl)
  Variabel=read_excel(file_path, sheet = "Variabel")
  Variabel=data.frame(Variabel=Variabel$Variabel)
  Indikator=read_excel(file_path, sheet = "Indikator")
  Indikator=data.frame(Indikator=Indikator$Indikator)
  Data=read_excel(file_path, sheet = "Data")
  MIM=read_excel(file_path, sheet = "MIM")
  MOM=read_excel(file_path, sheet = "MOM")
  return(list(Variabel = Variabel, Indikator = Indikator, Data = Data, MIM = MIM, MOM = MOM))
}

ols = function(X, y) {
  beta = solve(t(X) %*% X) %*% t(X) %*% y
  return(beta)
}

plsalgorithm <- function(data, matrix_outer_model, matrix_inner_model, inner_weight_scheme="Centroid", indicator, laten_variables){
  #Set Output 
  outputplsalgoritm=list()
  indexoutput=0

  #Counting the number of indicators
  n_indicator=nrow(matrix_outer_model)

  #Counting the number of laten variable
  n_laten_variables=ncol(matrix_outer_model)

  #Counting the number of observations
  n=nrow(data)

  #Data standardization in matrix form
  standardize_data=scale(data)

  #Mapping indicator to latent variable
  indicator_to_laten_variable_map=list()
  for (i in 1:n_laten_variables) {
    indicator_to_laten_variable_connection=c()
    for (j in 1:n_indicator) {
      if (matrix_outer_model[j,i]==1 | matrix_outer_model[j,i]==2 | matrix_outer_model[j,i]==3) {
        indicator_to_laten_variable_connection=append(indicator_to_laten_variable_connection,j)
      }
    }
    indicator_to_laten_variable_map=append(indicator_to_laten_variable_map,list(indicator_to_laten_variable_connection))
  }

  #Outer model type mapping
  type_outer_model_map=list()
  for (i in 1:n_laten_variables) {
    type_outer_model=c()
    for (j in 1:n_indicator) {
      if (matrix_outer_model[j,i]==1 | matrix_outer_model[j,i]==2 | matrix_outer_model[j,i]==3) {
        type_outer_model=append(type_outer_model,matrix_outer_model[j,i])
      }
    }
    type_outer_model_map=append(type_outer_model_map,list(type_outer_model))
  }

  #Standardization of data in list form
  list_indicator=list()
  for (i in 1:n_laten_variables) {
    part_standardize_data=standardize_data[,indicator_to_laten_variable_map[[i]]]
    list_indicator=append(list_indicator,list(part_standardize_data))
  }

  #Initialization Weight
  Weight=list()
  for (i in 1:n_laten_variables) {
    vector_one=rep(1,length(indicator_to_laten_variable_map[[i]]))
    matrix_one=matrix(vector_one,nrow = length(indicator_to_laten_variable_map[[i]]),ncol = 1)
    Weight=append(Weight,list(matrix_one))
  }

  #Counting f
  f=list()
  for (i in 1:n_laten_variables) {
    f_i=sqrt(1/(t(Weight[[i]])%*%var(list_indicator[[i]])%*%Weight[[i]]))
    f=append(f,list(f_i))
  }

  #Counting  Outer Weight
  outer_weight=list()
  for (i in 1:n_laten_variables) {
    outer_weight_i=Weight[[i]]%*%f[[i]]
    outer_weight=append(outer_weight,list(outer_weight_i))
  }

  #Outsite Approximation 
  Y=list()
  for (i in 1:n_laten_variables) {
    Y_i=list_indicator[[i]]%*%outer_weight[[i]]
    Y=append(Y,list(Y_i))
  }

  #Outer Model Iteration
  check_result = FALSE
  iteration=1
  while (check_result <= FALSE) {

    ## step 1 inner weight
    v=matrix(0,nrow = n_laten_variables,ncol = n_laten_variables)
    if (inner_weight_scheme == "Centroid") {
      for (i in 1:n_laten_variables) {
        for (j in 1:n_laten_variables) {
          if (matrix_inner_model[i,j] == 1) {
            v[i,j]=cor(Y[[i]],Y[[j]])/abs(cor(Y[[i]],Y[[j]]))
            v[j,i]=cor(Y[[i]],Y[[j]])/abs(cor(Y[[i]],Y[[j]]))
          }
        }
      }
    } else if (inner_weight_scheme == "Factor") {
      for (i in 1:n_laten_variables) {
        for (j in 1:n_laten_variables) {
          if (matrix_inner_model[i,j] == 1) {
            v[i,j]=cor(Y[[i]],Y[[j]])
            v[j,i]=cor(Y[[i]],Y[[j]])
          }
        }
      }
    } else if (inner_weight_scheme == "Path") {
      for (i in 1:n_laten_variables) {
        for (j in 1:n_laten_variables) {
          if (matrix_inner_model[i,j] == 1) {
            v[i,j]=ols(Y[[i]],Y[[j]])
            v[j,i]=cor(Y[[i]],Y[[j]])
          }
        }
      }
    }

    #step 2 inside approximation
    Y_ins=list()
    for (i in 1:n_laten_variables) {
      Y_ins_i=matrix(0,nrow = n,ncol = 1)
      for (j in 1:n_laten_variables) {
        Y_ins_i=Y_ins_i+Y[[j]]%*%v[i,j]
      }
      Y_ins=append(Y_ins,list(Y_ins_i))
    }

    #step 3 outer weight
    ##weight
    weight_new=list()
    for (i in 1:n_laten_variables) {
      # 1=single construct, 2=reflective, 3=formative
      if (type_outer_model_map[[i]][1]==2) {
        weight_new_i=matrix(0,nrow = length(type_outer_model_map[[i]]), ncol = 1)
        for (j in 1:length(type_outer_model_map[[i]])) {
          weight_new_i[j,1]=ols(Y_ins[[i]],list_indicator[[i]][,j])
        }
        weight_new=append(weight_new,list(weight_new_i))
      } else if (type_outer_model_map[[i]][1]==3) {
        weight_new_i=ols(list_indicator[[i]],Y_ins[[i]])
        weight_new=append(weight_new,list(weight_new_i))
      } else if (type_outer_model_map[[i]][1]==1) {
        weight_new_i=Weight[[i]]
        weight_new=append(weight_new,list(weight_new_i))
      }
    }

    check_result = TRUE
    for (i in 1:length(Weight)) {
      difference=abs(Weight[[i]]-weight_new[[i]])
      if(!all(difference<0.00001)){
        check_result = FALSE
        break
      }
    }

    ##Adding iteration value
    iteration=iteration+1

    for (i in 1:n_laten_variables) {
      Weight[[i]]=weight_new[[i]]
    }

    ##Counting f
    f=list()
    for (i in 1:n_laten_variables) {
      f_i=sqrt(1/(t(Weight[[i]])%*%var(list_indicator[[i]])%*%Weight[[i]]))
      f=append(f,list(f_i))
    }

    ##Counting outer weight
    outer_weight=list()
    for (i in 1:n_laten_variables) {
      outer_weight_i=Weight[[i]]%*%f[[i]]
      outer_weight=append(outer_weight,list(outer_weight_i))
    }

    #step 4 (outside approximation)
    Y=list()
    for (i in 1:n_laten_variables) {
      Y_i=list_indicator[[i]]%*%outer_weight[[i]]
      Y=append(Y,list(Y_i))
    }
  }

  # Outer Weight Final and Skor Laten Final
  cat("Number of Iterasi:",iteration,"\n")
  indexoutput=indexoutput+1
  outputplsalgoritm[[indexoutput]]=outer_weight
  new_text=paste("Outer Weight Final")
  names(outputplsalgoritm)[indexoutput]=new_text
  cat("Outer Weight","\n")
  for(i in seq_along(outer_weight)) {
    cat("Variabel Laten ",laten_variables[i,1],"\n")
    print(outer_weight[[i]]) 
    cat("\n") 
  }
  indexoutput=indexoutput+1
  outputplsalgoritm[[indexoutput]]=Y
  new_text=paste("Y Final")
  names(outputplsalgoritm)[indexoutput]=new_text
  cat("Skor Variabel Laten","\n")
  for(i in seq_along(Y)) {
    cat("Variabel Laten ",laten_variables[i,1],"\n")
    print(head(Y[[i]]))
    cat("\n")
  }

  #stage 2
  ##Creating a list of exogenous columns
  list_exogenous_columns=list()
  for (i in 1:n_laten_variables) {
    exogenous_columns=c()
    for (j in 1:n_laten_variables) {
      if (matrix_inner_model[j,i]==1) {
        exogenous_columns=append(exogenous_columns,j)
      }
    }
    list_exogenous_columns=append(list_exogenous_columns,list(exogenous_columns))
  }

  ##Eksogen
  exogenous=list()
  for (i in 1:n_laten_variables) {
    k=length(list_exogenous_columns[[i]])
    if (k==0) {
      exogenous_i = NULL
    } else if (k==1) {
      fill=list_exogenous_columns[[i]][1]
      exogenous_i = Y[[fill]]
    } else if (k>1) {
      for (j in 1:k) {
        fill=list_exogenous_columns[[i]][j]
        # print(fill)
        if (j==1) {
          exogenous_i = Y[[fill]]
        } else {
          exogenous_i = cbind(exogenous_i,Y[[fill]])
        }
      }
    }
    exogenous=append(exogenous,list(exogenous_i))
  }

  path_coefficient=list()
  for (i in 1:n_laten_variables) {
    if (is.null(list_exogenous_columns[[i]])) {
      path_coefficient_i=NULL
    } else {
      path_coefficient_i=ols(exogenous[[i]],Y[[i]])
    }
    path_coefficient=append(path_coefficient,list(path_coefficient_i))
  }
  indexoutput=indexoutput+1
  outputplsalgoritm[[indexoutput]]=path_coefficient
  names(outputplsalgoritm)[indexoutput]="Path Coefficient"
  cat("Koefisien Jalur:\n ")
  for(i in seq_along(path_coefficient)) {
    cat("Variabel Laten ",laten_variables[i,1],"\n")
    print(path_coefficient[[i]]) 
    cat("\n") 
  }

  ##Outer Loading
  outer_loading=list()
  for (i in 1:n_laten_variables) {
    if (type_outer_model_map[[i]][1]==2 | type_outer_model_map[[i]][1]==3) {
      outer_loading_i=matrix(0,nrow = length(type_outer_model_map[[i]]), ncol = 1)
      for (j in 1:length(type_outer_model_map[[i]])) {
        outer_loading_i[j,1]=ols(Y[[i]],list_indicator[[i]][,j])
      }
      outer_loading=append(outer_loading,list(outer_loading_i))

    } else if (type_outer_model_map[[i]][1]==1) {
      outer_loading_i=1
      outer_loading=append(outer_loading,list(outer_loading_i))
    }
  }
  indexoutput=indexoutput+1
  outputplsalgoritm[[indexoutput]]=outer_loading
  names(outputplsalgoritm)[indexoutput]="Outer Loading"
  cat("Outer Loading:\n ")
  for(i in seq_along(outer_loading)) {
    cat("Variabel Laten ",laten_variables[i,1],"\n")
    print(outer_loading[[i]]) 
    cat("\n") 
  }
  vector_outer_loading=unlist(outer_loading)

  ##Inner Residual
  pertama=TRUE
  for (i in 1:n_laten_variables) {
    if (is.null(list_exogenous_columns[[i]])) {
    } else {
      innerresidual_i=Y[[i]]-(exogenous[[i]]%*%path_coefficient[[i]])
      if (pertama==TRUE) {
        innerresidual=matrix(innerresidual_i)
        pertama=FALSE
      } else if (pertama==FALSE) {
        innerresidual=cbind(innerresidual,innerresidual_i)
      }
    }
  }

  ##Outer Residual
  pertama=TRUE
  for (i in 1:n_laten_variables) {
    for (j in 1:n_indicator) {
      if (matrix_outer_model[j,i]==2 | matrix_outer_model[j,i]==3) {
        outerresidual_i=standardize_data[,j]-(Y[[i]]%*%vector_outer_loading[j])
        if (pertama==TRUE) {
          outerresidual=matrix(outerresidual_i)
          pertama=FALSE
        } else if (pertama==FALSE) {
          outerresidual=cbind(outerresidual,outerresidual_i)
        }
      }
    }
  }

  ##Matriks Residual (Combination of Outer Residual and Inner Residual)
  matrixresidual=cbind(outerresidual,innerresidual)
  indexoutput=indexoutput+1
  outputplsalgoritm[[indexoutput]]=matrixresidual
  names(outputplsalgoritm)[indexoutput]="Matrix Residual"
  cat("Matriks Residual Gabungan:\n ")
  print(head(matrixresidual))
  cat("\n")

  ##Composite Reliability (CR)
  CR=list()
  for (i in 1:length(outer_loading)) {
    if (type_outer_model_map[[i]][1]==2) {
      squared_loadings=outer_loading[[i]]^2
      squared_sum_loadings=sum(outer_loading[[i]])^2
      var_error=1-squared_loadings
      sum_var_error=sum(var_error)
      CR_i=squared_sum_loadings/(squared_sum_loadings+sum_var_error)
      CR=append(CR,CR_i)

    } else if (type_outer_model_map[[i]][1]==1 | type_outer_model_map[[i]][1]==3) {
      CR_i=NA
      CR=append(CR,CR_i)
    }
  }
  indexoutput=indexoutput+1
  outputplsalgoritm[[indexoutput]]=CR
  names(outputplsalgoritm)[indexoutput]="CR"
  cat("CR:\n ")
  for(i in seq_along(CR)) {
    cat("Variabel Laten ",laten_variables[i,1],"\n")
    print(CR[[i]]) 
    cat("\n") 
  }

  ##Average Variance Extracted(AVE)
  AVE=list()
  for (i in 1:length(outer_loading)) {
    if (type_outer_model_map[[i]][1]==2) {
      squared_loadings=outer_loading[[i]]^2
      sum_squared_loadings=sum(squared_loadings)
      var_error=1-squared_loadings
      sum_var_error=sum(var_error)
      AVE_i=sum_squared_loadings/(sum_squared_loadings+sum_var_error)
      AVE=append(AVE,AVE_i)

    } else if (type_outer_model_map[[i]][1]==1 | type_outer_model_map[[i]][1]==3) {
      AVE_i=NA
      AVE=append(AVE,AVE_i)
    }
  }
  indexoutput=indexoutput+1
  outputplsalgoritm[[indexoutput]]=AVE
  names(outputplsalgoritm)[indexoutput]="AVE"
  cat("AVE:\n ")
  for(i in seq_along(AVE)) {
    cat("Variabel Laten ",laten_variables[i,1],"\n")
    print(AVE[[i]]) 
    cat("\n")
  }

  ##Heterotrait-Monotrait Ratio (HTMT)
  htmt_matrix = matrix(NA, n_laten_variables, n_laten_variables)
  rownames(htmt_matrix)=laten_variables$Variabel
  colnames(htmt_matrix)=laten_variables$Variabel
  for (i in 1:n_laten_variables) {
    for (j in 1:n_laten_variables) {
      if (i != j) {
        indicators_i=list_indicator[[i]]
        indicators_j=list_indicator[[j]]
        cross_correlations=cor(indicators_i, indicators_j)
        within_correlations_i=cor(indicators_i)
        within_correlations_j=cor(indicators_j)
        mean_cross_correlation=mean(abs(cross_correlations))
        mean_within_correlation_i=mean(abs(within_correlations_i[lower.tri(within_correlations_i)]))
        mean_within_correlation_j=mean(abs(within_correlations_j[lower.tri(within_correlations_j)]))
        htmt_value=mean_cross_correlation/sqrt(mean_within_correlation_i*mean_within_correlation_j)
        htmt_matrix[i, j]=htmt_value
      }
    }
  }
  indexoutput=indexoutput+1
  outputplsalgoritm[[indexoutput]]=htmt_matrix
  names(outputplsalgoritm)[indexoutput]="HTMT Matrix"
  cat("HTMT Matrix:\n ")
  print(htmt_matrix)
  cat("\n ")

  ##R Square
  R_Square=list()
  for (i in 1:n_laten_variables) {
    if (!is.null(exogenous[[i]]) && !is.null(path_coefficient[[i]])) {
      y_actual = Y[[i]]
      y_predicted = exogenous[[i]] %*% path_coefficient[[i]]
      ss_total = sum((y_actual - mean(y_actual))^2)
      ss_residual = sum((y_actual - y_predicted)^2)
      r_square = 1 - (ss_residual / ss_total)
      R_Square[[i]] = r_square
    } else {
      R_Square[[i]] = NA
    }
  }
  indexoutput=indexoutput+1
  outputplsalgoritm[[indexoutput]]=R_Square
  names(outputplsalgoritm)[indexoutput]="R Square"
  cat("R Square:\n ")
  for(i in seq_along(R_Square)) {
    cat("Variabel Laten ",laten_variables[i,1],"\n")
    print(R_Square[[i]]) 
    cat("\n") 
  }

  #output
  return(outputplsalgoritm)

}

plsalgorithm_bootstrap <- function(data, matrix_outer_model, matrix_inner_model, inner_weight_scheme="Centroid", indicator, laten_variables, n_bootstrap=1000) {
  # Function to calculate PLS Algorithm without bootstrapping
  pls_algorithm_core <- function(data) {
    plsalgoritmlite <- function(data, matrix_outer_model, matrix_inner_model, inner_weight_scheme="Centroid", indicator, laten_variables){
      #Set Output 
      outputplsalgoritm=list()
      indexoutput=0

      #Counting the number of indicators
      n_indicator=nrow(matrix_outer_model)

      #Counting the number of  laten variables
      n_laten_variables=ncol(matrix_outer_model)

      #Counting the number of observation
      n=nrow(data)

      #Data standardization in matrix form
      standardize_data=scale(data)

      #Mapping indicator to latent variable
      indicator_to_laten_variable_map=list()
      for (i in 1:n_laten_variables) {
        indicator_to_laten_variable_connection=c()
        for (j in 1:n_indicator) {
          if (matrix_outer_model[j,i]==1 | matrix_outer_model[j,i]==2 | matrix_outer_model[j,i]==3) {
            indicator_to_laten_variable_connection=append(indicator_to_laten_variable_connection,j)
          }
        }
        indicator_to_laten_variable_map=append(indicator_to_laten_variable_map,list(indicator_to_laten_variable_connection))
      }

      #Outer model type mapping
      type_outer_model_map=list()
      for (i in 1:n_laten_variables) {
        type_outer_model=c()
        for (j in 1:n_indicator) {
          if (matrix_outer_model[j,i]==1 | matrix_outer_model[j,i]==2 | matrix_outer_model[j,i]==3) {
            type_outer_model=append(type_outer_model,matrix_outer_model[j,i])
          }
        }
        type_outer_model_map=append(type_outer_model_map,list(type_outer_model))
      }

      #Standardization of data in list form
      list_indicator=list()
      for (i in 1:n_laten_variables) {
        part_standardize_data=standardize_data[,indicator_to_laten_variable_map[[i]]]
        list_indicator=append(list_indicator,list(part_standardize_data))
      }

      # Initialization Weight
      Weight=list()
      for (i in 1:n_laten_variables) {
        vector_one=rep(1,length(indicator_to_laten_variable_map[[i]]))
        matrix_one=matrix(vector_one,nrow = length(indicator_to_laten_variable_map[[i]]),ncol = 1)
        Weight=append(Weight,list(matrix_one))
      }

      #Counting nilai f
      f=list()
      for (i in 1:n_laten_variables) {
        f_i=sqrt(1/(t(Weight[[i]])%*%var(list_indicator[[i]])%*%Weight[[i]]))
        f=append(f,list(f_i))
      }

      #Counting Outer Weight
      outer_weight=list()
      for (i in 1:n_laten_variables) {
        outer_weight_i=Weight[[i]]%*%f[[i]]
        outer_weight=append(outer_weight,list(outer_weight_i))
      }

      #Outsite Approximation 
      Y=list()
      for (i in 1:n_laten_variables) {
        Y_i=list_indicator[[i]]%*%outer_weight[[i]]
        Y=append(Y,list(Y_i))
      }

      #Step 1 Iteration Outer Model
      check_result = FALSE
      iteration=1
      while (check_result <= FALSE) {

        ## step 1 inner weight
        v=matrix(0,nrow = n_laten_variables,ncol = n_laten_variables)
        if (inner_weight_scheme == "Centroid") {
          for (i in 1:n_laten_variables) {
            for (j in 1:n_laten_variables) {
              if (matrix_inner_model[i,j] == 1) {
                v[i,j]=cor(Y[[i]],Y[[j]])/abs(cor(Y[[i]],Y[[j]]))
                v[j,i]=cor(Y[[i]],Y[[j]])/abs(cor(Y[[i]],Y[[j]]))
              }
            }
          }
        } else if (inner_weight_scheme == "Factor") {
          for (i in 1:n_laten_variables) {
            for (j in 1:n_laten_variables) {
              if (matrix_inner_model[i,j] == 1) {
                v[i,j]=cor(Y[[i]],Y[[j]])
                v[j,i]=cor(Y[[i]],Y[[j]])
              }
            }
          }
        } else if (inner_weight_scheme == "Path") {
          for (i in 1:n_laten_variables) {
            for (j in 1:n_laten_variables) {
              if (matrix_inner_model[i,j] == 1) {
                v[i,j]=ols(Y[[i]],Y[[j]])
                v[j,i]=cor(Y[[i]],Y[[j]])
              }
            }
          }
        }

        #step 2 inside approximation
        Y_ins=list()
        for (i in 1:n_laten_variables) {
          Y_ins_i=matrix(0,nrow = n,ncol = 1)
          for (j in 1:n_laten_variables) {
            Y_ins_i=Y_ins_i+Y[[j]]%*%v[i,j]
          }
          Y_ins=append(Y_ins,list(Y_ins_i))
        }

        #step 3 outer weight
        ##weight
        weight_new=list()
        for (i in 1:n_laten_variables) {
          # 1=single construct, 2=reflective, 3=formative
          if (type_outer_model_map[[i]][1]==2) {
            weight_new_i=matrix(0,nrow = length(type_outer_model_map[[i]]), ncol = 1)
            for (j in 1:length(type_outer_model_map[[i]])) {
              weight_new_i[j,1]=ols(Y_ins[[i]],list_indicator[[i]][,j])
            }
            weight_new=append(weight_new,list(weight_new_i))
          } else if (type_outer_model_map[[i]][1]==3) {
            weight_new_i=ols(list_indicator[[i]],Y_ins[[i]])
            weight_new=append(weight_new,list(weight_new_i))
          } else if (type_outer_model_map[[i]][1]==1) {
            weight_new_i=Weight[[i]]
            weight_new=append(weight_new,list(weight_new_i))
          }
        }

        check_result = TRUE
        for (i in 1:length(Weight)) {
          difference=abs(Weight[[i]]-weight_new[[i]])
          if(!all(difference<0.00001)){
            check_result = FALSE
            break
          }
        }

        iteration=iteration+1

        for (i in 1:n_laten_variables) {
          Weight[[i]]=weight_new[[i]]
        }

        ##Counting f
        f=list()
        for (i in 1:n_laten_variables) {
          f_i=sqrt(1/(t(Weight[[i]])%*%var(list_indicator[[i]])%*%Weight[[i]]))
          f=append(f,list(f_i))
        }

        ##Counting outer weight
        outer_weight=list()
        for (i in 1:n_laten_variables) {
          outer_weight_i=Weight[[i]]%*%f[[i]]
          outer_weight=append(outer_weight,list(outer_weight_i))
        }

        #step 4 (outside approximation)
        Y=list()
        for (i in 1:n_laten_variables) {
          Y_i=list_indicator[[i]]%*%outer_weight[[i]]
          Y=append(Y,list(Y_i))
        }
      }

      #Print Final Outer Weight and Final Latent Score
      indexoutput=indexoutput+1
      outputplsalgoritm[[indexoutput]]=outer_weight
      new_text=paste("Outer Weight Final")
      names(outputplsalgoritm)[indexoutput]=new_text

      #step 2
      ##Creating a list of exogenous columns
      list_exogenous_columns=list()
      for (i in 1:n_laten_variables) {
        exogenous_columns=c()
        for (j in 1:n_laten_variables) {
          if (matrix_inner_model[j,i]==1) {
            exogenous_columns=append(exogenous_columns,j)
          }
        }
        list_exogenous_columns=append(list_exogenous_columns,list(exogenous_columns))
      }

      ##Eksogen
      exogenous=list()
      for (i in 1:n_laten_variables) {
        k=length(list_exogenous_columns[[i]])
        if (k==0) {
          exogenous_i = NULL
        } else if (k==1) {
          fill=list_exogenous_columns[[i]][1]
          exogenous_i = Y[[fill]]
        } else if (k>1) {
          for (j in 1:k) {
            fill=list_exogenous_columns[[i]][j]
            # print(fill)
            if (j==1) {
              exogenous_i = Y[[fill]]
            } else {
              exogenous_i = cbind(exogenous_i,Y[[fill]])
            }
          }
        }
        exogenous=append(exogenous,list(exogenous_i))
      }

      path_coefficient=list()
      for (i in 1:n_laten_variables) {
        if (is.null(list_exogenous_columns[[i]])) {
          path_coefficient_i=NULL
        } else {
          path_coefficient_i=ols(exogenous[[i]],Y[[i]])
        }
        path_coefficient=append(path_coefficient,list(path_coefficient_i))
      }
      indexoutput=indexoutput+1
      outputplsalgoritm[[indexoutput]]=path_coefficient
      names(outputplsalgoritm)[indexoutput]="Path Coefficient"

      ##Outer Loading
      outer_loading=list()
      for (i in 1:n_laten_variables) {
        if (type_outer_model_map[[i]][1]==2 | type_outer_model_map[[i]][1]==3) {
          outer_loading_i=matrix(0,nrow = length(type_outer_model_map[[i]]), ncol = 1)
          for (j in 1:length(type_outer_model_map[[i]])) {
            outer_loading_i[j,1]=ols(Y[[i]],list_indicator[[i]][,j])
          }
          outer_loading=append(outer_loading,list(outer_loading_i))

        } else if (type_outer_model_map[[i]][1]==1) {
          outer_loading_i=1
          outer_loading=append(outer_loading,list(outer_loading_i))
        }
      }
      indexoutput=indexoutput+1
      outputplsalgoritm[[indexoutput]]=outer_loading
      names(outputplsalgoritm)[indexoutput]="Outer Loading"

      #output
      return(outputplsalgoritm)

    }
    result <- plsalgoritmlite(data, matrix_outer_model, matrix_inner_model, inner_weight_scheme, indicator, laten_variables)
    return(result)
  }

  # Calculate PLS algorithm for original data
  result_original <- pls_algorithm_core(data)

  # Initialization to save bootstrapping results
  outer_weight_bootstrap <- list()
  outer_loading_bootstrap <- list()
  path_coefficient_bootstrap <- list()

  # bootstrapping
  for (i in 1:n_bootstrap) {
    data_bootstrap <- data[sample(1:nrow(data), replace=TRUE), ]
    result_bootstrap <- pls_algorithm_core(data_bootstrap)
    if (i == 1) {
      outer_weight_bootstrap <- result_bootstrap$`Outer Weight Final`
      outer_loading_bootstrap <- result_bootstrap$`Outer Loading`
      path_coefficient_bootstrap <- result_bootstrap$`Path Coefficient`
    } else {
      for (j in 1:nrow(laten_variables)) {
        # print(outer_weight_bootstrap[[j]])
        # print(result_bootstrap$`Outer Weight Final`[[j]])
        if (!is.null(outer_weight_bootstrap[[j]]) ) {
          outer_weight_bootstrap[[j]] <- cbind(outer_weight_bootstrap[[j]], result_bootstrap$`Outer Weight Final`[[j]])
        }
        if (!is.null(outer_loading_bootstrap[[j]]) ) {
          outer_loading_bootstrap[[j]] <- cbind(outer_loading_bootstrap[[j]], result_bootstrap$`Outer Loading`[[j]])
        }
        if (!is.null(path_coefficient_bootstrap[[j]]) ) {
          path_coefficient_bootstrap[[j]] <- cbind(path_coefficient_bootstrap[[j]], result_bootstrap$`Path Coefficient`[[j]])
        }
      }
    }
  }

  #Calculating bootstrap statistics
  howb=list()
  for (j in 1:nrow(laten_variables)) {
    if (!is.null(result_original$`Outer Weight Final`[[j]])) {
      outer_weight_original=as.vector(result_original$`Outer Weight Final`[[j]])
      average_outer_weight=rowMeans(outer_weight_bootstrap[[j]])
      standar_error=as.vector(apply(outer_weight_bootstrap[[j]], 1, sd))
      t_hitung=outer_weight_original/standar_error
      p_value=2*(1-pnorm(abs(t_hitung)))
      howb[[j]]=data.frame(outer_weight_original,
                           average_outer_weight,
                           standar_error,
                           t_hitung,
                           p_value)
    } else {
      outer_weight_original=NULL
      average_outer_weight=NULL
      standar_error=NULL
      t_hitung=NULL
      p_value=NULL
      howb[[j]]=data.frame(outer_weight_original,
                           average_outer_weight,
                           standar_error,
                           t_hitung,
                           p_value)
    }
  }
  holb=list()
  for (j in 1:nrow(laten_variables)) {
    if (!is.null(result_original$`Outer Loading`[[j]])) {
      outer_loading_original=as.vector(result_original$`Outer Loading`[[j]])
      average_outer_loading=rowMeans(outer_loading_bootstrap[[j]])
      standar_error=as.vector(apply(outer_loading_bootstrap[[j]], 1, sd))
      t_hitung=outer_loading_original/standar_error
      p_value=2*(1-pnorm(abs(t_hitung)))
      holb[[j]]=data.frame(outer_loading_original,
                           average_outer_loading,
                           standar_error,
                           t_hitung,
                           p_value)
    } else {
      outer_loading_original=NULL
      average_outer_loading=NULL
      standar_error=NULL
      t_hitung=NULL
      p_value=NULL
      holb[[j]]=data.frame(outer_loading_original,
                           average_outer_loading,
                           standar_error,
                           t_hitung,
                           p_value)
    }
  }
  hpcb=list()
  for (j in 1:nrow(laten_variables)) {
    if (!is.null(result_original$`Path Coefficient`[[j]])) {
      path_coefficient_original=as.vector(result_original$`Path Coefficient`[[j]])
      average_path_coefficient=rowMeans(path_coefficient_bootstrap[[j]])
      standar_error=as.vector(apply(path_coefficient_bootstrap[[j]], 1, sd))
      t_hitung=path_coefficient_original/standar_error
      p_value=2*(1-pnorm(abs(t_hitung)))
      hpcb[[j]]=data.frame(path_coefficient_original,
                           average_path_coefficient,
                           standar_error,
                           t_hitung,
                           p_value)
    } else {
      path_coefficient_original=NULL
      average_path_coefficient=NULL
      standar_error=NULL
      t_hitung=NULL
      p_value=NULL
      hpcb[[j]]=data.frame(path_coefficient_original,
                           average_path_coefficient,
                           standar_error,
                           t_hitung,
                           p_value)
    }
  }

  #Outer Weight
  output <- list(
    outer_weight=howb,
    outer_loading=holb,
    path_coefficient=hpcb
  )

  return(output)
}

euclidean_distance <- function(a, b) {
  sqrt(sum((a - b)^2))
}

kmeans_custom <- function(data, k, max_iter = 100) {
  n <- nrow(data)
  d <- ncol(data)

  # Randomly initialize centroids
  set.seed(123)  
  centroids <- data[sample(1:n, k), ]

  clusters <- rep(0, n)
  for (iter in 1:max_iter) {
    # Cluster assignment
    for (i in 1:n) {
      distances <- apply(centroids, 1, function(centroid) euclidean_distance(data[i, ], centroid))
      clusters[i] <- which.min(distances)
    }

    # Save the previous centroid for convergence checking.
    previous_centroids <- centroids

    # Centroid update
    for (j in 1:k) {
      if (sum(clusters == j) > 0) {
        centroids[j, ] <- colMeans(data[clusters == j, ])
      }
    }

    # Convergence check
    if (all(previous_centroids == centroids)) {
      cat("Algoritma konvergen pada iterasi ke-", iter, "\n")
      break
    }
  }

  # Returns results in list form
  return(list(clusters = clusters, centroids = centroids))
}

rbf_kernel <- function(x, y, sigma = 1) {
  dist_sq <- sum((x - y)^2)
  exp(-dist_sq / (2 * sigma^2))
}

create_kernel_matrix <- function(data, kernel_fun = rbf_kernel, sigma = 1) {
  n <- nrow(data)
  K <- matrix(0, n, n)
  for (i in 1:n) {
    for (j in 1:n) {
      K[i, j] <- kernel_fun(data[i, ], data[j, ], sigma = sigma)
    }
  }
  return(K)
}

kernel_kmeans <- function(data,
                          k,
                          max_iter = 100,
                          kernel_fun = rbf_kernel,
                          sigma = 1) {
  # 1. Counting kernel matrix K (n x n)
  K <- create_kernel_matrix(data, kernel_fun, sigma)

  n <- nrow(data)

  # 2. Random cluster initialization
  set.seed(123)
  clusters <- sample(1:k, n, replace = TRUE)

  # Auxiliary variable to store the number of intracluster kernels
  sum_K_in_cluster <- numeric(k)
  sum_K_with_i <- matrix(0, nrow = k, ncol = n)

  # -------------------------
  # function updates the number of kernels for each cluster
  # -------------------------
  update_cluster_sums <- function(clusters) {
    sum_K_in_cluster <<- numeric(k)
    sum_K_with_i <<- matrix(0, nrow = k, ncol = n)

    for (j in 1:k) {
      idx_j <- which(clusters == j)
      if (length(idx_j) > 0) {
        # sum_{p,q in C_j} K[p, q]
        sum_K_in_cluster[j] <<- sum(K[idx_j, idx_j])

        # sum_{p in C_j} K[i, p]
        for (i in 1:n) {
          sum_K_with_i[j, i] <<- sum(K[i, idx_j])
        }
      }
    }
  }

  # Inisialisasi sum kernel
  update_cluster_sums(clusters)

  # -------------------------
  # Iteration Kernel K-Means
  # -------------------------
  for (iter in 1:max_iter) {
    changed <- FALSE

    for (i in 1:n) {
      # Counting distance^2 in feature space
      # distance^2 = K[i,i] - 2/|C_j| sum_{p in C_j} K[i,p] + 1/|C_j|^2 sum_{p,q in C_j} K[p,q]
      dist_clusters <- numeric(k)
      for (j in 1:k) {
        idx_j <- which(clusters == j)
        nj <- length(idx_j)
        if (nj > 0) {
          dist_clusters[j] <- K[i, i] -
            (2 / nj) * sum_K_with_i[j, i] +
            (1 / (nj^2)) * sum_K_in_cluster[j]
        } else {
          dist_clusters[j] <- Inf
        }
      }

      new_cluster <- which.min(dist_clusters)
      if (new_cluster != clusters[i]) {
        clusters[i] <- new_cluster
        changed <- TRUE
      }
    }

    # Check convergence
    if (!changed) {
      cat("Kernel K-Means konvergen pada iterasi ke-", iter, "\n")
      break
    }

    # Update sum-sum kernel
    update_cluster_sums(clusters)
  }


  # Return results
  return(list(
    clusters = clusters
  ))
}

To run this package, you can do this:

library(SEMPLSKKC)
## 
## Attaching package: 'SEMPLSKKC'
## The following objects are masked _by_ '.GlobalEnv':
## 
##     create_kernel_matrix, euclidean_distance, import_dari_excel,
##     kernel_kmeans, kmeans_custom, ols, plsalgorithm,
##     plsalgorithm_bootstrap, rbf_kernel

Running SEMPLSKKC

inputdata=import_dari_excel(file_path = "DataSeminter.xlsx")

hasil=plsalgorithm(data = inputdata$Data,inner_weight_scheme = "Path",matrix_outer_model = inputdata$MOM, matrix_inner_model = inputdata$MIM, indicator = inputdata$Indikator, laten_variables = inputdata$Variabel)
## Number of Iterasi: 7 
## Outer Weight 
## Variabel Laten  Perfomance Expectancy 
##           [,1]
## [1,] 0.4078256
## [2,] 0.3948863
## [3,] 0.3516330
## 
## Variabel Laten  Effort Expectancy 
##           [,1]
## [1,] 0.4682900
## [2,] 0.3154480
## [3,] 0.3689983
## 
## Variabel Laten  Social Influence 
##           [,1]
## [1,] 0.7372356
## [2,] 0.4142433
## 
## Variabel Laten  Facilitating Conditions 
##           [,1]
## [1,] 0.3906090
## [2,] 0.4973840
## [3,] 0.3232516
## 
## Variabel Laten  Behavioral Intention 
##           [,1]
## [1,] 0.3231985
## [2,] 0.3223177
## [3,] 0.2944332
## [4,] 0.1980679
## 
## Skor Variabel Laten 
## Variabel Laten  Perfomance Expectancy 
##           [,1]
## [1,] -0.193634
## [2,] -0.193634
## [3,] -0.193634
## [4,] -0.621821
## [5,] -0.193634
## [6,] -0.193634
## 
## Variabel Laten  Effort Expectancy 
##             [,1]
## [1,] -0.63653562
## [2,]  1.29973203
## [3,]  0.61976369
## [4,] -0.63653562
## [5,]  0.04343272
## [6,] -0.63653562
## 
## Variabel Laten  Social Influence 
##            [,1]
## [1,] -2.0094775
## [2,] -1.6434825
## [3,] -0.3188389
## [4,]  0.1604853
## [5,] -0.6848340
## [6,]  0.1604853
## 
## Variabel Laten  Facilitating Conditions 
##            [,1]
## [1,] -1.9626047
## [2,] -0.2291284
## [3,] -0.2291284
## [4,] -0.2291284
## [5,]  0.3041491
## [6,] -0.2291284
## 
## Variabel Laten  Behavioral Intention 
##             [,1]
## [1,] -2.54378552
## [2,] -2.54378552
## [3,] -0.44374851
## [4,] -0.03466219
## [5,] -0.44838802
## [6,] -0.03466219
## 
## Koefisien Jalur:
##  Variabel Laten  Perfomance Expectancy 
## NULL
## 
## Variabel Laten  Effort Expectancy 
## NULL
## 
## Variabel Laten  Social Influence 
## NULL
## 
## Variabel Laten  Facilitating Conditions 
## NULL
## 
## Variabel Laten  Behavioral Intention 
##             [,1]
## [1,]  0.17984759
## [2,] -0.05737437
## [3,]  0.21005121
## [4,]  0.50697975
## 
## Outer Loading:
##  Variabel Laten  Perfomance Expectancy 
##           [,1]
## [1,] 0.8715220
## [2,] 0.8914727
## [3,] 0.8319485
## 
## Variabel Laten  Effort Expectancy 
##           [,1]
## [1,] 0.8868386
## [2,] 0.8781684
## [3,] 0.8338407
## 
## Variabel Laten  Social Influence 
##           [,1]
## [1,] 0.9304480
## [2,] 0.7581066
## 
## Variabel Laten  Facilitating Conditions 
##           [,1]
## [1,] 0.8037971
## [2,] 0.9068410
## [3,] 0.7269303
## 
## Variabel Laten  Behavioral Intention 
##           [,1]
## [1,] 0.9253825
## [2,] 0.8702525
## [3,] 0.9257141
## [4,] 0.7465068
## 
## Matriks Residual Gabungan:
##              [,1]       [,2]       [,3]       [,4]        [,5]       [,6]
## [1,] -0.08791535 -0.1296811  0.2475975  0.2664125  0.04963479 -0.3805315
## [2,] -0.08791535 -0.1296811  0.2475975  0.1304387 -0.01545051 -0.1523294
## [3,] -0.08791535 -0.1296811  0.2475975  0.7334609  0.58167623 -1.4280850
## [4,]  0.28525906  0.2520359 -0.6138829  0.2664125  0.04963479 -0.3805315
## [5,] -0.08791535 -0.1296811  0.2475975 -0.3366097 -0.54749195  0.8952241
## [6,] -0.08791535 -0.1296811  0.2475975  0.2664125  0.04963479 -0.3805315
##             [,7]        [,8]       [,9]      [,10]      [,11]      [,12]
## [1,] -0.29818677  0.53068795 -1.1022605  0.3221855  0.8362000 -0.1498453
## [2,]  0.50788054 -0.90388342  0.1732348  0.1394588 -0.4239163 -0.1498453
## [3,]  0.42197524 -0.75099634  0.1732348  0.1394588 -0.4239163 -0.8274396
## [4,] -0.02401106  0.04273288  0.1732348  0.1394588 -0.4239163  0.0597423
## [5,] -0.38409207  0.68357502 -0.2554121 -0.3441392  0.8381570  0.4425970
## [6,] -0.02401106  0.04273288  0.1732348  0.1394588 -0.4239163  0.0597423
##           [,13]       [,14]      [,15]       [,16]
## [1,]  0.5135670 -0.51187444  0.1696938 -1.12838771
## [2,]  0.5135670 -0.51187444  0.1696938 -1.97301066
## [3,]  0.1230986  0.30880705  0.6908102 -0.19022938
## [4,] -0.2329097 -0.06988993  0.3854245  0.12310332
## [5,]  0.1271362  0.31310191 -1.3945346 -0.42141872
## [6,] -0.2329097 -0.06988993  0.3854245  0.04609492
## 
## CR:
##  Variabel Laten  Perfomance Expectancy 
## [1] 0.8993515
## 
## Variabel Laten  Effort Expectancy 
## [1] 0.9004078
## 
## Variabel Laten  Social Influence 
## [1] 0.8359482
## 
## Variabel Laten  Facilitating Conditions 
## [1] 0.8555591
## 
## Variabel Laten  Behavioral Intention 
## [1] 0.9252116
## 
## AVE:
##  Variabel Laten  Perfomance Expectancy 
## [1] 0.7488042
## 
## Variabel Laten  Effort Expectancy 
## [1] 0.7509843
## 
## Variabel Laten  Social Influence 
## [1] 0.7202296
## 
## Variabel Laten  Facilitating Conditions 
## [1] 0.665626
## 
## Variabel Laten  Behavioral Intention 
## [1] 0.7569728
## 
## HTMT Matrix:
##                          Perfomance Expectancy Effort Expectancy
## Perfomance Expectancy                      NA         0.3737800
## Effort Expectancy                   0.3737800                NA
## Social Influence                    0.6172193         0.6160426
## Facilitating Conditions             0.4824333         0.7979404
## Behavioral Intention                0.5167693         0.4471064
##                         Social Influence Facilitating Conditions
## Perfomance Expectancy          0.6172193               0.4824333
## Effort Expectancy              0.6160426               0.7979404
## Social Influence                      NA               0.8150128
## Facilitating Conditions        0.8150128                      NA
## Behavioral Intention           0.6839490               0.7799284
##                         Behavioral Intention
## Perfomance Expectancy              0.5167693
## Effort Expectancy                  0.4471064
## Social Influence                   0.6839490
## Facilitating Conditions            0.7799284
## Behavioral Intention                      NA
## 
##  R Square:
##  Variabel Laten  Perfomance Expectancy 
## [1] NA
## 
## Variabel Laten  Effort Expectancy 
## [1] NA
## 
## Variabel Laten  Social Influence 
## [1] NA
## 
## Variabel Laten  Facilitating Conditions 
## [1] NA
## 
## Variabel Laten  Behavioral Intention 
## [1] 0.5115431
resultbootstrap <- plsalgorithm_bootstrap(data = inputdata$Data,inner_weight_scheme = "Path",matrix_outer_model = inputdata$MOM, matrix_inner_model = inputdata$MIM, indicator = inputdata$Indikator, laten_variables = inputdata$Variabel, n_bootstrap=50)

print(resultbootstrap$path_coefficient)
## [[1]]
## data frame with 0 columns and 0 rows
## 
## [[2]]
## data frame with 0 columns and 0 rows
## 
## [[3]]
## data frame with 0 columns and 0 rows
## 
## [[4]]
## data frame with 0 columns and 0 rows
## 
## [[5]]
##   path_coefficient_original average_path_coefficient standar_error  t_hitung
## 1                0.17984759               0.16642143    0.06576088  2.734872
## 2               -0.05737437              -0.04801611    0.04064532 -1.411586
## 3                0.21005121               0.20546637    0.06606206  3.179604
## 4                0.50697975               0.51153925    0.07514495  6.746691
##        p_value
## 1 6.240454e-03
## 2 1.580719e-01
## 3 1.474763e-03
## 4 1.512546e-11
dfmatrikserror <- as.data.frame(hasil$`Matrix Residual`)
print(head(dfmatrikserror))
##            V1         V2         V3         V4          V5         V6
## 1 -0.08791535 -0.1296811  0.2475975  0.2664125  0.04963479 -0.3805315
## 2 -0.08791535 -0.1296811  0.2475975  0.1304387 -0.01545051 -0.1523294
## 3 -0.08791535 -0.1296811  0.2475975  0.7334609  0.58167623 -1.4280850
## 4  0.28525906  0.2520359 -0.6138829  0.2664125  0.04963479 -0.3805315
## 5 -0.08791535 -0.1296811  0.2475975 -0.3366097 -0.54749195  0.8952241
## 6 -0.08791535 -0.1296811  0.2475975  0.2664125  0.04963479 -0.3805315
##            V7          V8         V9        V10        V11        V12
## 1 -0.29818677  0.53068795 -1.1022605  0.3221855  0.8362000 -0.1498453
## 2  0.50788054 -0.90388342  0.1732348  0.1394588 -0.4239163 -0.1498453
## 3  0.42197524 -0.75099634  0.1732348  0.1394588 -0.4239163 -0.8274396
## 4 -0.02401106  0.04273288  0.1732348  0.1394588 -0.4239163  0.0597423
## 5 -0.38409207  0.68357502 -0.2554121 -0.3441392  0.8381570  0.4425970
## 6 -0.02401106  0.04273288  0.1732348  0.1394588 -0.4239163  0.0597423
##          V13         V14        V15         V16
## 1  0.5135670 -0.51187444  0.1696938 -1.12838771
## 2  0.5135670 -0.51187444  0.1696938 -1.97301066
## 3  0.1230986  0.30880705  0.6908102 -0.19022938
## 4 -0.2329097 -0.06988993  0.3854245  0.12310332
## 5  0.1271362  0.31310191 -1.3945346 -0.42141872
## 6 -0.2329097 -0.06988993  0.3854245  0.04609492
# Jalankan algoritma Kernel K-Means
hasil_kkmeans <- kernel_kmeans(dfmatrikserror, k=2, max_iter = 100, kernel_fun = rbf_kernel, sigma = 1)
## Kernel K-Means konvergen pada iterasi ke- 5
# Tampilkan hasil cluster
print(hasil_kkmeans$clusters)
##   [1] 2 2 2 1 2 1 2 1 1 2 1 1 1 1 2 2 1 2 2 1 2 2 1 2 1 2 2 2 2 1 2 2 1 2 1 2 2
##  [38] 2 2 2 1 1 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 2 2 2 2 2
##  [75] 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 2 2 2 2 2 2 1 1 2
## [112] 1 2 1 2 1 1 2 1 2 2 2 1 2 1 2 2 2 2 1 2 2 2 2 1 2 2 2 2 2 1 2 2 2 2 1 2 2
## [149] 1 1 2 2 2 2 1 2 1 1 2 2 1 1 1 2 1 2 2 2 1 1 2 2 2 2 2 2 2 1 1 2 2 1 1 2 1
## [186] 2 1 1 2 1 1 1 1 2 2 1 2 2 1 2 2 1 2 1 2 2 2 2 2 1 1 1 2 1 2 2 2 2 2 2 2 2
## [223] 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 2 1 1 2 1 2 2 2 1 1 2 2 2 2 2 2 2 1 1 2 2
## [260] 1 1 2 2 1 1 2 1 1 1 2 2 1 2 2 2 2 2 2 1 2 1 1 1 2 1 2 2 2 1 2 1 2 1 1 2 1
## [297] 1 1 1 2 2 1 2 2 1 2 1 2 1 1 1 1 2 2 1 2 2 1 2 2 1 2 1 2 2 2 2 2 1 1 1 2 1
## [334] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 2 2 2 2 2 2 1 1 2
data_matrix=as.matrix(dfmatrikserror)
print(table(hasil_kkmeans$clusters))
## 
##   1   2 
## 121 245
data_terkelompok_kernel <- split(inputdata$Data,hasil_kkmeans$clusters)
hasil_k1=plsalgorithm(data = data_terkelompok_kernel$"1",inner_weight_scheme = "Path",matrix_outer_model = inputdata$MOM, matrix_inner_model = inputdata$MIM, indicator = inputdata$Indikator, laten_variables = inputdata$Variabel)
## Number of Iterasi: 5 
## Outer Weight 
## Variabel Laten  Perfomance Expectancy 
##           [,1]
## [1,] 0.3837338
## [2,] 0.3243786
## [3,] 0.3408206
## 
## Variabel Laten  Effort Expectancy 
##           [,1]
## [1,] 0.3333333
## [2,] 0.3333333
## [3,] 0.3333333
## 
## Variabel Laten  Social Influence 
##           [,1]
## [1,] 0.5319346
## [2,] 0.5102544
## 
## Variabel Laten  Facilitating Conditions 
##           [,1]
## [1,] 0.3428930
## [2,] 0.3295562
## [3,] 0.3484066
## 
## Variabel Laten  Behavioral Intention 
##           [,1]
## [1,] 0.2761567
## [2,] 0.2761567
## [3,] 0.2761567
## [4,] 0.2112467
## 
## Skor Variabel Laten 
## Variabel Laten  Perfomance Expectancy 
##            [,1]
## [1,] -1.0248007
## [2,] -0.4894076
## [3,] -1.6642881
## [4,] -0.4894076
## [5,] -0.4894076
## [6,]  1.4285703
## 
## Variabel Laten  Effort Expectancy 
##            [,1]
## [1,] -0.8075271
## [2,] -0.8075271
## [3,] -0.8075271
## [4,] -0.8075271
## [5,] -0.8075271
## [6,]  1.2281142
## 
## Variabel Laten  Social Influence 
##            [,1]
## [1,] -0.4319952
## [2,] -0.4319952
## [3,] -0.4319952
## [4,] -0.4319952
## [5,] -0.4319952
## [6,]  1.4348411
## 
## Variabel Laten  Facilitating Conditions 
##            [,1]
## [1,] -0.4990059
## [2,] -0.4990059
## [3,] -0.4990059
## [4,] -0.4990059
## [5,] -0.4990059
## [6,]  1.3538611
## 
## Variabel Laten  Behavioral Intention 
##            [,1]
## [1,] -0.4479663
## [2,] -0.4479663
## [3,] -0.4479663
## [4,] -0.4479663
## [5,] -0.4479663
## [6,]  1.1563593
## 
## Koefisien Jalur:
##  Variabel Laten  Perfomance Expectancy 
## NULL
## 
## Variabel Laten  Effort Expectancy 
## NULL
## 
## Variabel Laten  Social Influence 
## NULL
## 
## Variabel Laten  Facilitating Conditions 
## NULL
## 
## Variabel Laten  Behavioral Intention 
##            [,1]
## [1,] 0.01067045
## [2,] 0.03637059
## [3,] 0.20403669
## [4,] 0.76202446
## 
## Outer Loading:
##  Variabel Laten  Perfomance Expectancy 
##           [,1]
## [1,] 0.9584553
## [2,] 0.9528553
## [3,] 0.9480721
## 
## Variabel Laten  Effort Expectancy 
##      [,1]
## [1,]    1
## [2,]    1
## [3,]    1
## 
## Variabel Laten  Social Influence 
##           [,1]
## [1,] 0.9612035
## [2,] 0.9577626
## 
## Variabel Laten  Facilitating Conditions 
##           [,1]
## [1,] 0.9852916
## [2,] 0.9621544
## [3,] 0.9904132
## 
## Variabel Laten  Behavioral Intention 
##           [,1]
## [1,] 0.9908249
## [2,] 0.9908249
## [3,] 0.9908249
## [4,] 0.8479716
## 
## Matriks Residual Gabungan:
##              [,1]       [,2]        [,3]          [,4]          [,5]
## [1,]  0.45409150  0.4062404 -0.89790921  2.220446e-16  2.220446e-16
## [2,] -0.05905885 -0.1039118  0.16539388  2.220446e-16  2.220446e-16
## [3,]  1.06701165 -0.9558438 -0.29162899  2.220446e-16  2.220446e-16
## [4,] -0.05905885 -0.1039118  0.16539388  2.220446e-16  2.220446e-16
## [5,] -0.05905885 -0.1039118  0.16539388  2.220446e-16  2.220446e-16
## [6,]  0.03913683  0.0399560 -0.08209303 -2.220446e-16 -2.220446e-16
##               [,6]        [,7]        [,8]        [,9]       [,10]       [,11]
## [1,]  2.220446e-16 -0.01009154  0.01052032 -0.03279443  0.09586926 -0.05840686
## [2,]  2.220446e-16 -0.01009154  0.01052032 -0.03279443  0.09586926 -0.05840686
## [3,]  2.220446e-16 -0.01009154  0.01052032 -0.03279443  0.09586926 -0.05840686
## [4,]  2.220446e-16 -0.01009154  0.01052032 -0.03279443  0.09586926 -0.05840686
## [5,]  2.220446e-16 -0.01009154  0.01052032 -0.03279443  0.09586926 -0.05840686
## [6,] -2.220446e-16  0.03351833 -0.03494249  0.00805459 -0.02635957  0.01700627
##            [,12]       [,13]       [,14]      [,15]       [,16]
## [1,] -0.08427797 -0.08427797 -0.08427797  0.3305225  0.06073662
## [2,] -0.08427797 -0.08427797 -0.08427797  0.3305225  0.05502373
## [3,] -0.08427797 -0.08427797 -0.08427797  0.3305225  0.06756024
## [4,] -0.08427797 -0.08427797 -0.08427797  0.3305225  0.05502373
## [5,] -0.08427797 -0.08427797 -0.08427797  0.3305225  0.05502373
## [6,]  0.26260809  0.26260809  0.26260809 -1.0299000 -0.22798694
## 
## CR:
##  Variabel Laten  Perfomance Expectancy 
## [1] 0.9675067
## 
## Variabel Laten  Effort Expectancy 
## [1] 1
## 
## Variabel Laten  Social Influence 
## [1] 0.9586644
## 
## Variabel Laten  Facilitating Conditions 
## [1] 0.986001
## 
## Variabel Laten  Behavioral Intention 
## [1] 0.9775146
## 
## AVE:
##  Variabel Laten  Perfomance Expectancy 
## [1] 0.9084701
## 
## Variabel Laten  Effort Expectancy 
## [1] 1
## 
## Variabel Laten  Social Influence 
## [1] 0.9206107
## 
## Variabel Laten  Facilitating Conditions 
## [1] 0.959153
## 
## Variabel Laten  Behavioral Intention 
## [1] 0.9160644
## 
## HTMT Matrix:
##                          Perfomance Expectancy Effort Expectancy
## Perfomance Expectancy                      NA         0.6923501
## Effort Expectancy                   0.6923501                NA
## Social Influence                    0.6849658         0.6076648
## Facilitating Conditions             0.8357941         0.7992708
## Behavioral Intention                0.8034515         0.7705566
##                         Social Influence Facilitating Conditions
## Perfomance Expectancy          0.6849658               0.8357941
## Effort Expectancy              0.6076648               0.7992708
## Social Influence                      NA               0.8360970
## Facilitating Conditions        0.8360970                      NA
## Behavioral Intention           0.8878069               0.9844447
##                         Behavioral Intention
## Perfomance Expectancy              0.8034515
## Effort Expectancy                  0.7705566
## Social Influence                   0.8878069
## Facilitating Conditions            0.9844447
## Behavioral Intention                      NA
## 
##  R Square:
##  Variabel Laten  Perfomance Expectancy 
## [1] NA
## 
## Variabel Laten  Effort Expectancy 
## [1] NA
## 
## Variabel Laten  Social Influence 
## [1] NA
## 
## Variabel Laten  Facilitating Conditions 
## [1] NA
## 
## Variabel Laten  Behavioral Intention 
## [1] 0.9388645
resultbootstrap_k1 <- plsalgorithm_bootstrap(data = data_terkelompok_kernel$"1",inner_weight_scheme = "Path",matrix_outer_model = inputdata$MOM, matrix_inner_model = inputdata$MIM, indicator = inputdata$Indikator, laten_variables = inputdata$Variabel, n_bootstrap=500)
hasil_k2=plsalgorithm(data = data_terkelompok_kernel$"2",inner_weight_scheme = "Path",matrix_outer_model = inputdata$MOM, matrix_inner_model = inputdata$MIM, indicator = inputdata$Indikator, laten_variables = inputdata$Variabel)
## Number of Iterasi: 9 
## Outer Weight 
## Variabel Laten  Perfomance Expectancy 
##           [,1]
## [1,] 0.4240390
## [2,] 0.4527869
## [3,] 0.3042690
## 
## Variabel Laten  Effort Expectancy 
##           [,1]
## [1,] 0.5053360
## [2,] 0.2482742
## [3,] 0.4409510
## 
## Variabel Laten  Social Influence 
##           [,1]
## [1,] 0.8631433
## [2,] 0.2887810
## 
## Variabel Laten  Facilitating Conditions 
##           [,1]
## [1,] 0.3768780
## [2,] 0.5697645
## [3,] 0.3177982
## 
## Variabel Laten  Behavioral Intention 
##           [,1]
## [1,] 0.3509757
## [2,] 0.3486298
## [3,] 0.3012877
## [4,] 0.1576645
## 
## Skor Variabel Laten 
## Variabel Laten  Perfomance Expectancy 
##          [,1]
## [1,] -0.10118
## [2,] -0.10118
## [3,] -0.10118
## [4,] -0.10118
## [5,] -0.10118
## [6,] -0.10118
## 
## Variabel Laten  Effort Expectancy 
##            [,1]
## [1,] -0.5927826
## [2,]  1.3248519
## [3,]  0.5388844
## [4,]  0.1931850
## [5,] -0.9690724
## [6,] -0.5927826
## 
## Variabel Laten  Social Influence 
##             [,1]
## [1,] -1.77242853
## [2,] -1.17860849
## [3,]  0.04094556
## [4,] -0.55287447
## [5,]  0.35381257
## [6,]  0.35381257
## 
## Variabel Laten  Facilitating Conditions 
##            [,1]
## [1,] -1.7966877
## [2,] -0.1039619
## [3,] -0.1039619
## [4,]  0.3915052
## [5,] -0.5736815
## [6,] -0.1039619
## 
## Variabel Laten  Behavioral Intention 
##             [,1]
## [1,] -2.24776698
## [2,] -2.24776698
## [3,] -0.31207207
## [4,] -0.21203489
## [5,]  0.09640565
## [6,]  1.49596720
## 
## Koefisien Jalur:
##  Variabel Laten  Perfomance Expectancy 
## NULL
## 
## Variabel Laten  Effort Expectancy 
## NULL
## 
## Variabel Laten  Social Influence 
## NULL
## 
## Variabel Laten  Facilitating Conditions 
## NULL
## 
## Variabel Laten  Behavioral Intention 
##            [,1]
## [1,]  0.1775119
## [2,] -0.0751141
## [3,]  0.2174542
## [4,]  0.4574628
## 
## Outer Loading:
##  Variabel Laten  Perfomance Expectancy 
##           [,1]
## [1,] 0.8522918
## [2,] 0.8923138
## [3,] 0.7709198
## 
## Variabel Laten  Effort Expectancy 
##           [,1]
## [1,] 0.8635967
## [2,] 0.8048812
## [3,] 0.8249495
## 
## Variabel Laten  Social Influence 
##           [,1]
## [1,] 0.9625411
## [2,] 0.5858731
## 
## Variabel Laten  Facilitating Conditions 
##           [,1]
## [1,] 0.7356745
## [2,] 0.9020437
## [3,] 0.6569828
## 
## Variabel Laten  Behavioral Intention 
##           [,1]
## [1,] 0.9147023
## [2,] 0.8515168
## [3,] 0.9112096
## [4,] 0.6822166
## 
## Matriks Residual Gabungan:
##              [,1]       [,2]     [,3]       [,4]        [,5]       [,6]
## [1,] -0.08131099 -0.1305332 0.307566  0.3837992  0.06882952 -0.4785932
## [2,] -0.08131099 -0.1305332 0.307566  0.2225381  0.04098366 -0.2781073
## [3,] -0.08131099 -0.1305332 0.307566  0.9012971  0.67359415 -1.4121613
## [4,] -0.08131099 -0.1305332 0.307566 -0.2949598 -0.56378098  0.6554607
## [5,] -0.08131099 -0.1305332 0.307566  0.7087619 -1.14392398 -0.1681731
## [6,] -0.08131099 -0.1305332 0.307566  0.3837992  0.06882952 -0.4785932
##             [,7]       [,8]       [,9]      [,10]      [,11]        [,12]
## [1,] -0.10330742  0.3087776 -1.0132096  0.3525524  0.5694953 -0.076867637
## [2,]  0.37556420 -1.1225313  0.2341828  0.1477415 -0.5425965 -0.076867637
## [3,]  0.25214108 -0.7536295  0.2341828  0.1477415 -0.5425965 -0.683617501
## [4,] -0.22673054  0.6776794 -0.1303198 -0.2991915  0.6909520  0.388712982
## [5,] -0.04900629  0.1464759 -0.6666003  0.5714491 -0.2339989  0.106581705
## [6,] -0.04900629  0.1464759  0.2341828  0.1477415 -0.5425965 -0.009765741
##              [,13]       [,14]       [,15]      [,16]
## [1,]  0.4279465131 -0.45597519  0.09617572 -1.0669928
## [2,]  0.4279465131 -0.45597519  0.09617572 -1.8264392
## [3,]  0.0846371074  0.31540639  0.73192149 -0.2149787
## [4,] -0.0005462354  0.22425155 -1.29263448 -0.2384375
## [5,] -0.2631885482 -0.05680242  0.45325120  0.2270752
## [6,] -0.1499713791 -0.06449365  0.47660157  1.4400222
## 
## CR:
##  Variabel Laten  Perfomance Expectancy 
## [1] 0.877539
## 
## Variabel Laten  Effort Expectancy 
## [1] 0.8703872
## 
## Variabel Laten  Social Influence 
## [1] 0.7665277
## 
## Variabel Laten  Facilitating Conditions 
## [1] 0.8127103
## 
## Variabel Laten  Behavioral Intention 
## [1] 0.908082
## 
## AVE:
##  Variabel Laten  Perfomance Expectancy 
## [1] 0.7056476
## 
## Variabel Laten  Effort Expectancy 
## [1] 0.6913916
## 
## Variabel Laten  Social Influence 
## [1] 0.6348664
## 
## Variabel Laten  Facilitating Conditions 
## [1] 0.5955087
## 
## Variabel Laten  Behavioral Intention 
## [1] 0.7143709
## 
## HTMT Matrix:
##                          Perfomance Expectancy Effort Expectancy
## Perfomance Expectancy                      NA         0.2129749
## Effort Expectancy                   0.2129749                NA
## Social Influence                    0.5786560         0.6518371
## Facilitating Conditions             0.2853007         0.7734470
## Behavioral Intention                0.3922148         0.3211511
##                         Social Influence Facilitating Conditions
## Perfomance Expectancy          0.5786560               0.2853007
## Effort Expectancy              0.6518371               0.7734470
## Social Influence                      NA               0.8214224
## Facilitating Conditions        0.8214224                      NA
## Behavioral Intention           0.5747911               0.6840497
##                         Behavioral Intention
## Perfomance Expectancy              0.3922148
## Effort Expectancy                  0.3211511
## Social Influence                   0.5747911
## Facilitating Conditions            0.6840497
## Behavioral Intention                      NA
## 
##  R Square:
##  Variabel Laten  Perfomance Expectancy 
## [1] NA
## 
## Variabel Laten  Effort Expectancy 
## [1] NA
## 
## Variabel Laten  Social Influence 
## [1] NA
## 
## Variabel Laten  Facilitating Conditions 
## [1] NA
## 
## Variabel Laten  Behavioral Intention 
## [1] 0.4021558
resultbootstrap_k2 <- plsalgorithm_bootstrap(data = data_terkelompok_kernel$"2",inner_weight_scheme = "Path",matrix_outer_model = inputdata$MOM, matrix_inner_model = inputdata$MIM, indicator = inputdata$Indikator, laten_variables = inputdata$Variabel, n_bootstrap=500)
resultbootstrap_k1$path_coefficient
## [[1]]
## data frame with 0 columns and 0 rows
## 
## [[2]]
## data frame with 0 columns and 0 rows
## 
## [[3]]
## data frame with 0 columns and 0 rows
## 
## [[4]]
## data frame with 0 columns and 0 rows
## 
## [[5]]
##   path_coefficient_original average_path_coefficient standar_error  t_hitung
## 1                0.01067045               0.01413965    0.06739955 0.1583163
## 2                0.03637059               0.03199431    0.02004987 1.8140064
## 3                0.20403669               0.20368414    0.08712341 2.3419273
## 4                0.76202446               0.76199453    0.11381854 6.6950822
##        p_value
## 1 8.742075e-01
## 2 6.967675e-02
## 3 1.918445e-02
## 4 2.155498e-11
resultbootstrap_k2$path_coefficient
## [[1]]
## data frame with 0 columns and 0 rows
## 
## [[2]]
## data frame with 0 columns and 0 rows
## 
## [[3]]
## data frame with 0 columns and 0 rows
## 
## [[4]]
## data frame with 0 columns and 0 rows
## 
## [[5]]
##   path_coefficient_original average_path_coefficient standar_error  t_hitung
## 1                 0.1775119               0.18588040    0.07788788  2.279069
## 2                -0.0751141              -0.07794092    0.05960726 -1.260150
## 3                 0.2174542               0.22380002    0.08626445  2.520786
## 4                 0.4574628               0.45371741    0.07991712  5.724215
##        p_value
## 1 2.266294e-02
## 2 2.076152e-01
## 3 1.170930e-02
## 4 1.039130e-08