First, some model taken from the help file of function ivreg
.
library(AER)
data("CigarettesSW")
CigarettesSW$rprice <- with(CigarettesSW, price/cpi)
CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi)
CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi)
## model
fm <- ivreg(log(packs) ~ log(rprice) + log(rincome) | log(rincome) +
tdiff + I(tax/cpi),
data = CigarettesSW, subset = year == "1995")
p-values, t-values and so are calculated only when you call summary()
function on your model. At this time actually function summary.ivreg()
is called. So if you need to get only p-values you should save result of summary()
as some object. This object (list) contains several parts and coefficients are stored in matrix named coefficients
.
sum.res<-summary(fm)
names(sum.res)
[1] "call" "terms" "residuals" "" "coefficients" "sigma"
[7] "df" "r.squared" "adj.r.squared" "waldtest" "vcov"
To get all coefficients:
sum.res$coefficients
Estimate Std. Error t value Pr(>|t|)
(Intercept) 9.8949555 1.0585599 9.347563 4.120910e-12
log(rprice) -1.2774241 0.2631986 -4.853461 1.496034e-05
log(rincome) 0.2804048 0.2385654 1.175379 2.460247e-01
p-values are stored in 4. column of this matrix:
sum.res$coefficients[,4]
(Intercept) log(rprice) log(rincome)
4.120910e-12 1.496034e-05 2.460247e-01