cparlogit: Conditionally Parametric logit for two or more choices

Description Usage Arguments Details Value References See Also Examples

View source: R/cparlogit.R

Description

Estimates a logit model with two choices by maximizing a locally weighted likelihood function – the logit equivalent of cparlwr

Usage

1
2
3
 
cparlogit(form,nonpar,window=.25,bandwidth=0,kern="tcub",
distance="Mahal",target=NULL,data=NULL,minp=NULL)  

Arguments

form

Model formula

nonpar

List of either one or two variables for z. Formats: cparlogit(y~xlist, nonpar=~z1, ...) or cparlogit(y~xlist, nonpar=~z1+z2, ...). Important: note the "~" before the first z variable.

window

Window size. Default: 0.25.

bandwidth

Bandwidth. Default: not used.

kern

Kernel weighting functions. Default is the tri-cube. Options include "rect", "tria", "epan", "bisq", "tcub", "trwt", and "gauss".

distance

Options: "Euclid", "Mahal", or "Latlong" for Euclidean, Mahalanobis, or "great-circle" geographic distance. May be abbreviated to the first letter but must be capitalized. Note: cparlogit looks for the first two letters to determine which variable is latitude and which is longitude, so the data set must be attached first or specified using the data option; options like data$latitude will not work. Default: Mahal.

target

If target = NULL, uses the maketarget command to form targets using the values specified for window, bandwidth, and kern. If target="alldata", each observation is used as a target value for x. A set of target values can be supplied directly.

data

A data frame containing the data. Default: use data in the current working directory

minp

Specifies a limit for the estimated probability. Any estimated probability lower than minp will be set to minp and any probability higher than 1-minp will be set to 1-minp. By default, the estimated probabilities are bounded by 0 and 1.

Details

The list of explanatory variables is specified in the base model formula while Z is specified using nonpar. X can include any number of explanatory variables, but Z must have at most two.

The model is estimated by maximizing the following weighted log-likelihood function at each target point:

∑ w_i { y_i log(P_i) + (1-y_i) log(1-P_i ) }

where y is the discrete dependent variable, X is the set of explanatory variables, and P_i = exp(X_i β) / (1+ exp(X_i β)).

When Z includes a single variable, w_i is a simple kernel weighting function: w_i = K((z_i - z_0 )/(sd(z)*h)) . When Z includes two variables (e.g., nonpar=~z1+z2), the method for specifying w depends on the distance option. Under either option, the ith row of the matrix Z = (z1, z2) is transformed such that z_i = sqrt(z_i * V * t(z_i)). Under the "Mahal" option, V is the inverse of cov(Z). Under the "Euclid" option, V is the inverse of diag(cov(Z)). After this transformation, the weights again reduce to the simple kernel weighting function K((z_i - z_0 )/(sd(z)*h)). h is specified by the bandwidth or window option.

The great circle formula is used to construct the distances used to form the weights when distance = "Latlong"; in this case, the variable list for nonpar must be listed as nonpar = ~latitude+longitude (or ~lo+la or ~lat+long, etc), with the longitude and latitude variables expressed in degrees (e.g., -87.627800 and 41.881998 for one observation of longitude and latitude, respectively). The order in which latitude and longitude are listed does not matter and the function only looks for the first two letters to determine which variable is latitude and which is longitude. It is important to note that the great circle distance measure is left in miles rather than being standardized. Thus, the window option should be specified when distance = "Latlong" or the bandwidth should be adjusted to account for the scale. The kernel weighting function becomes K(distance/h) under the "Latlong" option.

Following White (1982), the covariance matrix for a quasi-maximum likelihood model is A^{-1}BA^{-1} , where

A = ∑ w_i d^2LnL_i/dβ dβ'

B = ∑ w_i^2 (dLnL_i/dβ)(dLnL_i/dβ')

For the logit model,

A = ∑ w_i P_i(1 - P_i) X_i X_i'

B = ∑ w_i^2 (y_i - P_i)^2 X_i X_i'

The covariance matrix is calculated at all target points and the implied standard errors are then interpolated to each data point.

Available kernel weighting functions include the following:

Kernel Call abbreviation Kernel function K(z)
Rectangular ``rect'' 1/2 * I(|z|<1)
Triangular ``tria'' (1-|z|) * I(|z|<1)
Epanechnikov ``epan'' 3/4 * (1-z^2)*I(|z| < 1)
Bi-Square ``bisq'' 15/16 * (1-z^2)^2 * I(|z| < 1)
Tri-Cube ``tcub'' 70/81 * (1-|z|^3)^3 * I(|z| < 1)
Tri-Weight ``trwt'' 35/32 * (1-z^2)^3 * I(|z| < 1)
Gaussian ``gauss'' 2pi^{-.5} exp(-z^2/2)

Value

target

The target points for the original estimation of the function.

xcoef.target

Estimated coefficients, B(z), at the target values of z.

xcoef.target.se

Standard errors for B(z) at the target values of z.

xcoef

Estimated coefficients, B(z), at the original data points.

xcoef.se

Standard errors for B(z) with z evaluated at all points in the data set.

p

The estimated probabilities.

lnl

The log-likelihood value.

References

Fan, Jianqing, Nancy E. Heckman, and M.P. Wand, "Local Polynomial Kernel Regression for Generalized Linear Models and Quasi-Likelihood Functions," Journal of the American Statistical Association 90 (1995), 141-150.

Loader, Clive. Local Regression and Likelihood. New York: Springer, 1999.

McMillen, Daniel P. and John F. McDonald, "Locally Weighted Maximum Likelihood Estimation: Monte Carlo Evidence and an Application," in Luc Anselin, Raymond J.G.M. Florax, and Sergio J. Rey, eds., Advances in Spatial Econometrics, Springer-Verlag, New York (2004), 225-239.

Tibshirani, Robert and Trevor Hastie, "Local Likelihood Estimation," Journal of the American Statistical Association 82 (1987), 559-568.

See Also

cparprobit

cparmlogit

gmmlogit

gmmprobit

splogit

spprobit

spprobitml

Examples

1
2
3
4
5
6
7
8
9
set.seed(5647)
data(cookdata)
cookdata <- cookdata[!is.na(cookdata$AGE),]
n = nrow(cookdata)
cookdata$ystar <- cookdata$DCBD - .5*cookdata$AGE
cookdata$y <- cookdata$ystar - mean(cookdata$ystar) + rnorm(n,sd=4) > 0

fit  <- cparlogit(y~DCBD+AGE,~LONGITUDE+LATITUDE,window=.5,
  distance="Latlong",data=cookdata,minp=0.001)

McSpatial documentation built on May 30, 2017, 12:34 a.m.