Learn R Programming

broom (version 0.4.5)

ivreg_tidiers: Tidiers for ivreg models

Description

Tidiers for ivreg models

Usage

# S3 method for ivreg
tidy(x, conf.int = FALSE, conf.level = 0.95,
  exponentiate = FALSE, ...)

# S3 method for ivreg augment(x, data = as.data.frame(stats::model.frame(x)), newdata, ...)

# S3 method for ivreg glance(x, diagnostics = FALSE, ...)

Arguments

x

An "ivreg" object

conf.int

Whether to include a confidence interval

conf.level

Confidence level of the interval, used only if conf.int=TRUE

exponentiate

Whether to exponentiate the coefficient estimates and confidence intervals

...

extra arguments, not used

data

Original dataset

newdata

New data to make predictions from (optional)

diagnostics

Logical. Return results of diagnostic tests.

Value

All tidying methods return a data.frame without rownames, whose structure depends on the method chosen.

tidy.ivreg returns a data frame with one row per coefficient, of the same form as tidy.lm.

augment returns a data frame with one row for each initial observation, adding the columns:

.fitted

predicted (fitted) values

and if newdata is NULL:
.resid

residuals

glance returns a one-row data frame with columns

r.squared

The percent of variance explained by the model

adj.r.squared

r.squared adjusted based on the degrees of freedom

statistic

Wald test statistic

p.value

p-value from the Wald test

df

Degrees of freedom used by the coefficients

sigma

The square root of the estimated residual variance

df.residual

residual degrees of freedom

If diagnostics is TRUE, glance also returns:
p.value.Sargan

P value of Sargan test

p.value.Wu.Hausman

P value of Wu-Hausman test

p.value.weakinst

P value of weak instruments test

See Also

lm_tidiers

Examples

Run this code
# NOT RUN {
if (require("AER", quietly = TRUE)) {
    data("CigarettesSW", package = "AER")
    CigarettesSW$rprice <- with(CigarettesSW, price/cpi)
    CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi)
    CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi)
    ivr <- ivreg(log(packs) ~ log(rprice) + log(rincome) | log(rincome) + tdiff + I(tax/cpi),
          data = CigarettesSW, subset = year == "1995")
    
    summary(ivr)
    
    tidy(ivr)
    tidy(ivr, conf.int = TRUE)
    tidy(ivr, conf.int = TRUE, exponentiate = TRUE)
    
    head(augment(ivr))
    
    glance(ivr)
}

# }

Run the code above in your browser using DataLab