R: Average Effects for Proportional Odds Logistic Regression...
ordChange2
R Documentation
Average Effects for Proportional Odds Logistic Regression Models
Description
For objects of class polr, it calculates the average change in predicted probabilities, for discrete changes in a covariate holding all other variables at their observed values.
A string identifying the variable to be manipulated.
data
Data frame used to fit object.
diffchange
A string indicating the difference in predictor values to calculate the discrete change. sd gives plus and minus one-half standard deviation change around the median and unit gives a plus and minus one-half unit change around the median.
R
Number of simulations.
Details
The function calculates the changes in predicted probabilities for maximal discrete changes in the covariates for objects of class polr. This function works with polynomials specified with the poly function. It also works with multiplicative interactions of the covariates by virtue of the fact that it holds all other variables at typical values. By default, typical values are the median for quantitative variables and the mode for factors. The way the function works with factors is a bit different. The function identifies the two most different levels of the factor and calculates the change in predictions for a change from the level with the smallest prediction to the level with the largest prediction.
Value
A list with the following elements:
diffs
A matrix of calculated first differences
minmax
A matrix of values that were used to calculate the predicted changes
minPred
A matrix of predicted probabilities when each variable is held at its minimum value, in turn.
maxPred
A matrix of predicted probabilities when each variable is held at its maximum value, in turn.
Author(s)
Dave Armstrong (UW-Milwaukee, Department of Political Science)
Examples
library(MASS)
data(france)
polr.mod <- polr(vote ~ age + male + retnat + lrself, data=france)
typical.france <- data.frame(
age = 35,
retnat = factor(1, levels=1:3, labels=levels(france$retnat))
)
ordChange2(polr.mod, "age", data=france, diffchange="sd")
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(DAMisc)
Loading required package: car
Loading required package: effects
Attaching package: 'effects'
The following object is masked from 'package:car':
Prestige
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/DAMisc/ordChange2.Rd_%03d_medium.png", width=480, height=480)
> ### Name: ordChange2
> ### Title: Average Effects for Proportional Odds Logistic Regression Models
> ### Aliases: ordChange2
>
> ### ** Examples
>
> library(MASS)
> data(france)
> polr.mod <- polr(vote ~ age + male + retnat + lrself, data=france)
> typical.france <- data.frame(
+ age = 35,
+ retnat = factor(1, levels=1:3, labels=levels(france$retnat))
+ )
> ordChange2(polr.mod, "age", data=france, diffchange="sd")
Re-fitting to get Hessian
$mean
age
PCF -0.011401073
PS -0.014308656
Green 0.001337537
RPR 0.007758912
UDF 0.016613280
$lower
age
PCF -0.038277325
PS -0.030798067
Green -0.009982245
RPR -0.017950814
UDF 0.000949064
$upper
age
PCF -0.000281591
PS 0.028561574
Green 0.010765520
RPR 0.020035052
UDF 0.035856434
>
>
>
>
>
> dev.off()
null device
1
>