library(wooldridge)
data("hprice2")
library(wooldridge)
tail(hprice2)
## price crime nox rooms dist radial proptax stratio lowstat lprice
## 501 16800 0.224 5.85 6.03 2.50 6 39.1 19.2 14.33 9.729135
## 502 22400 0.063 5.73 6.59 2.48 1 27.3 21.0 9.67 10.016816
## 503 20600 0.045 5.73 6.12 2.29 1 27.3 21.0 9.08 9.933046
## 504 23899 0.061 5.73 6.98 2.17 1 27.3 21.0 5.64 10.081592
## 505 22000 0.110 5.73 6.79 2.39 1 27.3 21.0 6.48 9.998797
## 506 11900 0.047 5.73 6.03 2.51 1 27.3 21.0 7.88 9.384294
## lnox lproptax
## 501 1.766442 5.968708
## 502 1.745715 5.609472
## 503 1.745715 5.609472
## 504 1.745715 5.609472
## 505 1.745715 5.609472
## 506 1.745715 5.609472
lm(price ~ crime + nox + rooms + dist + radial + stratio, data = hprice2)
##
## Call:
## lm(formula = price ~ crime + nox + rooms + dist + radial + stratio,
## data = hprice2)
##
## Coefficients:
## (Intercept) crime nox rooms dist radial
## 25177.7 -190.1 -3042.3 6597.6 -1052.6 93.9
## stratio
## -1270.7
lm(scale(price) ~ 0 + scale(nox) + scale(crime) +scale(rooms) + scale(dist) + scale(stratio), data = hprice2)
##
## Call:
## lm(formula = scale(price) ~ 0 + scale(nox) + scale(crime) + scale(rooms) +
## scale(dist) + scale(stratio), data = hprice2)
##
## Coefficients:
## scale(nox) scale(crime) scale(rooms) scale(dist) scale(stratio)
## -0.3404 -0.1433 0.5139 -0.2348 -0.2703
Logaritmik fonksiyonel form
lm(formula = log(price) ~ log(nox) + rooms, data = hprice2 )
##
## Call:
## lm(formula = log(price) ~ log(nox) + rooms, data = hprice2)
##
## Coefficients:
## (Intercept) log(nox) rooms
## 9.2337 -0.7177 0.3059
6.2.1 Karasel modeller, Örnek 6.2
ornek6_2<-lm(log(price) ~ log(nox) + log(dist) + rooms + I(rooms^2) + stratio, data = hprice2)
summary(ornek6_2)
##
## Call:
## lm(formula = log(price) ~ log(nox) + log(dist) + rooms + I(rooms^2) +
## stratio, data = hprice2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.04285 -0.12774 0.02038 0.12650 1.25272
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 13.385477 0.566473 23.630 < 2e-16 ***
## log(nox) -0.901682 0.114687 -7.862 2.34e-14 ***
## log(dist) -0.086781 0.043281 -2.005 0.04549 *
## rooms -0.545113 0.165454 -3.295 0.00106 **
## I(rooms^2) 0.062261 0.012805 4.862 1.56e-06 ***
## stratio -0.047590 0.005854 -8.129 3.42e-15 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2592 on 500 degrees of freedom
## Multiple R-squared: 0.6028, Adjusted R-squared: 0.5988
## F-statistic: 151.8 on 5 and 500 DF, p-value: < 2.2e-16
data("attend")
(ornek6_3 <- lm(stndfnl~ atndrte*priGPA + ACT + I(priGPA^2) + I(ACT^2), data=attend))
##
## Call:
## lm(formula = stndfnl ~ atndrte * priGPA + ACT + I(priGPA^2) +
## I(ACT^2), data = attend)
##
## Coefficients:
## (Intercept) atndrte priGPA ACT I(priGPA^2)
## 2.050293 -0.006713 -1.628540 -0.128039 0.295905
## I(ACT^2) atndrte:priGPA
## 0.004533 0.005586
max(attend$priGPA)
## [1] 3.93
min(attend$priGPA)
## [1] 0.857
mean(attend$priGPA)
## [1] 2.586775
katsayi <- coef(ornek6_3)
katsayi["atndrte"]
## atndrte
## -0.006712928
katsayi["atndrte:priGPA"]
## atndrte:priGPA
## 0.005585907
katsayi["atndrte"] + mean(attend$priGPA)*katsayi["atndrte:priGPA"]
## atndrte
## 0.007736558
library(car)
## Zorunlu paket yükleniyor: carData
linearHypothesis(ornek6_3, c("atndrte + 2.59*atndrte:priGPA"))
## Linear hypothesis test
##
## Hypothesis:
## atndrte + 2.59 atndrte:priGPA = 0
##
## Model 1: restricted model
## Model 2: stndfnl ~ atndrte * priGPA + ACT + I(priGPA^2) + I(ACT^2)
##
## Res.Df RSS Df Sum of Sq F Pr(>F)
## 1 674 519.34
## 2 673 512.76 1 6.5772 8.6326 0.003415 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1