Description Usage Arguments Details Value Author(s) References See Also Examples
Userfriendly generation of fitted values and their confidence intervals
from models of class "polywog"
, using the "observedvalue approach"
advocated by Hanmer and Kalkan (2013).
1 2 3 
model 
a fitted model of class 
xvars 
a character vector containing names of raw input variables
(from 
data 
data frame to treat as the observed sample (defaults to the data used to fit the supplied model) 
xlims 
named list of limits for the evaluation grid for each
continuous variable in 
n 
number of grid points at which to evaluate each continuous variable
in 
interval 
logical: whether to compute bootstrap confidence intervals for each fitted value. 
level 
confidence level for the intervals. 
maxrows 
maximum number of rows of output. Used to prevent accidental
memory overruns when 
report 
logical: whether to print a status bar. Not available if

.parallel 
logical: whether to perform bootstrap iterations in
parallel using 
... 
other arguments, currently ignored 
predVals
allows users to examine the estimated effects of input
variables on the expected outcome using the coefficients returned by
polywog
. The procedure is designed so that, for a preliminary
analysis, the user can simply specify the fitted model and the independent
variable of interest, and quickly obtain predicted values.
The predicted values are generated according to Hanmer and Kalkan's (2013)
observedvalue approach, which takes the form of a nested loop. When
xvars
contains a single variable X_m, the procedure is as
follows:
For each level x of X_m in data
(if X_m
is discrete) or each element x of a grid over the range of X_m
in data
(if X_m is continuous):
For each observation i of data
:
Set X_{mi} = x, while holding all other variables X_{mi} at their observed levels
Compute the predicted value of Y_i for the modified
observation i, using the estimated model coefficients (as in
predict.polywog
)
The predicted value of Y given X_m = x is the average of the predictions computed in the previous step
This observedvalue approach provides a better estimate of population
average effects for nonlinear models than does the traditional approach,
which is to vary X_m across its levels/range while holding each
other covariate to its mean or median in data
(Hanmer and Kalkan
2013).
When xvars
consists of multiple variables X_1, ..., X_M, the predVals
procedure is the same, except the
outer loop is over every combination of their levels in
data
.
All confidence intervals are generated via the bootstrap. Specifically,
predVals
repeats the above procedure for each set of bootstrap
coefficients and computes order statistics of the resulting set of
averages (for each combination of levels of xvars
). If
model
does not have a boot.matrix
element (see
bootPolywog
), confidence intervals will not be computed.
A data frame containing the fitted values and confidence intervals (if requested) for each combination of covariate values.
The returned data frame also inherits from class "preplot.polywog"
.
This is used by plot.polywog
, which calls predVals
to
compute the values to plot.
Brenton Kenkel and Curtis S. Signorino
Michael J. Hanmer and Kerem Ozan Kalkan. 2013. "Behind the Curve: Clarifying the Best Approach to Calculating Predicted Probabilities and Marginal Effects from Limited Dependent Variable Models." American Journal of Political Science 57(1):263–277.
predict.polywog
for more flexible (but less
userfriendly) computation of fitted values. plot.polywog
for
plotting fitted values and their confidence intervals.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  ## Using occupational prestige data
data(Prestige, package = "carData")
Prestige < transform(Prestige, income = income / 1000)
## Fit a polywog model with bootstrap iterations
## (note: using low convergence threshold to shorten computation time of the
## example, *not* recommended in practice!)
set.seed(22)
fit1 < polywog(prestige ~ education + income + type,
data = Prestige,
degree = 2,
boot = 5,
thresh = 1e4)
## Predicted prestige across occupational categories
predVals(fit1, "type")
## Predicted prestige by education
predVals(fit1, "education", n = 10)
## Plotting
pred_income < predVals(fit1, "income", n = 10)
plot(pred_income)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.