I'm following along with a "learn R" course, and we ran the following multiple linear regression:
regressor = lm(formula = Profit ~ ., data = training_set)
Then a bit later, we added some columns to a different data set:
dataset$Level2 = dataset$Level^2
dataset$Level3 = dataset$Level^3
dataset$Level4 = dataset$Level^4
And ran identical line...
regressor = lm(formula = Profit ~ ., data = training_set)
And somehow now lm knows not to fit a multiple regression linear line?
It's modifying the original data set before it's even passed into lm, so unless lm is somehow trying to interpret my data to figure out which actual model to use, I don't see how it's knowing to do this...?
lmneeds to make for this. – Chris Haug Oct 16 '20 at 16:29x*term and not thex^2). But in a simple or multiple linear regression its a best fitting "straight line", solved for either by gradient descent or analytically, right? So how does, in this case, it know to use some other method to make a model who's function generates a curved line instead of straight. I can only imagine it is using some strategy to fit the line that isn't used in a simple or multiple linear regression? – Tallboy Oct 16 '20 at 16:31lmformula "solving" for the slope and y intercept of the regression line using some method? In certain dataset inputs, the line is straight, as if it were solvingy = mx + band other times, the outputted line is not straight (includingx^2 + x^3in the data etc), I'm wondering what mechanism is making this happen? Why are some model lines straight (even with multiple independent variables, like in a "multiple linear regression"), and then a curved line is output for other datasets? – Tallboy Oct 16 '20 at 16:47