mronkko / matrixpls

R package matrixpls
6 stars 5 forks source link

Error in matrixpls.sempls.R line 200 caused by unequal dimnames length #2

Closed JannicBeck closed 9 years ago

JannicBeck commented 9 years ago

There seems to be an error in matrixpls.sempls.R line 200, 201.

result$total_effects <- cbind(0,t(effects(matrixpls.res)$Total)) colnames(result$total_effects) <- rownames(result$total_effects)

Here is the model in R Code, which produces an error with the matrixpls package but works fine with the semPLS package.

mm <- cbind(c("y1", "y1", "y2", "y2", "y2", "y3", "y3"),            
c("x1", "x2", "x3", "x4", "x5", "x6", "x7"))
colnames(mm) <- c("source", "target")

sm <- cbind(c("y2", "y3"),             
c("y1", "y1"))
colnames(sm) <- c("source", "target")

sigma <- rbind(c(1.0000,0.6200,0.5022000,0.4752000,0.4752000,0.405,0.405),               
c(0.6200,1.0000,0.5022000,0.4752000,0.4752000,0.405,0.405),               
c(0.5022,0.5022,1.0000000,0.7470119,0.7470119,0.000,0.000),               
c(0.4752,0.4752,0.7470119,1.0000000,0.6242442,0.000,0.000),               
c(0.4752,0.4752,0.7470119,0.6242442,1.0000000,0.000,0.000),               
c(0.4050,0.4050,0.0000000,0.0000000,0.0000000,1.000,0.620),               
c(0.4050,0.4050,0.0000000,0.0000000,0.0000000,0.620,1.000))
colnames(sigma) <- mm[, 2]
rownames(sigma) <- colnames(sigma)

X <- as.data.frame(mvrnorm(nobs, rep(0, ncol(sigma)), sigma, empirical = TRUE))
model <- plsm(X, sm, mm)

# works fine
estim.model.sempls <- sempls(model, X)

# Error in `colnames<-`(`*tmp*`, value = rownames(result$total_effects)) : length of 'dimnames' [2] not equal to array extent
estim.model.matrix <- matrixpls.sempls(model, X)
mronkko commented 9 years ago

Fixed in https://github.com/mronkko/matrixpls/commit/b0bd4f7a4f90b8c719022b868ddde30548a2082c

If you decide to update to the github version, note that the documentation is not updated to reflect some recent changes. The 0.6 release, which includes this fixes and a large number of changes, will be out in a month or two.