[SOLVED] CS library(lmtest) # for coeftest()

$25

File Name: CS_library(lmtest)_#_for_coeftest().zip
File Size: 329.7 KB

5/5 - (1 vote)

library(lmtest) # for coeftest()
library(MASS) # for Boston housing data
data(Boston)# ?Boston; names(Boston)
# focusing here on a small sample case (n=20):
Boston_small <- Boston[1:20,]lm_obj <- lm(medv ~ ptratio + lstat + nox + crim, data = Boston_small)round(coeftest(lm_obj), 2)#> t test of coefficients:
#>
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 112.5939.862.82 0.01 **
#> ptratio-0.92 1.00 -0.92 0.37
#> lstat-0.47 0.18 -2.57 0.02 *
#> nox-134.7253.73 -2.51 0.02 *
#> crim4.99 8.650.58 0.57
#>
#> Signif. codes:0 *** 0.001 ** 0.01 * 0.05 . 0.1 1

library(car)
linearHypothesis(lm_obj, c(lstat=0, nox=0))

#> Linear hypothesis test
#>
#> Hypothesis:
#> lstat = 0
#> nox = 0
#>
#> Model 1: restricted model
#> Model 2: medv ~ ptratio + lstat + nox + crim
#>
#> Res.DfRSS Df Sum of SqFPr(>F)
#> 1 17 344.27
#> 2 15 190.402153.88 6.0614 0.01177 *
#>
#> Signif. codes:0 *** 0.001 ** 0.01 * 0.05 . 0.1 1

install.packages(sandwich)
install.packages(lmtest)
install.packages(car)
install.packages(AER)

library(sandwich)
library(lmtest)
library(car)
library(AER)

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] CS library(lmtest) # for coeftest()
$25