gastonstat / plspm

R package plspm
62 stars 26 forks source link

Issue with pls.groups command #21

Open jameshannay opened 1 year ago

jameshannay commented 1 year ago

I encounter this error while running the pls.groups command:

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

I have removed all NA values and have deleted any observations that hold the same values across all variables. My data is all of the right type (for groups, being a two-level factor). I have addressed these problems due to reading about a similar case here:

https://stackoverflow.com/questions/31685143/hurdle-in-pls-path-modeling

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: https://www.dropbox.com/s/8vewuupywpi1jkt/farmwood_groups%28distance%29.csv?dl=0

Any help would be appreciated. Thank you in advance.