I am using the function StepReg::stepwise() to carry out a stepwise analysis. I aim at estimating a model without the constant, because I am running a dynamic model with variables in first differences. I have already created a “dataset” object where I stored my dataset with variable in first differences, computed using dyplr::mutate(). Following the StepReg::stepwise() documentation (https://cran.r-project.org/web/packages/StepReg/StepReg.pdf), it is possibile to allow for no constant typing either ‘0’ or ‘-1’ in the ‘formula =’ option (the documentation says: “By default, an intercept term is always included in the models, to exclude it, include ’0’ or ’- 1’ in your formula: ’y ~ 0 + x1’, ’y ~ x1 + 0’, and ’y ~ x1-1’”). The option I am specyfing are:
formula <- dy ~ 0 + dx1 + dx2 + dx3 + dx4 + ... + xK
res <- stepwise(formula = formula,
data = df,
sle = 0.15,
sls = 0.1,
type = "linear",
#include = c("Prova1", "Prova2", "Prova3", "Prova4", "Prova5", "Prova6"),
strategy = c('bidirection'),
metric = c("AICc", "adjRsq"))
The error I encounter is : “Error in checkEnterOrRemove(add_or_remove, best_candidate_model, type, :
‘BREAK’ object not found.
How can I fix this? Am I encountering a bug?
I have already tried to type both “0” and “-1” in the formula.
Gianluca Sala is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.