0

I am trying to perform forward regression based on different classifications that I have in my csv. Is there any possible way to do it? As it's not a linear model I can't just use the lm() function.

I had done many research, but those do not show me how to fit a classification model inside.

This is my code trying to build a classification model:

XBC <- read.csv("C:/Users/SFASi/Desktop/Fusarium Project September/XBC2/XBC(Raw) - Copy.csv")

XBC <- XBC[ -c(1:3) ]
glimpse(XBC)

names <- c(1,2,5,6,8,10)
XBC[,names] <- lapply(XBC[,names],factor)
glimpse(XBC)

set.seed(100)
library(caTools)

spl = sample.split(XBC$Treatment, SplitRatio = 0.7)
train = subset(XBC, spl == TRUE)
test = subset(XBC, spl == FALSE)

print(dim(train));print(dim(test))

model_glm = glm(Treatment~., data = train)
summary(model_glm)
user438383
  • 5,716
  • 8
  • 28
  • 43
Calvin Chow
  • 31
  • 1
  • 4
  • See if these help https://stackoverflow.com/questions/22913774/forward-stepwise-regression https://stackoverflow.com/questions/55821462/how-can-i-perform-a-forward-selection-backward-selection-and-stepwise-regressi – Nad Pat Oct 18 '21 at 06:30

1 Answers1

0

Please provide a reproducible example, we cannot access your .csv file. Nonetheless, you can use the lm() function for non linear models. If we consider a linear model written as model <- lm(y ~ x, data = .), you can also test:

  • a log transformation: model_log <- lm(y ~ log(x), data=.)
  • a polynomial one: model_poly <- lm(y ~ poly(x, degree = n, raw = TRUE) n to be defined. when raw = TRUE, it uses raw and not orthogonal polynomials
  • etc. Then, you can access your lm() model with for example summary(model).
Mata
  • 538
  • 3
  • 17