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)
```