R/scopeExpSyst.R

`.scopeExpSyst` <-
function(varNames, varTypes, mod)
{
    i <- 1
    junk2 <- c()
    while(i <= length(varNames)) {
        
        vname <- varNames[i]
	      
        if(mod=="NNET" | mod=="FDA" | mod=="GLMs" | mod=="CTA" | mod=="GBM") junk <- vname
        if(mod == "GLMq") {
            if(varTypes[i] %in% c('numeric','integer'))      junk <- paste(vname, "+I(", vname, "^2)+I(",vname, "^3)", sep="")
            else if(varTypes[i] == 'factor')  junk <- vname
        }
        if(mod == "GLMp") {
            if(varTypes[i] %in% c('numeric','integer'))     junk <- paste(vname, "+I(", vname, "^2)+I(",vname, "^3)+", "poly(", vname, ",2) + poly(", vname, ",3)", sep="")
            else if(varTypes[i] == 'factor') junk <- vname
        }
        junk2 <- c(junk2, junk)
        i <- i + 1
    }

    junk2 <- eval(parse(text=paste("~", paste(junk2, collapse="+"))))
    return(junk2)
}


# `.scopeExpSyst` <-
# function(enviroTrain, mod)
# {
#     i <- 1
#     junk2 <- c()
#     while(i <= dim(enviroTrain)[2]) {
#         
# 	      vname <- names(enviroTrain)[i]
# 	      
#         if(mod=="NNET" | mod=="FDA" | mod=="GLMs" | mod=="CTA" | mod=="GBM") junk <- vname
#         if(mod == "GLMq") {
#             if(is.numeric(enviroTrain[,i]))      junk <- paste(vname, "+I(", vname, "^2)+I(",vname, "^3)", sep="")
#             else if(is.factor(enviroTrain[,i]))  junk <- vname
#         }
#         if(mod == "GLMp") {
#             if(is.numeric(enviroTrain[,i]))     junk <- paste(vname, "+I(", vname, "^2)+I(",vname, "^3)+", "poly(", vname, ",2) + poly(", vname, ",3)", sep="")
#             else if(is.factor(enviroTrain[,i])) junk <- vname
#         }
#         junk2 <- c(junk2, junk)
#         i <- i + 1
#     }
# 
#     junk2 <- eval(parse(text=paste("~", paste(junk2, collapse="+"))))
#     return(junk2)
# }

Try the BIOMOD package in your browser

Any scripts or data that you put into this service are public.

BIOMOD documentation built on May 2, 2019, 6:48 p.m.