![]() The summary function outputs the results of the linear regression model. The plus sign includes the Month variable in the model as a predictor (independent) variable. Notices on the multi.fit line the Spend variables is accompanied by the Month variable and a plus sign (+). Multi.fit = lm(Sales~Spend+Month, data=dataset) ![]() Simple.fit = lm(Sales~Spend, data=dataset) We’ll use Sales~Spend, data=dataset and we’ll call the resulting linear model “fit”. The lm function really just needs a formula (Y~X) and then a data source. The predictor (or independent) variable for our linear regression will be Spend (notice the capitalized S) and the dependent variable (the one we’re trying to predict) will be Sales (again, capital S). Simple (One Variable) and Multiple Linear Regression Using lm() #Use getwd() to see what your current directory is.ĭataset = read.csv("data-marketing-budget-12mo.csv", header=T,ĬolClasses = c("numeric", "numeric", "numeric")) ![]() #change your working directory to wherever you saved the csv. #You may need to use the setwd(directory-name) command to ![]() Assuming you’ve downloaded the CSV, we’ll read the data in to R and call it the dataset variable ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |