qvcalc                package:qvcalc                R Documentation

_Q_u_a_s_i _V_a_r_i_a_n_c_e_s _f_o_r _M_o_d_e_l _C_o_e_f_f_i_c_i_e_n_t_s

_D_e_s_c_r_i_p_t_i_o_n:

     Computes a set of quasi variances (and corresponding quasi
     standard errors) for estimated model coefficients relating to the
     levels of a categorical (i.e., factor) explanatory variable.  For
     details of the method see Firth (2000) or Firth and Menezes
     (2004).

_U_s_a_g_e:

     qvcalc(object, factorname=NULL, labels = NULL, dispersion = NULL,
           estimates=NULL,  modelcall=NULL)

_A_r_g_u_m_e_n_t_s:

  object: A model (of class lm, glm, etc.), or the covariance
          (sub)matrix for the estimates of interest

factorname: If 'object' is a model, the name of the factor of interest

  labels: An optional vector of row names for the 'qvframe' component
          of the result (redundant if 'object' is a model)

dispersion: an optional scalar multiplier for the covariance matrix, to
          cope with overdispersion for example

estimates: an optional vector of estimated coefficients (redundant if
          'object' is a model)

modelcall: optional, the call expression for the model of interest
          (redundant if 'object' is a model)

_D_e_t_a_i_l_s:

     Ordinarily the quasi variances are positive and so their square
     roots (the quasi standard errors) exist and can be used in plots,
     etc.

     Occasionally one (and only one) of the quasi variances is
     negative, and so the corresponding quasi standard error does not
     exist (it appears as 'NaN').  This is fairly rare in applications,
     and when it occurs it is because the factor of interest is
     strongly correlated with one or more other predictors in the
     model.  It is not an indication that quasi variances are
     inaccurate.  An example is shown below using data from the 'car'
     package: the quasi variance approximation is exact (since 'type'
     has only 3 levels), and there is a negative quasi variance.  The
     quasi variances remain perfectly valid (they can be used to obtain
     inference on any contrast), but it makes no sense to plot
     `comparison intervals' in the usual way since one of the quasi
     standard errors is not a real number.

_V_a_l_u_e:

     A list of class 'qv', with components 

  covmat: the full variance-covariance matrix for the estimated 
          coefficients corresponding to the factor of interest

 qvframe: a data frame with variables 'estimate', 'SE', 'quasiSE' and
          'quasiVar', the last two being a quasi standard error and
          quasi-variance for each level of the factor of interest

 relerrs: relative errors for approximating the standard errors of all 
          simple contrasts

factorname: the factor name if given

modelcall: if 'object' is a model, 'object$call'; otherwise 'NULL'

_A_u_t_h_o_r(_s):

     David Firth, d.firth@warwick.ac.uk

_R_e_f_e_r_e_n_c_e_s:

     Firth, D. (2000)  Quasi-variances in Xlisp-Stat and on the web.  
     _Journal of Statistical Software_ *5.4*, 1-13.   At <URL:
     http://www.jstatsoft.org>

     Firth, D. and Mezezes, R. X. de (2004)  Quasi-variances.  
     _Biometrika_ *91*, 65-80.  

     McCullagh, P. and Nelder, J. A. (1989) _Generalized Linear
     Models_. London: Chapman and Hall.

     Menezes, R. X. (1999)  More useful standard errors for group and
     factor effects in generalized linear models.  _D.Phil. Thesis_,
     Department of Statistics, University of Oxford.

_S_e_e _A_l_s_o:

     'worstErrors'

_E_x_a_m_p_l_e_s:

     ##  Overdispersed Poisson loglinear model for ship damage data
     ##  from McCullagh and Nelder (1989), Sec 6.3.2 
     library(MASS)
     data(ships)
     ships$year <- as.factor(ships$year)
     ships$period <- as.factor(ships$period)
     shipmodel <- glm(formula = incidents ~ type + year + period,
         family = quasipoisson, 
         data = ships, subset = (service > 0), offset = log(service))
     shiptype.qvs <- qvcalc(shipmodel, "type")
     summary(shiptype.qvs, digits=4)
     plot(shiptype.qvs)
     ## Not run: 
     ##  Example of a negative quasi variance
     ##  Requires the "car" package
     library(car)
     data(Prestige)
     attach(Prestige)
     mymodel <- lm(prestige ~ type + education)
     library(qvcalc)
     type.qvs <- qvcalc(mymodel, "type")
     ##  Warning message: 
     ##  NaNs produced in: sqrt(qv) 
     summary(type.qvs)
     ##  Model call:  lm(formula = prestige ~ type + education) 
     ##  Factor name:  type 
     ##          estimate       SE  quasiSE  quasiVar
     ##    bc    0.000000 0.000000 2.874361  8.261952
     ##    prof  6.142444 4.258961 3.142737  9.876793
     ##    wc   -5.458495 2.690667      NaN -1.022262
     ##  Worst relative errors in SEs of simple contrasts (%):  0 0 
     ##  Worst relative errors over *all* contrasts (%):  0 0
     plot(type.qvs)
     ##  Error in plot.qv(type.qvs) :  No comparison intervals available,
     ##  since one of the quasi variances is negative.  See ?qvcalc for more.
     ## End(Not run) 

