Receita <- read.csv("C:/Users/Carol/Dropbox/UFGD/2019.01_Disciplinas/Topicos de Estatistica/9_Aula/receita.csv", sep=";", dec=',')
link para download: https://www.dropbox.com/s/u0sb7817t6f6pwy/receita.csv?dl=0
Receita_Bruta | Publicidade_Televisiva | Publicidade_Jornais |
---|---|---|
96 | 5.0 | 1.5 |
90 | 2.0 | 2.0 |
95 | 4.0 | 1.5 |
92 | 2.5 | 2.5 |
95 | 3.0 | 3.3 |
94 | 3.5 | 2.3 |
94 | 2.5 | 4.2 |
94 | 3.0 | 2.5 |
require(corrgram)
## Loading required package: corrgram
corrgram(Receita,
#upper.panel=panel.cor,
upper.panel=panel.conf,
cex.labels=1.5, cex=1.2)
Escreva um modelo de regressão adequado este conjunto de dados.
Ajuste o modelo do item b) no software R e realize o teste F para verificar se a regressão é significativa.
mod <- lm(Receita_Bruta ~ Publicidade_Televisiva + Publicidade_Jornais,
data = Receita)
summary(mod)
##
## Call:
## lm(formula = Receita_Bruta ~ Publicidade_Televisiva + Publicidade_Jornais,
## data = Receita)
##
## Residuals:
## 1 2 3 4 5 6 7 8
## -0.6325 -0.4124 0.6577 -0.2080 0.6061 -0.2380 -0.4197 0.6469
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 83.2301 1.5739 52.882 4.57e-08 ***
## Publicidade_Televisiva 2.2902 0.3041 7.532 0.000653 ***
## Publicidade_Jornais 1.3010 0.3207 4.057 0.009761 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6426 on 5 degrees of freedom
## Multiple R-squared: 0.919, Adjusted R-squared: 0.8866
## F-statistic: 28.38 on 2 and 5 DF, p-value: 0.001865
summary(mod)
##
## Call:
## lm(formula = Receita_Bruta ~ Publicidade_Televisiva + Publicidade_Jornais,
## data = Receita)
##
## Residuals:
## 1 2 3 4 5 6 7 8
## -0.6325 -0.4124 0.6577 -0.2080 0.6061 -0.2380 -0.4197 0.6469
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 83.2301 1.5739 52.882 4.57e-08 ***
## Publicidade_Televisiva 2.2902 0.3041 7.532 0.000653 ***
## Publicidade_Jornais 1.3010 0.3207 4.057 0.009761 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6426 on 5 degrees of freedom
## Multiple R-squared: 0.919, Adjusted R-squared: 0.8866
## F-statistic: 28.38 on 2 and 5 DF, p-value: 0.001865
summary(mod)$adj.r.squared
## [1] 0.8866498
require(car)
## Loading required package: car
## Loading required package: carData
qqPlot(mod)
## [1] 1 3
shapiro.test(mod$residuals)
##
## Shapiro-Wilk normality test
##
## data: mod$residuals
## W = 0.81611, p-value = 0.04247
plot(mod$residuals)
durbinWatsonTest(mod)
## lag Autocorrelation D-W Statistic p-value
## 1 -0.2853598 2.17427 0.61
## Alternative hypothesis: rho != 0
plot(mod, 1)
require(lmtest)
## Loading required package: lmtest
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
bptest(mod)
##
## studentized Breusch-Pagan test
##
## data: mod
## BP = 2.313, df = 2, p-value = 0.3146