entertainmentcas.blogg.se

How to creat r output for simple linear regression equation
How to creat r output for simple linear regression equation





how to creat r output for simple linear regression equation

Output for R’s lm Function showing the formula used, the summary statistics for the residuals, the coefficients (or weights) of the predictor variable, and finally the performance measures including RMSE, R-squared, and the F-Statistic.īoth models have significant models (see the F-Statistic for Regression) and the Multiple R-squared and Adjusted R-squared are both exceptionally high (keep in mind, this is a simplified example). 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)

how to creat r output for simple linear regression equation

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()

how to creat r output for simple linear regression equation

#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







How to creat r output for simple linear regression equation