Title: | Additional Families for Generalized Linear Models |
---|---|
Description: | Creates family objects identical to stats family but for new links. |
Authors: | Greg McMahan |
Maintainer: | Greg McMahan <[email protected]> |
License: | GPL-3 |
Version: | 0.2.4 |
Built: | 2025-01-20 05:11:25 UTC |
Source: | https://github.com/gmcmacran/extendedfamily |
Additional Binomial Links For Generalized Linear Models
binomialEF(link = "loglog", alpha = 1)
binomialEF(link = "loglog", alpha = 1)
link |
name of link function. One of loglog, logc, identity, or odds-power (Default: loglog) |
alpha |
power for odds-power link. Not used otherwise. (Default: 1) |
family is a generic function with methods for classes "glm" and "lm".
The loglog link works well for many datasets. The range of the link is negative infinity to positive infinity. For all other links, this is not true. This can cause a failure to converge in R's glm function. If this happens, the link does not work well for the training data. Try another link.
An object of class "family" (which has a concise print method). This is a list with elements
family: character: the family name.
link: character: the link name.
linkfun: function: the link.
linkinv: function: the inverse of the link function.
variance: function: the variance as a function of the mean.
dev.resids function giving the deviance for each observation as a function of (y, mu, wt), used by the residuals method when computing deviance residuals.
aic: function giving the AIC value if appropriate (but NA for the quasi- families). More precisely, this function returns -2 ll + 2 s, where ll is the log-likelihood and s is the number of estimated scale parameters. Note that the penalty term for the location parameters (typically the “regression coefficients”) is added elsewhere, e.g., in glm.fit() or AIC(), see the AIC example in glm. See logLik for the assumptions made about the dispersion parameter.
initialize: expression. This needs to set up whatever data objects are needed for the family as well as n (needed for AIC in the binomial family) and mustart (See glm)
validmu: logical function. Returns TRUE if a mean vector mu is within the domain of variance.
valideta: logical function. Returns TRUE if a linear predictor eta is within the domain of linkinv.
simulate: (optional) function simulate(object, nsim) to be called by the "lm" method of simulate. It will normally return a matrix with nsim columns and one row for each fitted value, but it can also return a list of length nsim. Clearly this will be missing for ‘quasi-’ families.
dispersion: (optional for R >= 4.3.0) numeric: value of the dispersion parameter, if fixed, or NA_real_ if free.
library(stats) library(extendedFamily) # loglog example data(heart) model <- glm( formula = death ~ anterior + hcabg + kk2 + kk3 + kk4 + age2 + age3 + age4, data = heart, family = binomialEF(link = "loglog") )
library(stats) library(extendedFamily) # loglog example data(heart) model <- glm( formula = death ~ anterior + hcabg + kk2 + kk3 + kk4 + age2 + age3 + age4, data = heart, family = binomialEF(link = "loglog") )
A dataset containing 4,483 rows about heart attack victims.
data(heart)
data(heart)
A data frame with 4,483 rows and 11 variables:
1 - Death within 48 hours of myocardial infarction onset. 0 - otherwise.
1 - anterior infarction. 0 - inferior infarction
1 - Medical history of cardiac bypass surgery. 0 - otherwise
1 - Killip class 1. 0 - otherwise
1 - Killip class 2. 0 - otherwise
1 - Killip class 3. 0 - otherwise
1 - Killip class 4. 0 - otherwise
1 - Patient age less than 60. 0 - otherwise
1 - Patient age between 60 and 69 inclusive. 0 - otherwise
1 - Patient age between 70 and 79 inclusive. 0 - otherwise
1 - Patient age 80 or higher. 0 - otherwise
The raw dataset is minimally modified in this package. Rows containing missing values were removed. The center variable was dropped. This data is referred to as "heart01" in Generalized Linear Models and Extensions book.
Hardin, James William., and Joseph Hilbe. Generalized Linear Models and Extensions. Stata Press, 2012.
Dataset can be downloaded at https://www.stata-press.com/data/glmext.html