Consistent error message while running grouping analysis in 'plspm' package - r

I am looking for some help in resolving an error using the partial least squares path modeling package ('plspm').
I can get results running a basic PLS-PM analysis but run into issues when using the grouping function, receiving the error message:
Error in if (w_dif < specs$tol || iter == specs$maxiter) break : missing value where TRUE/FALSE needed
I have no missing values and all variables have the proper classification. Elsewhere I read that there is a problem with processing observations with the exact same values across all variables, I have deleted those and still face this issue. I seem to be facing the issue only when I run the groups using the "bootstrap" method as well.
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)
ames(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")
The data is contained here:
https://www.dropbox.com/s/8vewuupywpi1jkt/farmwood_groups%28distance%29.csv?dl=0
Any help would be appreciated. Thank you in advance

Related

Error in makebin(data, file) : 'sid' invalid (order)

When trying to use the cSPADE algorithm from the arulesSequences package in R I always receive the following error:
Error in makebin(data, file) : 'sid' invalid (order)
I think the problem is related to the arrangement of the data somehow but I really don't know what the problem may be.
A similar problem was presented here but the solution that I tried to incorporate by using
arrange(sessions#itemsetInfo,sequenceID,eventID)
did not change anything. Thanks for your help!
#This is how I pre-processed the data
load("example.Rda")
example.Rda %>% head(5) %>% knitr::kable()
str(example.Rda)
example.Rda = as.data.frame(example.Rda)
sessions <- as(example.Rda %>% transmute(items = question_type), "transactions")
transactionInfo(sessions)$sequenceID <- example.Rda$user_id
transactionInfo(sessions)$eventID <- example.Rda$item_id
itemLabels(sessions) <- str_replace_all(itemLabels(sessions), "items=", "")
inspect(head(sessions,10))
arrange(sessions#itemsetInfo,sequenceID,eventID)
str(sessions)
View(sessions)
#This is the definition of the itemsets after which the error occurs
itemsets <- cspade(sessions,
parameter = list(support = 0.001),
control = list(verbose = FALSE))

R error "attempt to select less than one element in get1index"

I need to estimate some parameters in gp model so I install "kergp" package in R to generate a customized kernel. When I use "mle" function to estimate parameters, I get the error as below:
Error in fitList[[bestIndex]] : attempt to select less than one element in get1index
Here is the code:(where initial_data is a dataframe.)
q4<-q1CompSymm(af, input = "af", cov = "corr", intAsChar = TRUE)
quan<-covTP(k1Fun1 = k1Fun1PowExp,d = 4,cov = "homo",
iso1 = 0,parLower = c(rep(0,9)), parUpper = c(2,2,2,2,Inf,Inf,Inf,Inf,Inf))
inputNames(quan)<-c("hl","hn1","hn2","hn3")
kernel<-covComp(formula = ~quan()*q4())
mle(kernel,
parCovIni = c(rep(0.5,10)),
initial_data$y,select(initial_data,-c('index','y','iw','rts')), F = NULL,
parCovLower = c(rep(0,10)),
parCovUpper = c(2,2,2,2,Inf,Inf,Inf,Inf,Inf,1),
noise = TRUE, varNoiseIni = var(initial_data$y) / 10,
optimFun = "stats::optim",
optimMethod = "BFGS")
I had seen the related document from github(https://github.com/cran/kergp/blob/master/R/methodMLE.R) but still couldn't figure out how this situation happen...
Besides, this error occurred after some iterations if there are any help. Any help would be appreciated. Thanks

Error while using tm1r to send dataset. How to debug this issue?

I am currently developing a database integrated forecasting tool for a costumer. I am using mainly R and TM1 Persepctives. To connect R with tm1 I use tm1r. For Data import from tm1 to r it works fine.
However, when I am trying to write back the calculated forecast from R to tm1, I run into problems.
I will give you some reprex data, so you can have a look at the output. If I use "tm2_send_data" instead of "tm1_send_dataset" it works fine too.
The latter function gives me the Error :
"Error in if (is.character(txt) && length(txt) == 1 && nchar(txt, type = "bytes") < :
missing value where TRUE/FALSE needed"
I have no clue, what this is supposed to mean! I tried some formatting of the data types, without any effect.
library(tm1r)
# data
values <- data.frame(fake_values =
c(105,147,159,232,312,337,285,188,257,10,98,27)
)
date_stamps <- c("2021001","2021002","2021003","2021004","2021005","2021006","2021007","2021008","2021009","2021010","2021011","2021012")
rownames(values) = date_stamps
# Send dataset to TM1
con_obj <- tm1_connection("localhost", "8840", "test_admin", "")
tm1_send_dataset(
con_obj,
valueset = values, cube = "pvl_FORECAST_HILFSWÜRFEL",
rowdim = "PVL_test_Zeit", coldim = "pvl_Produkt",
titledim1 = "DATENART", titleel1 = "FC",
titledim2 = "Version", titleel2 = 'Version_Bearbeitung',
titledim3 = "FC-Scheibe", titleel3 = "ML_FC_2021",
titledim4 = "PVL_test_Kunde", titleel4 = "MGR_domestic_D",
titledim5 = "PVL_test_Measure", titleel5 = "Menge_EA"
)

Problems formating data (biomod2)

I keep running into an error while trying to run the BIOMOD_FormatingData()-function.
I have checked through all arguments and removed any NA-values, the explanatory variables are the same for both the testing and training datasets (independent datasets), and I've generated pseudo-absence data for the evaluation dataset (included in eval.resp.var).
Has anyone run into this error before? and if so, what was the issue related to? This is my first time using Biomod2 for ensemble modelling and I've run out of ideas as to what could be causing this error!
Here is my script and the subsequent error:
library(biomod2)
geranium_data <-
BIOMOD_FormatingData(
resp.var = SG.occ.train['Geranium.lucidum'],
resp.xy = SG.occ.train[, c('Longitude', 'Latitude')],
expl.var = SG.variables,
resp.name = "geranium_data",
eval.resp.var = SG.test.data['Geranium.lucidum'],
eval.expl.var = SG.variables,
eval.resp.xy = SG.test.data[, c('Longitude', 'Latitude')],
PA.nb.rep = 10,
PA.nb.absences = 4650,
PA.strategy = 'random',
na.rm = TRUE
)
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= geranium_data Data Formating -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Response variable name was converted into geranium.data
> Pseudo Absences Selection checkings...
> random pseudo absences selection
> Pseudo absences are selected in explanatory variablesError in `names<-`(`*tmp*`, value = c("calibration", "validation")) : incorrect number of layer names

Clustering by M3C package : Error in `[.data.frame`(df, neworder2) : undefined columns selected

I had a similar problem to what posted here. To resolve the issue, followed the answer by #Jack Gisby there. Now a new error showed up:
Working on TCGA data , I am getting the same error (first error):
Error in `.rowNamesDF<-`(x, value = value) :
duplicate 'row.names' are not allowed
running duplicated() on each relevant field returned FALSE.
Her is the second error (just after trimming identifiers to not start with a common string like "TCGA-"):
Error in `[.data.frame`(df, neworder2) : undefined columns selected
> traceback()
5: stop("undefined columns selected")
4: `[.data.frame`(df, neworder2)
3: df[neworder2]
2: M3Creal(as.matrix(mydata), maxK = maxK, reps = repsreal, pItem = pItem,
pFeature = 1, clusterAlg = clusteralg, distance = distance,
title = "/home/christopher/Desktop/", des = des, lthick = lthick,
dotsize = dotsize, x1 = pacx1, x2 = pacx2, seed = seed, removeplots = removeplots,
silent = silent, fsize = fsize, method = method, objective = objective)
1: M3C(pro.vst, des = clin, removeplots = FALSE, iters = 25, objective = "PAC",
fsize = 8, lthick = 1, dotsize = 1.25)
I've added to an opened issue on the M3C GitHub.
I got the same error as Hamid Ghaedi while running M3C. I managed to track it down to the following line of code (line 476 on the M3C.R file):
df <- data.frame(m_matrix)
Many of my sample names (column names) started with a number and the data.frame() function added an "X" to the beginning of each name that started with a number ("1" becomes "X1"). This caused a mismatch with the names listed in neworder2.
To get around this problem, I changed all of my sample names to start with a letter and M3C is now running correctly.
Edit: This workaround can be easily applied by using the data.frame() function on your input dataset before running M3C.

Resources