Realice los Ejercicios impares de (Griffiths et al., 1993, pp. 425-430)
Write down the basic consumption function, relating consumption to income, with time varying intercept and response parameters. Substitute equations 12.2.5 and 12.3.2 into the economic model, and add an error term to obstain a statistical model that permits both response and intercept to change during war years. La función de consumo dependiendo del ingreso sería:
\(C_t=\alpha_{0t}+\alpha_{1t}Y_t\)
Dónde \(\alpha_{0t}\) denota el consumo autonomo y \(\alpha_{1t}\) la propensión marginal a consumir. los subindices \(t\) indican que los parametros varían en el tiempo. Ahora, definiendo una variable dicotomica \(D_t\) (como se denota en el libro) que toma el valor de 1 cuando el año de los datos corresponde a uno del periodo de guerra y 0 en caso contrario, los parametros cambiarían de la siguiente forma (de acuerdo a las ecuaciones 12.2.5 y 12.3.2)
\(\alpha_{0t}=\alpha_0+\delta D_t\)
\(\alpha_{1t}=\alpha_1+\gamma D_t\)
Reemplazando en la ecuación del consumo, y agregando el término de error:
\(C_t=\alpha_0+\delta D_t + \alpha_1Y_t+\gamma D_tY_t + e_t\)Use the data in Table 12.1 and estimate the parameters of the statistical model 12.3.5 by least squares. Sketch the consumption relation for war and nonwar years, and compare the resulting sketch to Figure 12.3b.
m12_1<-lm(C~D+Y+Y*D, data=Tabla_12_1)
summary(m12_1)
##
## Call:
## lm(formula = C ~ D + Y + Y * D, data = Tabla_12_1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -73.962 -16.170 -5.016 12.218 164.732
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 95.86297 21.85102 4.387 8.81e-05 ***
## D 957.14160 299.36624 3.197 0.002795 **
## Y 0.86706 0.01263 68.637 < 2e-16 ***
## D:Y -0.72928 0.18760 -3.887 0.000394 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 36.46 on 38 degrees of freedom
## Multiple R-squared: 0.9924, Adjusted R-squared: 0.9918
## F-statistic: 1660 on 3 and 38 DF, p-value: < 2.2e-16
datos<-m12_1$model
datos$C_E<-m12_1$fitted.values
datos<-data.frame(datos)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.6.3
consumption<-ggplot(data=datos,aes(x=Y, y=C_E))+geom_line(aes(linetype=as.factor(D)))
consumption
Let \(P_t=1-D_t\) define a dummy variable that is 1 during nonwar years and 0 during war years. Estimate by least squares the model
\(C_t=\delta_1 P_t+ \delta_2 D_t + \beta_1(P_tY_t)+\beta_2(D_tY_t)+e_t\)
Note that this model does not contain an overall constant term. Compare the resulying estimates to those in (b).
Tabla_12_1$PY<-Tabla_12_1$P*Tabla_12_1$Y
Tabla_12_1$DY<-Tabla_12_1$D*Tabla_12_1$Y
m12_2<-lm(C~P+D+PY+DY+0, data=Tabla_12_1)
summary(m12_2)
##
## Call:
## lm(formula = C ~ P + D + PY + DY + 0, data = Tabla_12_1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -73.962 -16.170 -5.016 12.218 164.732
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## P 9.586e+01 2.185e+01 4.387 8.81e-05 ***
## D 1.053e+03 2.986e+02 3.527 0.00112 **
## PY 8.671e-01 1.263e-02 68.637 < 2e-16 ***
## DY 1.378e-01 1.872e-01 0.736 0.46620
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 36.46 on 38 degrees of freedom
## Multiple R-squared: 0.9995, Adjusted R-squared: 0.9994
## F-statistic: 1.899e+04 on 4 and 38 DF, p-value: < 2.2e-16
datos2<-Tabla_12_1
datos2$C_E<-m12_2$fitted.values
datos2<-data.frame(datos2)
consumption2<-ggplot(data=datos2,aes(x=Y, y=C_E))+geom_line(aes(linetype=as.factor(D)))
consumption2
Use the data in Table 12.1 to estimate separate consumption relations
\(C_t=\beta_1+\beta_2Y_t+e_t\)
for the war and nonwar periods. Compare the resulting estimates and standard errors to those obtained in parts (b) and (c). Explain any differences you observe.
m_war<-lm(C~Y, data=subset(Tabla_12_1, Tabla_12_1$D==1))
m_nowar<-lm(C~Y, data=subset(Tabla_12_1, Tabla_12_1$D==0))
ayb<-data.frame(m12_1$fitted.values,m12_1$residuals,m12_1$model,m12_2$fitted.values, m12_2$residuals)
war<-data.frame(subset(ayb, ayb$D==1),m_war$fitted.values,m_war$residuals)
nowar<-data.frame(subset(ayb, ayb$D==0),m_nowar$fitted.values,m_nowar$residuals)
war
## m12_1.fitted.values m12_1.residuals C D Y m12_2.fitted.values
## 13 1249.607 -9.606711 1240 1 1427 1249.607
## 14 1270.962 -73.961534 1197 1 1582 1270.962
## 15 1277.437 -64.436868 1213 1 1629 1277.437
## 16 1283.499 -45.498882 1238 1 1673 1283.499
## 17 1279.228 28.772083 1308 1 1642 1279.228
## 18 1274.268 164.731912 1439 1 1606 1274.268
## m12_2.residuals m_war.fitted.values m_war.residuals
## 13 -9.606711 1249.607 -9.606711
## 14 -73.961534 1270.962 -73.961534
## 15 -64.436868 1277.437 -64.436868
## 16 -45.498882 1283.499 -45.498882
## 17 28.772083 1279.228 28.772083
## 18 164.731912 1274.268 164.731912
head(nowar)
## m12_1.fitted.values m12_1.residuals C D Y m12_2.fitted.values
## 1 1167.5437 -22.54374 1145 0 1236 1167.5437
## 2 1073.9017 -14.90173 1059 0 1128 1073.9017
## 3 1029.6819 -13.68189 1016 0 1077 1029.6819
## 4 894.4212 24.57879 919 0 921 894.4212
## 5 870.1437 26.85635 897 0 893 870.1437
## 6 921.2999 12.70006 934 0 952 921.2999
## m12_2.residuals m_nowar.fitted.values m_nowar.residuals
## 1 -22.54374 1167.5437 -22.54374
## 2 -14.90173 1073.9017 -14.90173
## 3 -13.68189 1029.6819 -13.68189
## 4 24.57879 894.4212 24.57879
## 5 26.85635 870.1437 26.85635
## 6 12.70006 921.2999 12.70006
Los resultados son los mismos en los tres modelos
Use the data in Table 12.1 to construct the design matrix X that contains (i) an intercept variable, (ii) income, (iii) the dummy variable \(D_t\) in equations 12.2.3, and (iv) the dummy variable \(H_t=1-D_t\). Identify the linearly dependent columns.
#denotamos como X las variables del modelo 1
X<-m12_1$model
# Añadimos P y el término constante
X$P<-matrix(1,nrow=nrow(X), ncol=1)
X$P<-X$P-X$D
X$Constante<-matrix(1,nrow=nrow(X), ncol=1)
X<-as.matrix(X)
# Hallamos X'X
XX<-t(X)%*%X
# Testeamos si alguna de las variables es una combinación lineal de otra, ello se puede saber testeando si es definida positiva
matrixcalc::is.positive.definite(XX)
## [1] FALSE
# Como no lo es la imprimimos
XX
## C D Y P Constante
## C 101019019 7635 111297278 55314 62949
## D 7635 6 9559 0 6
## Y 111297278 9559 122981194 59815 69374
## P 55314 0 59815 36 36
## Constante 62949 6 69374 36 42
# No es evidente la combinación lineal, la podemos identificar con la función findDepMat
findDepMat <- function(X, rows = TRUE, tol = 1e-10) {
if (!is.matrix(X))
stop("'X' is not a matrix")
if (!is.numeric(X))
stop("'X' is not numeric")
if (!rows) {
X <- t(X)
}
depends <- logical(NROW(X))
for (i in 1:(NROW(X) - 1)) {
for (j in (i + 1):NROW(X)) {
# Only check it if a dependency has not been established
if (!depends[j]) {
depends[j] <- (max(abs(diff(X[i,] / X[j,]))) < tol)
}
}
} # for (i
# Check with qr
qr.rank <- qr(X, tol = tol)$rank
if (sum(!depends) != qr.rank) {
warning("Number of linearly independent rows (or columns), ",
sum(!depends), ", do not agree with rank of X, ", qr.rank, ".\n")
}
return(depends)
} # findDepMat
findDepMat(XX)
## Warning in findDepMat(XX): Number of linearly independent rows (or columns), 5, do not agree with rank of X, 4.
## [1] FALSE FALSE FALSE FALSE FALSE
El test dice que ninguna columna es independiente, sin embargo es facil darse cuenta que la columna D es el resultado de tomar la constante y restarle P
Given the economic model 12.5.4, write down the corresponding statistical model with appropriate assumptions.
El modelo 12.5.4 Estaba dado por:
\(BE_i=\beta_1+\delta S_i + \gamma_1 E_{1i} + \gamma_2 E_{2i} + \gamma_3 E_{3i} + \beta_2 Y_i\)
Dónde \(BE_i\) es el gasto en cerveza, y las variables \(E_{ij}\) son categorías de una variable cualitativa qie indica el nivel educativo, y \(S_i\) es una variable dummy que expresa el sexo del individuo observado. Los tres niveles educativos contemplados son Bachillerato, universidad y posgrado, por lo que, de conservar el término constante \(\beta_1\) debemos suponer que existen individuos con un nivel educativo distinto a estas tres categorías, en el libro se asume que representa a los que tienen menos que el Bachillerato.
Incorporar la variable sexo implicaría suponer que el gasto en cerveza varía dependiendo del sexo del individuo, Esto altera tambien el significado del parámetro \(\beta_1\) pues ahora, suponiendo que 1 es mujer y 0 hombre, representaría el efecto de tener menos que el bachillerato y ser hombre. Solamente haría falta agregar el término de error como en 12.6.6 y el modelo sería simplemente:
\(BE_i=\beta_1+\delta S_i + \gamma_1 E_{1i} + \gamma_2 E_{2i} + \gamma_3 E_{3i} + \beta_2 Y_i+e_i\)
o en forma matricial
\(BE_i=\begin{pmatrix} 1 & S_i & E_{1i} & E_{2i} & E_{3i} & Y_i\end{pmatrix}*\begin{pmatrix} \beta_1\\ \delta\\ \gamma_1\\ \gamma_2\\ \gamma_3\\ \beta_2\end{pmatrix}+e_i\)Write down, in specific terms, the null hypothesis in the form \(H_0: R\beta=r\), as discussed in Chapter 11.
Elegimos una variable para desarrollar el test. Ene ste caso supongamos que la variable sexo no es significativa, por tanto \(H_o: \delta =0\). Definiendo:
\(R=\begin{bmatrix} 0&1&0&0&0&0 \end{bmatrix}\) y \(r=0\)
Se puede escribir
\(R\beta=\begin{bmatrix} 0&1&0&0&0&0 \end{bmatrix} \begin{bmatrix} \beta_1\\ \delta\\ \gamma_1\\ \gamma_2\\ \gamma_3\\ \beta_2\end{bmatrix}=\delta\)
se puede escribir la hipotesis nula entonces como \(H_0: R\beta=r\)Test the hypothesis that age does not affect beer expenditure through either the slope or the intercept parameter. Specifically, using the results in Table 12.4, test the null hypothesis that \(\delta_1=\delta_2=0\) in equation 12.7.8.
En primer lugar estimamos los tres modelos de la tabla 12.4
#Modelo 5
mod5<-lm(BE~Y,data=Tabla_12_2)
#Modelo 6
Tabla_12_2$YA<-Tabla_12_2$Y*Tabla_12_2$A
mod6<-lm(BE~Y+YA,data=Tabla_12_2)
#Modelo 7
mod7<-lm(BE~Y+A+YA,data=Tabla_12_2)
Posteriormente testeamos si afecta en pendiente empleando la prueba de Chow. El modelo no restringido será el Modelo 7, y el restringido el 6
#Extraemos la suma de los residuos al cuadrado
SSR7<-NULL
SSR7$mod5<-sum(mod5$residuals^2)
SSR7$mod6<-sum(mod6$residuals^2)
SSR7$mod7<-sum(mod7$residuals^2)
#Ejecutamos la prueba con un nivel de significancia del 5%
Chow7<-((SSR7$mod6-SSR7$mod5)/3)/(SSR7$mod5/38)
qf(.95,3,38)<Chow7
## [1] FALSE
Como resultado, se debe aceptar la hipótesis nula de que no hay diferencia en pendiente. continuando con la diferencia en intercepto. se ejecura la misma prueba, pero en este caso el modelo restringifo es el 7
Chow72<-((SSR7$mod7-SSR7$mod5)/4)/(SSR7$mod5/38)
qf(.95,4,38)<Chow72
## [1] FALSE
Tampoco existe evidencia de diferencia en el intercepto. La prueba tambien se podría ejecutar de forma directa en el modelo 7 así:
car::linearHypothesis(mod7,c("A=0","YA=0"), white.adjust="hc1")
## Linear hypothesis test
##
## Hypothesis:
## A = 0
## YA = 0
##
## Model 1: restricted model
## Model 2: BE ~ Y + A + YA
##
## Note: Coefficient covariance matrix supplied.
##
## Res.Df Df F Pr(>F)
## 1 38
## 2 36 2 8.328 0.001065 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Con lo que se confirma que los parametros \(\delta\) son diferentes de cero en la ecuación, incluso al 1% pero, ello no quiere decir que marquen una diferencia significativa en pendiente o intercepto con respecto al modelo 5 no restringido como sí lo muestra el test de Chow.
Modify equation 12.7.3 to permit a “life-cycle” effect in which the marginal effect of income on beer expenditure increases with age, up to a point, and then falls. Do so by adding a quadratic term to equation 12.7.3. Substitute the resulting model into the expenditure relationship equation 12.7.1. What sign do you anticipate on the quadratic term?
La ecuación 12.7.3 quedaría expresada como:
\(\beta_{2i}=\beta_2+\delta_2 A_i +\delta_3 A_i^2\)
Reemplazando en la ecuación 12.7.1
\(BE_i=\beta_1+\beta_2Y_i+\delta_2(Y_iA_i)+\delta_3(Y_iA_i^2)+e_i\)
Se esperaría que el signo de \(\delta_3\) sea negativo, ya que si va a disminuir el gasto en cerveza a partir de cierta edad, y esta variable al cuadrado será cada vez más grande, el signo tiene que ser negativo para que en efecto se reduzca el gasto. la parte creciente debería ser compensada por la variable de edad lineal o por el intercepto.Assume that the effect of age on the response of the beer expenditure relation 12.7.3 differs according to the gender of the individual. Develop a model that incorporates this possibility and discuss how the conjecture could be tested.
En este caso la ecuación 17.7.3 podría escribirse como:
\(\beta_{2i}=\beta_2+\delta_2 S_iA_i\)
Note que no incorporamos un parámetro para solo la variable sexo, esto se debe a que cuando se reemplace el valor de \(\beta_2\) en la ecuación 12.7.1, el parametro de solo la variable sexo terminaría multiplicando al ingreso, por lo que no reflejaría necesariamente un cambio en la relación con la edad y el sexo, sino del sexo con el nivel de ingreso. Tampoco se conservó un parámetro para solo la variable edad, pues en ese caso, al contener intercepto, se caeria en la trampa de las variables dummy en la ecuación 17.7.3. Si bien, no se incorpora una variable para la categoría hombre y otra para la categoría mujer, la sola variable \(A_i\) representaría a los hombres, y \(S_iA_i\) la diferencia entre sexos, por lo que el término constante resultaría sobrando. El modelo finalmente sería:
\(BE_i=\beta_1+\beta_2Y_i+\delta_2(Y_iA_iS_i)+e_i\)Consider the beer expenditure model
\(BE_i=\beta_{1i}+\beta_{2i}Y_i+e_i\)
as discussed in Section 12.5. Assume that the intercept and slope parameters vary with the gender of the individual, so
\(\beta_{1i}=\delta_1+\delta_2S_i\)
\(\beta_{2i}=\theta_1+\theta_2S_i\)
Substitute these expressions for the parameter variation into the model. What are the regression functions \(E[BE_i]\) for males and females?
Realizamos la sustitución
\(BE_i=\delta_1+\delta_2S_i+\theta_1Y_i+\theta_2S_iY_i+e_i\)
Asumiendo que la variable \(S_i\) toma el valor de 1 para mujer y 0 para hombres, el valor esperado para hombres sería:
\(E[BE_i]=\delta_1+\theta_1Y_i\)
y el valor esperado para mujeres:
\(E[BE_i]=\delta_1+\delta_2+\theta_1Y_i+\theta_2Y_i\)
Asumiendo que \(\beta_{1i}=\delta_1+\delta_2\) y \(\beta_{2i}=\theta_1+\theta_2\) el valor esperado sería finalmente
\(E[BE_i]=\beta_{1i}+\beta_{2i}Y_i\)Using the data in Table 12.2, estimate the parameters of the statistical model in (a) using least squares applied to the entire data set (all T=40 obsevations).
mod9<-lm(BE~S+Y+S*Y,data=Tabla_12_2)
summary(mod9)
##
## Call:
## lm(formula = BE ~ S + Y + S * Y, data = Tabla_12_2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -211.90 -77.55 -3.61 74.58 214.26
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.865e+02 4.567e+01 4.083 0.000237 ***
## S -1.260e+02 5.701e+01 -2.210 0.033541 *
## Y 2.327e-03 8.569e-04 2.715 0.010105 *
## S:Y -1.291e-03 1.019e-03 -1.267 0.213333
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 114.1 on 36 degrees of freedom
## Multiple R-squared: 0.5055, Adjusted R-squared: 0.4643
## F-statistic: 12.27 on 3 and 36 DF, p-value: 1.112e-05
Using the data in Table 12.2, apply least squares to estimate the simple expenditure model
\(BE_i=\beta_1+\beta_2Y_i+e_i\)
first using only the data on males, and then using only the data on females. Compare and contrast the results to those obtained in (b). Explain the reason for any differences.
#El modelo para hombres
mod_9h<-lm(BE~Y,data=subset(Tabla_12_2, Tabla_12_2$S==0))
summary(mod_9h)
##
## Call:
## lm(formula = BE ~ Y, data = subset(Tabla_12_2, Tabla_12_2$S ==
## 0))
##
## Residuals:
## Min 1Q Median 3Q Max
## -211.90 -120.25 19.42 78.50 214.26
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.865e+02 5.265e+01 3.542 0.00251 **
## Y 2.327e-03 9.877e-04 2.355 0.03077 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 131.5 on 17 degrees of freedom
## Multiple R-squared: 0.2461, Adjusted R-squared: 0.2017
## F-statistic: 5.548 on 1 and 17 DF, p-value: 0.03077
#el modelo para mujeres
mod_9m<-lm(BE~Y,data=subset(Tabla_12_2, Tabla_12_2$S==1))
summary(mod_9m)
##
## Call:
## lm(formula = BE ~ Y, data = subset(Tabla_12_2, Tabla_12_2$S ==
## 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -153.63 -52.59 -11.40 33.00 189.11
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 60.469162 28.662678 2.110 0.0484 *
## Y 0.001035 0.000464 2.231 0.0379 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 95.84 on 19 degrees of freedom
## Multiple R-squared: 0.2076, Adjusted R-squared: 0.1659
## F-statistic: 4.977 on 1 and 19 DF, p-value: 0.03794
Los parametros cuando \(S_i=0\) son iguales a los \(\delta_1\) y \(\theta_1\) del primer modelo, el parametro de \(Y_i\) del segundo modelo entra en el intervalo de confianza del parametro de \(S_iY_i\) en el primer modelo, y las diferencias son muy pequeñas, aunque en el segundo modelo sí es significativa al 5%. La diferencia principal está en el intercepto, el cual se hace mucho más grande en el segundo modelo, tal vez diferenciando aún más el consumo promedio entre ambos sexos.
Define a new dummy variable \(H_i=1-S_i\). Model the parameter variation as
\(\beta_{1i}=\alpha_1H_i+\alpha_2S_i\)
\(\beta_{2i}=\gamma_1H_i+\gamma_2S_i\)
Substitute these expressions into the expenditure model. What are the regression functions \(E[BE_i]\) for males and females? Compare the results in part (a)
Realizamos la sustitución
\(BE_i=\alpha_1H_i+\alpha_2S_i+\gamma_1H_iY_i+\gamma_2S_iY_i+e_i\)
La ecuación para hombres:
\(E[BE_i]=\alpha_1+\gamma_1Y_i\)
La ecuación para mujeres
\(BE_i=\alpha_2+\gamma_2Y_i+e_i\)Estimate the statistical model in (d) by least squares, using the data in Table 12.2, and compare and contrast the results to those obtained in (b) and (c).
#Creamos H
Tabla_12_2$H<-matrix(1,nrow=nrow(Tabla_12_2), ncol=1)
Tabla_12_2$H<-Tabla_12_2$H-Tabla_12_2$S
Tabla_12_2$HY<-Tabla_12_2$H*Tabla_12_2$Y
Tabla_12_2$SY<-Tabla_12_2$S*Tabla_12_2$Y
# El modelo d
mod9d<-lm(BE~H+S+HY+SY+0,Tabla_12_2)
summary(mod9d)
##
## Call:
## lm(formula = BE ~ H + S + HY + SY + 0, data = Tabla_12_2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -211.90 -77.55 -3.61 74.58 214.26
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## H 1.865e+02 4.567e+01 4.083 0.000237 ***
## S 6.047e+01 3.412e+01 1.772 0.084802 .
## HY 2.327e-03 8.569e-04 2.715 0.010105 *
## SY 1.035e-03 5.523e-04 1.874 0.069051 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 114.1 on 36 degrees of freedom
## Multiple R-squared: 0.806, Adjusted R-squared: 0.7844
## F-statistic: 37.39 on 4 and 36 DF, p-value: 2.35e-12
A pesar de omitir la constante para no caer en la trampa de las variables dummy, incluir la variable H reduce la significancia de las interacciones con \(S_i\). Esta especificación obtiene parametros que son el resultado de unir la estimación por separado en el punto (c) y se diferencian del punto (b) en el valor de los parametros d \(S_i\) y \(S_iY_i\).
For each corporation (separately) use least squares to estimate the investment functions
\(i=\beta_1+\beta_2v+\beta_3k+e\)
Definimos una variable dummy que indique la compañía a la que pertenecen los datos D=1 si es General Electric y D=0 si es Westinghouse.
#Modelo para Westinghouse
mod11a1<-lm(i~v+k,data=subset(Tabla_12_6,Tabla_12_6$D==0))
summary(mod11a1)
##
## Call:
## lm(formula = i ~ v + k, data = subset(Tabla_12_6, Tabla_12_6$D ==
## 0))
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.500 -7.835 -1.934 6.487 17.267
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.50887 8.01740 -0.063 0.95013
## v 0.05289 0.01571 3.366 0.00367 **
## k 0.09242 0.05611 1.647 0.11792
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 10.22 on 17 degrees of freedom
## Multiple R-squared: 0.7443, Adjusted R-squared: 0.7142
## F-statistic: 24.75 on 2 and 17 DF, p-value: 9.232e-06
#Modelo para General Electric
mod11a2<-lm(i~v+k,data=subset(Tabla_12_6,Tabla_12_6$D==1))
summary(mod11a2)
##
## Call:
## lm(formula = i ~ v + k, data = subset(Tabla_12_6, Tabla_12_6$D ==
## 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.511 -23.359 -3.922 7.824 58.737
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -9.95631 31.37425 -0.317 0.755
## v 0.02655 0.01557 1.706 0.106
## k 0.15169 0.02570 5.902 1.74e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 27.88 on 17 degrees of freedom
## Multiple R-squared: 0.7053, Adjusted R-squared: 0.6706
## F-statistic: 20.34 on 2 and 17 DF, p-value: 3.088e-05
These two firms engage in similar activities, and we conjecture that the coefficients of v and k are identical for the two firms, but that the intercept parameters may be different for the firms’ investment functions. Use a dummy variable to allow for differing firms intercepts, but common coefficients of v and k, and estimate the resulting model. What do you conclude about our conjecture?
#En este caso ya no usamos la variable D para generar subconjuntos, sino para cambiar el intercepto incorporandola al modelo
mod11b<-lm(i~D+v+k,data=Tabla_12_6)
summary(mod11b)
##
## Call:
## lm(formula = i ~ D + v + k, data = Tabla_12_6)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.339 -10.357 -2.146 7.566 57.860
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.98317 8.17011 1.222 0.2297
## D -25.94693 14.73842 -1.760 0.0868 .
## v 0.02974 0.01023 2.908 0.0062 **
## k 0.15123 0.01861 8.127 1.16e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 20.58 on 36 degrees of freedom
## Multiple R-squared: 0.8249, Adjusted R-squared: 0.8103
## F-statistic: 56.51 on 3 and 36 DF, p-value: 1.073e-13
En los modelos individuales, el intercepto no era significativo en ninguno de los casos, por lo que podría decirse que eran estadísticamente cero. con un resultado así, es dudoso suponer que existe diferencia en el intercepto. Al incorporar la variable dummy el parametro es significativo solo al 10%, por lo que tampoco es que haya mucha validez en suponer que los interceptos son diferentes. Por otro lado, en los modelos individuales, los parametros de v y k eran significativos, solo uno para cada empresa, mientras que en el modelo conjunto ambos son significativos y más parecidos al modelo de solo General Electric.
Use an intercept dummy and interaction variables to test whether or not the Westinghouse investment function is identical to the General Electric investment function. State and discuss your conclusion.
En primer lugar definimos las interacciones \(v_1=v*D\) y \(k_1=k*D\) y con estas creamos el modelo restringido y el no restringido
#Restringido
mod11cr<-lm(i~D+v+k+v1+k1,data=Tabla_12_6)
summary(mod11cr)
##
## Call:
## lm(formula = i ~ D + v + k + v1 + k1, data = Tabla_12_6)
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.511 -10.597 -2.887 6.487 58.737
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.50887 16.47908 -0.031 0.976
## D -9.44744 28.80625 -0.328 0.745
## v 0.05289 0.03229 1.638 0.111
## k 0.09242 0.11534 0.801 0.429
## v1 -0.02634 0.03435 -0.767 0.449
## k1 0.05927 0.11695 0.507 0.616
##
## Residual standard error: 21 on 34 degrees of freedom
## Multiple R-squared: 0.8278, Adjusted R-squared: 0.8025
## F-statistic: 32.7 on 5 and 34 DF, p-value: 4.608e-12
#No restringido
mod11cnr<-lm(i~v+k,data=Tabla_12_6)
summary(mod11cnr)
##
## Call:
## lm(formula = i ~ v + k, data = Tabla_12_6)
##
## Residuals:
## Min 1Q Median 3Q Max
## -41.792 -11.453 -0.433 9.108 58.800
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 17.868360 7.024159 2.544 0.0153 *
## v 0.015194 0.006196 2.452 0.0190 *
## k 0.143580 0.018601 7.719 3.19e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 21.16 on 37 degrees of freedom
## Multiple R-squared: 0.8098, Adjusted R-squared: 0.7995
## F-statistic: 78.75 on 2 and 37 DF, p-value: 4.639e-14
Ninguna variable es significativa, a pesar de ello aplicamos la prueba de Chow
SSR11<-NULL
SSR11$R<-sum(mod11cr$residuals^2)
SSR11$U<-sum(mod11cnr$residuals^2)
Chow11<-((SSR11$R-SSR11$U)/6)/(SSR11$U/37)
qf(.95,6,37)<Chow11
## [1] FALSE
No se puede rechazar la hipótesis nula de que los parametros de las interacciones y el intercepto diferente sean cero. Es decir, que el valor esperado de la inversión condicional en el valor de la empresa y el capital tiene el mismo intercepto y pendiente para ambas empresas
Para los ejercicios anteriores aplique las pruebas de la libreria strucchange de R cuando esto sea adecuado.
library(strucchange)
## Warning: package 'strucchange' was built under R version 3.6.3
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Loading required package: sandwich
## Warning: package 'sandwich' was built under R version 3.6.3
#Modelo 12.1
sctest(C~Y, data=Tabla_12_1, type="Chow", point=13) # indicamos el modelo a evaluar, el tipo de prueba, y el punto en el que suponemos el cambio, en este caso el año 13 y el año 18
##
## Chow test
##
## data: C ~ Y
## F = 4.3424, p-value = 0.02002
sctest(C~Y, data=Tabla_12_1, type="Chow", point=18)
##
## Chow test
##
## data: C ~ Y
## F = 63.166, p-value = 8.263e-13
#Modelo 12.7
sctest(BE~Y+Y*A,data=Tabla_12_2, type="Chow", point=22) #en el punto 22 es en el que se cambia de sexo
##
## Chow test
##
## data: BE ~ Y + Y * A
## F = 10.538, p-value = 1.461e-05
#Modelo 12.9
sctest(BE~Y,data=Tabla_12_2, type="Chow", point=22)
##
## Chow test
##
## data: BE ~ Y
## F = 13.402, p-value = 4.463e-05
#Modelo 12.11
sctest(i~v+k,data=Tabla_12_6, type="Chow", point=21)
##
## Chow test
##
## data: i ~ v + k
## F = 0.49664, p-value = 0.6871
Para los ejercicios anteriores aplique el Filtro de Kalman con las varianzas estimadas del Ejercicio 1, cuando esto sea adecuado.