R: Probability trend for a continuous variable in an ordered...
ocProb
R Documentation
Probability trend for a continuous variable in an ordered choice model
Description
This function computes the probability values for a continuous variable, based on an ordered choice model. Either an ordered probit or logit model can be used.
Usage
ocProb(w, nam.c, n = 100, digits = 3)
Arguments
w
a object of class of "polr" estimated from polr from the MASS library.
n
number of points for calculating probability; the large the number, the smoother the curve.
nam.c
a name of a continuous indepedent variable; this must be given for the function to work.
digits
number of digitis for output formatting.
Details
This function computes the probability values associated with a continous variable in an ordered probit or logit model. The standard errors of each probability value by factor level is computed using delta method. The software of LIMDEP is used to compare and benchmark the results.
Value
Return a list object of class "ocProb" with the following components:
Greene, W.H. 2003. Econometric Analysis (5th ed.). Prentice Hall, New York. 1026 P.
See Also
ocME
Examples
# Loading data from the MASS library
library(MASS)
data(housing)
str(housing); head(housing)
# Fit an ordered choice model with polr from the MASS library
# Note this is a fake specification
# The variable of "Freq" is included to have a
# continuous variable for demonstration.
fm2 <- Sat ~ Infl + Type + Cont + Freq
rc <- polr(fm2, data = housing, Hess = TRUE, method = "probit")
rd <- polr(fm2, data = housing, Hess = TRUE, method = "logistic")
summary(rc); summary(rd)
# Compute predicated probabilities with one continous variable
(fa <- ocProb(w = rc, nam.c = 'Freq', n = 300))
(fb <- ocProb(w = rd, nam.c = 'Freq', n = 300))
plot(fa)
plot(fb)