Dentro del archivo "datos_ventas.RData" se encuentran los datos para estimar una funcion de ventas, para una empresa, y contiene las siguientes variables:
ventas = Ventas en millones de US$,
tv = gasto en publicidad en TV en millones de US$,
radio = gasto en publicidad en radio en millones de US$,
periodico = gasto en publicidad en periodico en millones de US$.
Se solicita:
library(stargazer)
options(scipen = 999999)
load("C:/Users/gusta_000/Desktop/Econometria/Guia/datos_ventas.RData")
modelo_ventas<-lm(formula = ventas~tv+radio+periodico,data = datos_ventas)
stargazer(modelo_ventas,title = "Ecuacion de Ventas",type = "text")
##
## Ecuacion de Ventas
## ===============================================
## Dependent variable:
## ---------------------------
## ventas
## -----------------------------------------------
## tv 0.045
## (0.118)
##
## radio -3.450***
## (0.206)
##
## periodico 18.485***
## (0.563)
##
## Constant -33.289***
## (7.172)
##
## -----------------------------------------------
## Observations 200
## R2 0.847
## Adjusted R2 0.844
## Residual Std. Error 33.875 (df = 196)
## F Statistic 360.758*** (df = 3; 196)
## ===============================================
## Note: *p<0.1; **p<0.05; ***p<0.01
#Creando matriz M
matriz_x <- model.matrix(modelo_ventas)
matriz_xx <- t(matriz_x)%*%matriz_x
n <- nrow(matriz_x)
matriz_M <- diag(n)-matriz_x%*%solve(t(matriz_x)%*%matriz_x)%*%t(matriz_x)
Y <- datos_ventas$ventas
residuos <- matriz_M%*%Y
print(residuos)
## [,1]
## 1 -17.8524638
## 2 19.0821552
## 3 33.7931916
## 4 -17.3508987
## 5 10.2572135
## 6 74.2038531
## 7 -15.2465204
## 8 -23.4242974
## 9 -39.6405207
## 10 45.1613878
## 11 -40.6649446
## 12 8.9590198
## 13 5.1392043
## 14 -22.6236420
## 15 -2.4070766
## 16 -23.2129522
## 17 -8.8531474
## 18 -2.2553254
## 19 -36.4998224
## 20 -7.7078500
## 21 12.1068249
## 22 56.1602254
## 23 -4.4128052
## 24 32.1887265
## 25 -41.0755512
## 26 85.5635292
## 27 -0.5813419
## 28 36.0534051
## 29 25.1740669
## 30 -36.8482228
## 31 26.2868044
## 32 -15.4987679
## 33 -43.1444263
## 34 46.2272722
## 35 -42.1231189
## 36 101.1406281
## 37 -18.4643544
## 38 4.6103727
## 39 -19.7868698
## 40 -7.5311456
## 41 4.4398079
## 42 7.6680340
## 43 39.7209714
## 44 29.5192706
## 45 -12.0296830
## 46 9.1587903
## 47 -40.4095721
## 48 -13.3392963
## 49 39.1663986
## 50 -40.4133097
## 51 31.4947034
## 52 -31.1473697
## 53 -26.0085689
## 54 -19.2664951
## 55 21.2230654
## 56 -38.1989298
## 57 33.9900112
## 58 -9.0293035
## 59 -26.4532617
## 60 5.2080674
## 61 -57.0047861
## 62 -7.9150425
## 63 34.6127519
## 64 -21.0722866
## 65 -22.0009918
## 66 -37.5816067
## 67 -26.0583831
## 68 -25.5511822
## 69 15.6898060
## 70 -11.9155347
## 71 -2.0728694
## 72 -38.2242913
## 73 10.3876466
## 74 -22.3937288
## 75 16.7129825
## 76 36.0899293
## 77 -62.1710571
## 78 -11.0250420
## 79 43.4373665
## 80 -28.5252657
## 81 -17.3349979
## 82 58.2041869
## 83 -31.7292205
## 84 2.1957465
## 85 -7.5263700
## 86 6.0297930
## 87 -18.0886178
## 88 -14.5646838
## 89 -32.2092742
## 90 -3.0357398
## 91 -22.9596676
## 92 -69.3639459
## 93 5.2832261
## 94 -3.5250431
## 95 -24.0859349
## 96 -9.1837060
## 97 26.4214991
## 98 3.1212001
## 99 -2.9193041
## 100 -7.6730899
## 101 52.0041912
## 102 10.4210157
## 103 73.7871802
## 104 7.9854131
## 105 6.9306678
## 106 -26.3200156
## 107 -38.1956964
## 108 -37.1411765
## 109 -51.3551775
## 110 15.2312039
## 111 37.1313178
## 112 2.0545188
## 113 1.3651902
## 114 19.5562302
## 115 1.4943123
## 116 -6.1604300
## 117 -4.8525782
## 118 -61.9776211
## 119 -11.2002151
## 120 -15.1234596
## 121 -21.5609770
## 122 -4.7202419
## 123 50.4386227
## 124 -5.7864987
## 125 6.7136905
## 126 -35.9140143
## 127 50.9977671
## 128 -49.5940852
## 129 -34.1058846
## 130 -46.9621445
## 131 140.6245747
## 132 71.7959550
## 133 30.0581974
## 134 4.3121884
## 135 0.7502335
## 136 28.9102154
## 137 17.3960181
## 138 19.5045244
## 139 -12.7465335
## 140 -13.0911168
## 141 -36.7362018
## 142 -9.2131004
## 143 -4.9409642
## 144 -36.2423122
## 145 -31.9387023
## 146 -10.6584048
## 147 54.1763052
## 148 -25.9962973
## 149 8.2843516
## 150 -20.6385139
## 151 62.6625611
## 152 -33.3544363
## 153 3.7729886
## 154 -11.3760631
## 155 5.0805779
## 156 17.9950120
## 157 -7.8494101
## 158 -0.2201702
## 159 35.3022384
## 160 -11.5540752
## 161 0.6591253
## 162 -5.5871655
## 163 7.5462798
## 164 -9.3303245
## 165 -19.0175482
## 166 55.7263685
## 167 32.0402256
## 168 31.6353338
## 169 11.4108832
## 170 76.5904762
## 171 -32.7991015
## 172 -0.2825814
## 173 -19.0264844
## 174 9.3293014
## 175 54.2493038
## 176 -22.1047290
## 177 11.5543472
## 178 12.5352601
## 179 98.7318828
## 180 -0.3195726
## 181 4.3908269
## 182 43.6649823
## 183 -53.0060931
## 184 -18.3203130
## 185 33.8772333
## 186 -24.7792769
## 187 -11.5610805
## 188 2.7811315
## 189 73.1591927
## 190 -31.1749134
## 191 14.6672356
## 192 -37.2279106
## 193 -45.8529068
## 194 -17.4973688
## 195 -14.2672641
## 196 -56.8557034
## 197 -35.2780738
## 198 5.4730833
## 199 -12.5781921
## 200 46.9637691
confint(object = modelo_ventas, parm = "tv", level = 0.968)
## 1.6 % 98.4 %
## tv -0.2097376 0.2998052
Interpretacion: el gasto en publicidad en TV no es estadisticamente significativo de forma individual, ya que incluye "0" dentro del intervalo.