Learn R Programming

netCoin (version 2.1.49)

glmCoin: Regression Graphs

Description

produces a netCoin object from a set of glm regressions.

Usage

glmCoin(formulas, data, weights=NULL, pmax=.05,
        robust=FALSE, showArrows=TRUE,
        color="variable", lwidth="s.value", lcolor="estimate",
        language=c("en","es","ca"),
        igraph=FALSE, ...)

Value

This function creates a netCoin object (or igraph) and, if stated, a folder in the computer with an HTML document named index.html which contains the produced graph. This file can be directly opened with your browser and sent to a web server to work properly.

The links of the graph carry the average marginal effects as GW contrasts (estimate, std.error, p.value: effects relative to the weighted overall mean) and also relative to the first category of each qualitative variable (estimate.base, std.error.base, p.value.base; for the base category itself the estimate is 0 and its standard error and p value are NA). Both sets can be displayed with marginsTable.

The netCoin object also includes a data frame named equations with one row per declared equation and the following goodness-of-fit measures: model (formula), family (declared family), n (number of observations; the sum of weights in weighted models), n_obs (number of observed cases, regardless of weights), r2 (deviance-based R2: 1-deviance/null deviance, which equals the classical R2 for gaussian models), r2.mcfadden (McFadden's pseudo-R2, NA for quasi families), r2.nagelkerke (Nagelkerke's pseudo-R2), logLik, aic, bic (NA for quasi families), deviance, null.deviance and df.residual. When igraph=TRUE, this data frame is attached as the graph attribute equations.

It also includes a list named coeffs with one data frame of regression coefficients per equation, in the same order as the rows of equations. Each data frame has one row per coefficient and response category, with columns Target (the response, or response:category in binomial and multinomial models), term (the name given by the fitted model), Source (the same term written as a node name, so that it can be matched against nodes and links), factor (whether the term involves a qualitative variable), estimate, std.error, statistic, p.value, conf.low, conf.high and sd.x (the weighted standard deviation of the term, NA for the constant). The attributes family, link, sd.y (the weighted standard deviation of the response, NA unless it is on its own scale) and latent.sd (the standard deviation of the underlying latent variable, per Target, NA unless the link is logit or probit) record the scales needed to standardize or exponentiate the estimates. These are the coefficients that coefTable displays; note that they are not the marginal effects carried by the links. When igraph=TRUE, this list is attached as the graph attribute coeffs.

Arguments

formulas

A set of formulas separated, folowed by the family and a return. For example: model <- "counts ~ outcome + treatment, poisson counts ~ outcome, poisson" The possible families are gaussian (default), poisson, binomial and multinomial.

data

Data frame containing the variables in the model.

weights

Optional vector of weights to be used in the fitting process.

pmax

Selection of links with Pr(>|z|) less than p (one-tail by default).

robust

Robust estimation of standard errors if TRUE.

showArrows

a logical value true if the directional arrows are to be shown. Default = FALSE.

color

Nodes' attribute to be used for expressing color ("variable" by default).

lwidth

Nodes' attribute to be used for widht of arrows ("s.value" by default).

lcolor

Nodes' attribute to be used for color of arrows ("estimate" by default).

language

Language of the graph controls.

igraph

Produces an igraph object instead of a netCoin object if TRUE.

...

Any netCoin argument.

Author

Modesto Escobar, Department of Sociology and Communication, University of Salamanca.

Examples

Run this code
## Dobson (1990) Page 93: Randomized Controlled Trial :
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
Dobson <- data.frame(counts=counts, outcome=outcome, treatment=treatment)
model <- "counts ~ outcome + treatment, poisson"
glmCoin(model,Dobson)

## Multinomial model: housing satisfaction in Copenhagen (Madsen, 1976)
data(housing, package="MASS")
g <- glmCoin("Sat ~ Infl + Type + Cont, multinomial", housing, weights="Freq")
g$equations

Run the code above in your browser using DataLab