plspm icon indicating copy to clipboard operation
plspm copied to clipboard

Possible bug in get_weights_nonmetric() for factorial scheme

Open guilhemchalancon opened this issue 12 years ago • 0 comments

Hi Gaston,

In get_weights_nonmetric() [as of 30aaec0a44b5c8be7bc24ef48dcf8283ce6b80f2], the computation of inner weights seems to fail when using the factorial scheme. I have pasted an example code at the end for you to reproduce the error.

Straight to the point, the reason is that the label for factorial is wrong in get_weights_nonmetric().

    # =============================================================
    # updating inner weights
    # =============================================================
    E <- switch(specs$scheme, 
                "centroid" = sign(cor(Y) * link),
                "factor" = cov(Y) * link,
                "path" = get_path_scheme(path_matrix, Y))
    # internal estimation of LVs 'Z'
    Z = Y %*% E

Here, switch is used to choose between the 3 possible schemes, expect it searches for factor rather than factorial.

The corrected line should thus be:

switch(specs$scheme, 
"centroid" = sign(cor(Y) * link), 
"factorial" = cov(Y) * link,
"path" = get_path_scheme(path_matrix, Y))

And here is an example code:

data(russa)
rus_path = rbind(c(0, 0, 0), c(0, 0, 0), c(1, 1, 0))
rownames(rus_path) = c("AGRI", "IND", "POLINS")
colnames(rus_path) = c("AGRI", "IND", "POLINS")
rus_blocks = list(1:3, 4:5, 6:9)
rus_scaling = list(c("NUM", "NUM", "NUM"),
                   c("NUM", "NUM"),
                   c("NUM", "NUM", "NUM", "NUM"))
rus_modes = rep("A", 3)
example = plspm(russa, rus_path, rus_blocks, scaling = rus_scaling, modes = rep("PLSCOW",3), scheme = "factorial")

which gives 'Error during wrapup: requires numeric/complex matrix/vector arguments'

Cheers, G

guilhemchalancon avatar Mar 23 '14 19:03 guilhemchalancon