ocProb: Probability trend for a continuous variable in an ordered...

View source: R/ocProb.r

ocProbR 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:

w, nam.c, method=w$method, mean.x=colMeans(x), out, lev)

w

an object of class "polr"

nam.c

the name of a continous variable

method

type of the ordered choice model of w, either "probit" or "logistic"

mean.x

mean values of the independent variables used in w

out

This is a list object with the estimated probability values, standard errors, t values, and p values for each of the factor level in lev.

lev

a character string representing the factor level used in w

Methods

Two methods are defined as follows:

print:

print the probability output.

plot:

Plot the probability values for a continuous variable.

Author(s)

Changyou Sun (edwinsun258@gmail.com)

References

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) 

erer documentation built on Sept. 26, 2024, 5:06 p.m.