Skip to content

Coding and addition of explanatory variables

3 messages · Enoch Gyamfi Ampadu, Julian Burgos, Roger Bivand

#
Dear List,

Please I am doing a biomass analysis with a satellite image. The
explanatory variables include the satellite bands and vegetation indices. I
am using Random forest regression. I have added bands of the satellite
image to the model and it worked. However, when I tried to add the
vegetation indices (bands) I get error messages. I have put the codes I am
using below;

Model <- randomForest(class~ B1 + B2 + B3 + B4 + B5 + B6 + B7 + B8 + B9 +
B10 + B11 + B12 + DVI1, data = Trainingset, proximity=TRUE,
                            importance=TRUE).
The "DVI1" is the vegetation index variable band I tried to add to the
model.

Below is the error message I received.

"Error in eval(predvars, data, env) : object 'DVI1' not found"

   I will be glad if I could get some assistance on how to resolve it.

Best regards,

Enoch
#
Very hard to say without a reproducible example.  But perhaps "DVI1" is not in your "Trainingset" dataframe?
#
On Tue, 9 Jun 2020, Julian Burgos wrote:

            
Thanks, here is a code example:

library(randomForest)
data(airquality)
set.seed(131)
ozone.rf1 <- randomForest(Ozone ~ Solar.R + Wind + Temp + Month + Day, 
data=airquality, proximity=TRUE, importance=TRUE, na.action=na.omit)
print(ozone.rf1)
set.seed(131)
ozone.rf2 <- randomForest(Ozone ~ Solar.R + Wind + Temp + Month + day, 
data=airquality, proximity=TRUE, importance=TRUE, na.action=na.omit)
# Error in eval(predvars, data, env) : object 'day' not found

Concise code examples always help to tease out problems,

Roger