I keep getting the following error, does anyone know why? Error in rangerCpp(treetype, x, y.mat, independent.variable.names, mtry, : Not compatible with requested type: [type=closure; target=double].

Rf model inputs

(outcome <- "age")
(vars <- c("shucked_wt", "length", "diameter", "viscera_wt", "shell_wt"))
(fmla <- paste(outcome, "~", paste(vars, collapse = " + ")))

#Abalone model rf
(abalone_model_rf <- ranger(fmla, data = abalone, num.trees = 500, respect.unordered.factors = "order", seed = set.seed))

I think you missed one step. Your fmla variable is a string actually.
Try fmla <- as.formula(fmla)

I know nothing about the ranger() function but I notice that the call ends with seed = set.seed. Since there is a function named set.seed, I suggest you try seed = set.seed()

abalone_model_rf <- ranger(fmla, data = abalone, num.trees = 500, 
        respect.unordered.factors = "order", seed = set.seed())

Awesome. Thank you! The fmla tip worked.

This topic was automatically closed 21 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.