Last data update: 2014.03.03

R: Fitting GWRM Models
gwR Documentation

Fitting GWRM Models

Description

gw is used to fit Generalized Waring Regression Models (GWRM), specified by giving a symbolic description of the linear predictor.

Usage

gw(formula, data, weights, k = NULL, subset, na.action, kstart = 1,
  rostart = 2, betastart = NULL, offset, control = list(...),
  method = NULL, hessian = TRUE, model = TRUE, x = FALSE, y = TRUE,
  ...)

Arguments

formula

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted.

data

an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula).

weights

an optional vector of 'prior weights' to be used in the fitting process. Should be NULL or a numeric vector.

k

optional value for the k parameter. If NULL, it is estimated.

subset

an optional vector specifying a subset of observations to be used in the fitting process.

na.action

a function which indicates what should happen when the data contain NA values. See glm.

kstart

starting value for the k parameter.

rostart

starting value for the ro parameter.

betastart

starting values for the vector of means.

offset

this can be used to specify an a priori known component to be included in the linear predictor during fitting. This should be NULL or a numeric vector of length equal to the number of cases. One or more offset terms can be included in the formula instead or as well, and if more than one is specified their sum is used. See model.offset.

control

a list of parameters for controlling the fitting process.

method

the method to be used in fitting the model. The default method initially uses non-linear minimization (nlm) and Nelder-Mead optimization (optim) to fit a model which is then re-fitted by "L-BFGS-B" (optim). In this way, SE estimates for all the model parameters are provided. "nlm" and "Nelder-Mead" are also possible values, but they do not provide SE estimates for k and ro.

hessian

if TRUE, the hessian of f at the minimum is returned.

model

a logical value indicating whether model frame should be included as a component of the returned value.

x,y

For gw: logical values indicating whether the response vector and model matrix used in the fitting process should be returned as components of the returned value.

For gw.fit: x is a design matrix of dimension n * p, and y is a vector of observations of length n.

...

further arguments.

Value

gw returns an object of class "gw". The function summary can be used to obtain or print a summary of the results. An object of class "gw" is a list containing the following components:

  • Y if requested (the default), the y vector used.

  • W the weights supplied, a vector of 1s if none were.

  • covars names of the covariates in the model.

  • nobs number of observations.

  • covoffset a logical value specifying if an offset is present.

  • loglik the maximized log-likelihood.

  • aic a version of Akaike's An Information Criterion, minus twice the maximized log-likelihood plus twice the number of parameters.

  • bic Bayesian Information Criterion, minus twice the maximized log-likelihood plus the number of parameters multiplied by the logarithm of the number of observations.

  • df.residual the residual degrees of freedom.

  • residuals the residuals in the final iteration of the fit.

  • coefficients a named vector of coefficients.

  • betaIIpars parameters estimates of the BetaII distribution.

  • betascoefs a vector of coefficients.

  • fitted.values the fitted mean values, obtained by transforming the linear predictors by the inverse of the link function.

  • hessian a symmetric matrix giving an estimate of the Hessian at the solution found in the optimization of the log-likelihood function.

  • cov an estimate of the covariance matrix of the model coefficients.

  • se a vector of the standard errors estimates of the estimated coefficients.

  • corr an estimate of the correlation matrix of the model coefficients.

  • code a code that indicates successful convergence of the fitter function used (see nlm and optim helps).

  • converged logical value that indicates if the optimization algorithms succesfull.

  • method the name of the fitter function used.

  • k if requested, the k value used.

  • kBool a logical value specifying whether there is a k value or it is estimated.

  • call the matched call.

  • formula the formula supplied.

  • terms the terms object used.

  • data the data argument.

  • offset the offset vector used.

  • control the value of the control argument used.

  • method the name of the fitter function used.

  • contrasts (where relevant) the contrasts used.

  • xlevels (where relevant) a record of the levels of the factors used in fitting.

Examples

data(goals)
gw(goals ~ position + offset(log(played)), data = goals)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(GWRM)
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/GWRM/gw.Rd_%03d_medium.png", width=480, height=480)
> ### Name: gw
> ### Title: Fitting GWRM Models
> ### Aliases: gw gw.fit
> 
> ### ** Examples
> 
> data(goals)
> gw(goals ~ position + offset(log(played)), data = goals)

Call:  gw(formula = goals ~ position + offset(log(played)), data = goals)

Coefficients:
  (Intercept)  positionForward  positionMidfielder  k        ro     
  -3.0917       1.5677           0.6835             13.7908  12.8911

Degrees of Freedom: 1219 Residual
AIC: 3820
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>