glmPQL: Compute PQL estimates for fixed effects from a generalized...

Description Usage Arguments Value Examples

View source: R/glm_PQL_Function.R

Description

Compute PQL estimates for fixed effects from a generalized linear model.

Usage

1
glmPQL(glm.mod, niter = 20, data = NULL)

Arguments

glm.mod

a generalized linear model fitted with the glm function.

niter

maximum number of iterations allowed in the PQL algorithm.

data

The data used by the fitted model. This argument is required for models with special expressions in their formula, such as offset, log, cbind(sucesses, trials), etc.

Value

A glmPQL object (i.e. a linear model using pseudo outcomes).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Load the datasets package for example code
library(datasets)
library(dplyr)

# We'll model the number of world changing discoveries per year for the
# last 100 years as a poisson outcome. First, we set up the data

dat = data.frame(discoveries) %>% mutate(year = 1:length(discoveries))

# Fit the GLM with a poisson link function
mod <- glm(discoveries~year+I(year^2), family = 'poisson', data = dat)

# Find PQL estimates using the original GLM
mod.pql = glmPQL(mod)

# Note that the PQL model yields a higher R Squared statistic
# than the fit of a strictly linear model. This is attributed
# to correctly modelling the distribution of outcomes and then
# linearizing the model to measure goodness of fit, rather than
# simply fitting a linear model

summary(mod.pql)
summary(linfit <- lm(discoveries~year+I(year^2), data = dat))

r2beta(mod.pql)
r2beta(linfit)

r2glmm documentation built on May 1, 2019, 9:09 p.m.