Test de corrélation et modèle de regression linéaire simple dans R/Rstudio

Описание к видео Test de corrélation et modèle de regression linéaire simple dans R/Rstudio

Le module 1 de la serie des modèles de regression linéaire dans Rstudio

LINEAR REGRESSION MODELS IN R

1. Load and read data
library(readxl)
Database = read_excel("states.data.xlsx", col_names = TRUE, col_types = NULL, na="", sheet="states", skip = 0)

2. Simple linear regression

2.1 Examine the data before fitting models

summary of expense and csat columns, all rows
data.ex.csat = subset(Database, select = c("expense", "csat"))
summary(data.ex.csat)

correlation between expense and csat
cor(data.ex.csat)

2.2 Plot the data before fitting models : scatter plot of expense vs csat
plot(data.ex.csat)

2.3 Linear regression example

Fit our regression model
sat.mod1 = lm(csat ~ expense, data=Database)
summary(sat.mod1)

Regression csat vs percent

data.per.csat = subset(Database, select = c("percent", "csat"))
summary(data.per.csat)
cor(data.per.csat)
plot(data.per.csat)
sat.mod2 = lm(csat ~ percent, data=Database)
summary(sat.mod2)

anova(sat.mod1, sat.mod2)
AIC(sat.mod1, sat.mod2)

Комментарии

Информация по комментариям в разработке