Error in seq.int(min(dim(R))) : 'from' must be a finite number

Hello, I really need help, I am using R package "gfoRmula", but got the error "Error in seq.int(min(dim(R))) : 'from' must be a finite number". I don't know what to do.
This is my R code and results.

#R code#
install.packages("gfoRmula")
install.packages("devtools")
devtools::install_github("CausalInference/gfoRmula")

install.packages("dplyr")
install.packages("data.table")
install.packages("readxl")

library(gfoRmula)
library(devtools)
library(dplyr)
library(data.table)
library(readxl)

Pbcd002f <- read_excel("C://Users//Pbcd002f.xls")

#Multiple exposures: (pbcd) g_form

as.data.frame(Pbcd002f)

obs_data <- Pbcd002f %>%
mutate(L3 = as.factor(L3), # time-fixed variables
L4 = as.factor(L4),
L1 = as.integer(L1), # time-varying variables
L5 = as.factor(L5),
L7 = as.factor(L7),
L8 = ifelse(test = L8 == 2, yes = 1, no = L8),
L8 = as.integer(L8),
Y3 = as.integer(Y3))

str(obs_data)

Time-fixed covariates

table(obs_data$L3)
table(obs_data$L4)

Time-fixed covariates

table(obs_data$L1)
plot(density(obs_data$L2))#BMI
table(obs_data$L5)
table(obs_data$L7)
table(obs_data$L8)
plot(density(log(obs_data$E1)))
plot(density(log(obs_data$E2)))
summary(obs_data$E1)
summary(obs_data$E2)

id <- 'ID'
time_points <- 7
time_name <- 'T0'
outcome_name <- 'Y3'
outcome_type <- 'binary_eof'
bascovs <- c('L3','L4','L6')
histvars <- list(c('L1','L2','L5','L7','L8','E1','E2'),
c('L2','E1','E2'))
covnames <- c('L1', 'L2', 'L5', 'L7', 'L8', 'E1', 'E2')

covtypes<-c('categorical','normal','categorical','categorical','categorical','normal','normal') # The variable 'L1' is binary

covtypes <- c('binary','normal','categorical','categorical','binary','normal','normal')
covparams <- list(covmodels = c(L1 ~ L3 + L4 + L6 + T0 + lag1_L1,
L2 ~ L3 + L4 + L6 + T0 + lag1_L1 + lag_cumavg1_L2,
L5 ~ L3 + L4 + L6 + T0 + lag1_E1 + lag1_E2 + lag1_L5, # The time ordering between variables should be considered
L7 ~ L3 + L4 + L6 + T0 + L5 + lag1_E1 + lag1_E2 + lag1_L5 + lag1_L7, # The time ordering between variables should be considered
L8 ~ L3 + L4 + L6 + T0 + L1 + lag1_L8,
E1 ~ L3 + L4 + L6 + T0 + lag1_L1 + lag1_L8 + lag_cumavg1_E1 + lag_cumavg1_E2,
E2 ~ L3 + L4 + L6 + T0 + lag1_L1 + lag1_L8 + lag_cumavg1_E1 + lag_cumavg1_E2),
covlink = c('logit','identity','logit','logit','logit','identity','identity')) # The argument 'covlink' should be included in the object 'covparams'

ymodel <- Y3 ~ E1 + E2 + L1 + L2 + L5 + L7 + L8 +
lag1_L1 + lag_cumavg1_L2 + lag1_L5 + lag1_L7 + lag1_L8 +
lag_cumavg1_E1 + lag_cumavg1_E2 +
L3 + L4 + L6 + T0
intvars <- list(c('E1', 'E2'), c('E1', 'E2'))
interventions <- list(list(c(static, rep(x = 0.9187, times = time_points)),
c(static, rep(x = 1.6, times = time_points))),
list(c(static, rep(x = 5, times = time_points)),
c(static, rep(x = 30, times = time_points)))) # A type of interventions should be specified

gform_basic <- gformula(
obs_data = obs_data %>% as.data.table(),
id = id,
time_points = time_points,
time_name = time_name,
outcome_type = outcome_type,
outcome_name = outcome_name,
ymodel = ymodel,
covnames = covnames,
basecovs = bascovs,
histories = c(lagged,lagavg),
histvars = histvars,
covtypes = covtypes,
covparams = covparams,
intvars = intvars,
interventions = interventions,
int_descript = c("General concentration","High concentration"),
ref_int = 0,
nsimul=26070,
ci_method = "percentile",
nsamples=1000,
model_fits = TRUE,
seed = 20230815
)

#Results#
Error in seq.int(min(dim(R))) : 'from' must be a finite number
In addition: Warning messages:
1: glm.fit: The fitted probability values ​​are 0 or 1
2: In predict.lm(object, newdata, se.fit, scale = 1, type = if (type == :
prediction from rank-deficient fit; attr(, "non-estim") has doubtful cases
3: In predict.lm(object, newdata, se.fit, scale = 1, type = if (type == :
prediction from rank-deficient fit; attr(
, "non-estim") has doubtful cases
4: In predict.lm(object, newdata, se.fit, scale = 1, type = if (type == :
prediction from rank-deficient fit; attr(*, "non-estim") has doubtful cases
5: glm.fit: The fitted probability values ​​are 0 or 1
6: In min(dim(R)) : no non-missing arguments to min; returning Inf

How does

min(dim(obs_data))

evaluate?

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.