matrixpls.plspm error message

83 views
Skip to first unread message

Kim Benny

unread,
Sep 18, 2016, 12:24:39 PM9/18/16
to lavaan
R studio say
"
Loading required namespace: boot
Loading required namespace: parallel
Error in W[row, params$outer[[row]]] : subscript out of bounds...
"

I traced  into the function,  matrixpls.plspm and into get_params(...)... 
in that case error message turns out to ...
"
Error in get_params(x = Data, path_matrix, outer = blocks, modes = modes,  : 
  argument "Data" is missing, with no default...
"
For your decision, 
I write code like as 
...
########################################
##path matrix for model 5 constructs 
library(plspm)
library(matrixpls)
library(plsdepot)  ## For hierarchical latent models of the two-step(patch) approach
library(ggplot2)
library(reshape2)

cores <- getOption("mc.cores")
options(mc.cores=2)
  
autonomy1    = c(0,0,0,0,0)
competence1  = c(0,0,0,0,0)
relatedness1 = c(0,0,0,0,0)
enjoyment1   = c(1,1,1,0,0) ## second order construct
future_play1 = c(0,0,0,1,0)

# data for inner model
switch_inner1 <- rbind(autonomy1, competence1, relatedness1, enjoyment1, future_play1)
colnames(switch_inner1) <- rownames(switch_inner1)
innerplot(switch_inner1)
# data for outer model
switch_outer1 <- list(18:20, 21:23, 24:26, 18:26, c(37, 38))

sw_modes1 <- rep("A", 5)  ## all latent variables are measured in a reflective way
sw_pls1 <- plspm.res <- plspm(switch_data, switch_inner1, switch_outer1, modes = sw_modes1, boot.val = T, br = 200)

sw_pls1$unidim
sw_pls1$outer_model
sw_pls1$inner_summary
sw_pls1$gof
##
# data for factor scores 
s1_pca.autonomy = nipals(switch_data[,18:20])
s1_pca.competence = nipals(switch_data[,21:23])
s1_pca.relatedness = nipals(switch_data[,24:26])

s1.autonomy.Score = s1_pca.autonomy$scores[,1]
s1.competence.Score = s1_pca.competence$scores[,1]
s1.relatedness.Score = s1_pca.relatedness$scores[,1]
s1_pca.enjoyment = cbind(s1.autonomy.Score, s1.competence.Score, s1.relatedness.Score)

# second step, inner model
s2.inner_model = rbind(autonomy1, competence1, relatedness1, enjoyment1, future_play1)
colnames(s2.inner_model) <- rownames(s2.inner_model)
#innerplot(s2.inner_model)
# second step outer model, blocks
# sw_blocks_2step = list(1:3, 4:6, 7:9, 22:24, 10:12, 13:15, 16:17, 25:27, 20:21)
s2.switch_data = cbind(switch_data[,18:38], s1_pca.enjoyment)
s2.outer_model = list(1:3, 4:6, 7:9, 22:24, 20:21)

# all latent variables are measured in a reflective way
sw_modes = rep(c("A"), 5)
plspm.res <- plspm(s2.switch_data, s2.inner_model, s2.outer_model, sw_modes, boot.val = T, br = 200)
summary(plspm.res)

#matrixpls with interim data of plspm style
matrixpls.res <- matrixpls.plspm(s2.switch_data, s2.inner_model, s2.outer_model, sw_modes, scaled = FALSE, boot.val = FALSE)
########################################
Last line is the error code line, above 5 lines from that is a no-problem plspm function applying.
Now if possible, I want to use matrixpls-type cfa model to use antecedent plspm model.

You experienced and experts! Pls help me.
Where should I shovel this entangled?  

Mikko Rönkkö

unread,
Sep 18, 2016, 1:20:36 PM9/18/16
to lav...@googlegroups.com
Hi

I am not sure what you mean by "matrixpls-type cfa model”. Matrixpls is a collection of algorithms for calculating composites (weighted sums) of indicators and then using these in regression. If you want to do CFA, then you can do that with Lavaan. 

I tried your code, but I could not run it because I do not have the switch_data dataset. If you can send me (privately, not through the list)  the data or a small part of it, I can test to see what the problem is. 

matrixpls.plspm is a wrapper whose main purpose is testing the package. For end users, using the matrixpls function directly is a lot better option because it exposes more features and is a lot more computationaly efficient (i.e. faster). 

Mikko

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages