Learn R Programming

gnm (version 0.9-9)

pickCoef: Get Indices For Selected Model Coefficients

Description

Get the indices for a subset of model coefficients selected via a Tk dialog or by regular expression matching.

Usage

pickCoef(object, regexpr = NULL, ...)

Arguments

object
a model object.
regexpr
character string containing a regular expression. If missing, a Tk dialog will open for coefficient selection.
...
arguments to pass on to relimp:::pickFrom.

Value

  • A named vector of indices, or NULL.

See Also

regexp, grep, ofInterest

Examples

Run this code
set.seed(1)

### Use with ofInterest
data(yaish)
## fit the "UNIDIFF" mobility model across education levels
unidiff <- gnm(Freq ~ educ*orig + educ*dest +
               Mult(Exp(educ), orig:dest),
               family = poisson, data = yaish, subset = (dest != 7))

## set coefficients in first constituent multiplier as 'ofInterest'
ofInterest(unidiff) <- pickCoef(unidiff, "[.]educ")

## summarise model, only showing coefficients of interest
summary(unidiff)

## get contrasts of these coefficients
getContrasts(unidiff, ofInterest(unidiff))

### Use to pick out coefficients relating to different groups
data(voting)
## reconstruct counts voting Labour/non-Labour
count <- with(voting, percentage/100 * total)
yvar <- cbind(count, voting$total - count)
## create factors indicating movement in and out of salariat (class 1)
upward <- with(voting, origin != 1 & destination == 1)
downward <- with(voting, origin == 1 & destination != 1)

## fit separate weights for the "socially mobile" groups
socialMobility <- gnm(yvar ~ -1 + Dref(origin, destination,
                                       delta = ~ 1 + downward + upward),
                      family = binomial, data = voting)
## calculate weights
DrefWeights(socialMobility)

Run the code above in your browser using DataLab