-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathdetails_poisson_reg_gee.Rd
114 lines (89 loc) · 3.94 KB
/
details_poisson_reg_gee.Rd
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/poisson_reg_gee.R
\name{details_poisson_reg_gee}
\alias{details_poisson_reg_gee}
\title{Poisson regression via generalized estimating equations (GEE)}
\description{
\code{gee::gee()} uses generalized least squares to fit different types of models
with errors that are not independent.
}
\details{
For this engine, there is a single mode: regression
\subsection{Tuning Parameters}{
This model has no formal tuning parameters. It may be beneficial to
determine the appropriate correlation structure to use, but this
typically does not affect the predicted value of the model. It \emph{does}
have an effect on the inferential results and parameter covariance
values.
}
\subsection{Translation from parsnip to the original package}{
The \strong{multilevelmod} extension package is required to fit this model.
\if{html}{\out{<div class="sourceCode r">}}\preformatted{library(multilevelmod)
poisson_reg(engine = "gee") \%>\%
set_engine("gee") \%>\%
translate()
}\if{html}{\out{</div>}}
\if{html}{\out{<div class="sourceCode">}}\preformatted{## Poisson Regression Model Specification (regression)
##
## Computational engine: gee
##
## Model fit template:
## multilevelmod::gee_fit(formula = missing_arg(), data = missing_arg(),
## family = stats::poisson)
}\if{html}{\out{</div>}}
\code{multilevelmod::gee_fit()} is a wrapper model around \code{gee()}.
}
\subsection{Preprocessing requirements}{
There are no specific preprocessing needs. However, it is helpful to
keep the clustering/subject identifier column as factor or character
(instead of making them into dummy variables). See the examples in the
next section.
}
\subsection{Case weights}{
The underlying model implementation does not allow for case weights.
}
\subsection{Other details}{
Both \code{gee:gee()} and \code{gee:geepack()} specify the id/cluster variable
using an argument \code{id} that requires a vector. parsnip doesn’t work that
way so we enable this model to be fit using a artificial function
\code{id_var()} to be used in the formula. So, in the original package, the
call would look like:
\if{html}{\out{<div class="sourceCode r">}}\preformatted{gee(breaks ~ tension, id = wool, data = warpbreaks, corstr = "exchangeable")
}\if{html}{\out{</div>}}
With parsnip, we suggest using the formula method when fitting:
\if{html}{\out{<div class="sourceCode r">}}\preformatted{library(tidymodels)
poisson_reg() \%>\%
set_engine("gee", corstr = "exchangeable") \%>\%
fit(y ~ time + x + id_var(subject), data = longitudinal_counts)
}\if{html}{\out{</div>}}
When using tidymodels infrastructure, it may be better to use a
workflow. In this case, you can add the appropriate columns using
\code{add_variables()} then supply the GEE formula when adding the model:
\if{html}{\out{<div class="sourceCode r">}}\preformatted{library(tidymodels)
gee_spec <-
poisson_reg() \%>\%
set_engine("gee", corstr = "exchangeable")
gee_wflow <-
workflow() \%>\%
# The data are included as-is using:
add_variables(outcomes = y, predictors = c(time, x, subject)) \%>\%
add_model(gee_spec, formula = y ~ time + x + id_var(subject))
fit(gee_wflow, data = longitudinal_counts)
}\if{html}{\out{</div>}}
The \code{gee::gee()} function always prints out warnings and output even
when \code{silent = TRUE}. The parsnip \code{"gee"} engine, by contrast, silences
all console output coming from \code{gee::gee()}, even if \code{silent = FALSE}.
Also, because of issues with the \code{gee()} function, a supplementary call
to \code{glm()} is needed to get the rank and QR decomposition objects so
that \code{predict()} can be used.
}
\subsection{References}{
\itemize{
\item Liang, K.Y. and Zeger, S.L. (1986) Longitudinal data analysis using
generalized linear models. \emph{Biometrika}, 73 13–22.
\item Zeger, S.L. and Liang, K.Y. (1986) Longitudinal data analysis for
discrete and continuous outcomes. \emph{Biometrics}, 42 121–130.
}
}
}
\keyword{internal}