[R-sig-Geo] Coding and addition of explanatory variables

Roger Bivand Roger@B|v@nd @end|ng |rom nhh@no
Tue Jun 9 16:28:33 CEST 2020


On Tue, 9 Jun 2020, Julian Burgos wrote:

> Very hard to say without a reproducible example.  But perhaps "DVI1" is 
> not in your "Trainingset" dataframe?

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


>
>
> ________________________________
> From: R-sig-Geo <r-sig-geo-bounces using r-project.org> on behalf of Enoch Gyamfi Ampadu <egampadu using gmail.com>
> Sent: Tuesday, June 9, 2020 14:06
> To: Help R-Sig_Geo <r-sig-geo using r-project.org>
> Subject: [R-sig-Geo] Coding and addition of explanatory variables
>
> 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
>
> --
> *Enoch Gyamfi - Ampadu*
>
> *Geography & Environmental Sciences*
>
> *College of Agriculture, Engineering & Science*
>
> *University of KwaZulu-Natal, Westville Campus*
>
> *Private Bag X54001*
> *Durban, South Africa **� 4000**.*
> *Phone: +27 835 828255*
>
> *email: egampadu using gmail.com <egampadu using gmail.com>*
>
>
> *skype: enoch.ampadu*
> *The highest evidence of nobility is self-control*.
>
> *A simple act of kindness creates an endless ripple*.
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=02%7C01%7C%7C040a519515414dcf4ff508d80c7e6133%7C8e105b94435e4303a61063620dbe162b%7C0%7C0%7C637273084221502390&sdata=yL%2BLWXZWZ0EaUNEXxLXpWnkkOgKeMriuuuJR47MUIhI%3D&reserved=0
>
> 	[[alternative HTML version deleted]]
>
>

-- 
Roger Bivand
Department of Economics, Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; e-mail: Roger.Bivand using nhh.no
https://orcid.org/0000-0003-2392-6140
https://scholar.google.no/citations?user=AWeghB0AAAAJ&hl=en


More information about the R-sig-Geo mailing list