Consistent Error Message in plspm.group Application

Hi there,

I am looking for some help in resolving an error using the partial least squares path modeling package ('plspm').

I can get results running a basic PLS-PM analysis but run into issues when using the grouping function, receiving the error message:

Error in if (w_dif < specs$tol || iter == specs$maxiter) break :
missing value where TRUE/FALSE needed

I have no missing values and all variables have the proper classification. Elsewhere I have noticed that there is a problem with processing observations with the exact same values across all variables, I have deleted those and still face this issue. I seem to be facing the issue only when I run the groups using the "bootstrap" method as well.

Any help would be appreciated. Thank you in advance

If this evaluates to FALSE, I'd expect the message. Hard to tell without a reprex. See the FAQ.

Hello! Sorry for not including code.

Below is my code and a link to my dataset

farmwood = read.csv("farmwood_groups(distance).csv", header = TRUE) %>%

slice(-c(119:123))

Control = c(0,0,0,0,0,0)
Normative = c(0,0,0,0,0,0)
B_beliefs = c(0,0,0,0,0,0)
P_control = c(1,0,0,0,0,0)
S_norm = c(0,1,0,0,0,0)
Behavior = c(0,0,1,1,1,0)


farmwood_path = rbind(Control, Normative, B_beliefs, P_control, S_norm, Behavior)

colnames(farmwood_path) = rownames(farmwood_path)

farmwood_blocks = list(14:18,20:23,8:13,24:27,19,4:7)
farmwood_modes = rep("A", 6)

farmwood_pls = plspm(farmwood, farmwood_path, farmwood_blocks, modes = farmwood_modes)

names(farmwood)[names(farmwood) == "QB3"] <- "Distance"

farmwood$Distance <- as.factor(farmwood$Distance)

distance_boot = plspm.groups(farmwood_pls, farmwood$Distance, method = "bootstrap")

distance_perm = plspm.groups(farmwood_pls, farmwood$Distance, method = "permutation")

Data: Dropbox - farmwood_groups(distance).csv - Simplify your life

Thanks for the reprex. I've found the problem(s) but couldn't fix. I had to get {plspm} from github since the package was taken off CRAN active after a long period of silence from the developer. It doesn't look to have been touched for years. You might want to check {pls} as an alternative. Or make sure that the methodology is right by reviewing this.

Here are my notes:

error comes from get_weights.R

    w_new = rowSums(W)                
    w_dif = sum((abs(w_old) - abs(w_new))^2) 
    # when 1e-06 reached or after 100 iterations
    if (w_dif < specs$tol || iter == specs$maxiter) break

W is defined in this block

# outer design matrix 'ODM' and matrix of outer weights 'W'
  ODM = list_to_dummy(blocks)
  W = ODM %*% diag(1/(apply(X %*% ODM, 2, sd)*sdv), lvs, lvs)

blocks is the third positional argument to plspm(), set to farmwood_block as a list, as required

list of vectors with column indices or column names from Data indicating the sets of manifest variables forming each block (i.e. which manifest variables correspond to each block).

and X is

  X = get_treated_data(MV, specs) # specs is returned internally

where MV

  MV = get_manifests(Data, blocks)

where Data is farmwood ands blocks is farmwood_blocks.
specs however is supposed to derive from

However ODW and X are non-conformable

dim(ODM)
#[1] 24  6
dim(farmwood)
#[1] 118  33

and `%*%` requires the number of columns of one to equal the number of rows of the other.

That's even before considering that `farmwood` is a `data.frame` and not a `matrix`, but after converting and making conformable (number of rows of one equals the number of columns of the other), 

apply(X %*% ODM, 2, sd)

evaluates to `NA`, which will spoil everything to follow, since rowSums(X) will be NA so the expression

w_dif - specs$tol || iter == specs$maxiter


evaluates to `TRUE` (`NA || something`)

Here are the examples from `help(plspm)` that *don't* throw this error, but I can't spot what differs.

library(plspm)
library(turner) # missing dependency
data(satisfaction)

path matrix

IMAG = c(0,0,0,0,0,0)
EXPE = c(1,0,0,0,0,0)
QUAL = c(0,1,0,0,0,0)
VAL = c(0,1,1,0,0,0)
SAT = c(1,1,1,1,0,0)
LOY = c(1,0,0,0,1,0)
sat_path = rbind(IMAG, EXPE, QUAL, VAL, SAT, LOY)

innerplot(sat_path) # plot diagram of path matrix

sat_blocks = list(1:5, 6:10, 11:15, 16:19, 20:23, 24:27) # blocks of outer model

sat_mod = rep("A", 6) # vector of modes (reflective indicators)

satpls = plspm(satisfaction, sat_path, sat_blocks, modes = sat_mod,
scaled = FALSE)

innerplot(satpls) # plot diagram of the inner model

outerplot(satpls, what = "loadings") # plot loadings

outerplot(satpls, what = "weights") # plot outer weights

satpls

group_perm = plspm.groups(satpls, satisfaction$gender, # permutation test with 100 permutations

                      method="permutation", reps=100)

group_perm


(plots omitted)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.