1

I am solving a question related to my course. the question is:

Run linear model using training data with “Florence” as outcome variable, while using “Gender”, “FirstPurch”, and “all book categories” as predictors and give the summary of the model. Can you specify the significant predictors?

I have already created the training data.

here is my attempt:

reg= lm(Florence~.-c(Seq.,ID.,M,R, F), data = train.df)

I decided to remove those variables. see the table for details:

enter image description here

Let me know why I cannot use -c(name of the columns)

Phil
  • 7,287
  • 3
  • 36
  • 66
Riddle2795
  • 49
  • 6
  • Simply because the formula syntax for `lm()` in R doesn't allow for it. – Phil Oct 03 '22 at 20:29
  • But what if you have 19 variables to enter. it takes time to enter all of them by using +. Thank you for commenting. – Riddle2795 Oct 03 '22 at 20:46
  • 1
    You could first use `dplyr::select()` to create a reduced copy of the data frame (which allows for those kinds of shortcuts), and then use `y ~ .`. – Phil Oct 03 '22 at 20:52
  • or use `setdiff(names(df), c("..."))` + `reformulate()` – Ben Bolker Oct 03 '22 at 21:26

0 Answers0