cparlwr(form,nonpar,window=.25,bandwidth=0,kern="tcub", distance="Mahal",targetobs=NULL,data=NULL)
The estimated value of y at a target value $z_0$ is the predicted value from a weighted least squares regression of y on X with weights given by K. When Z includes a single variable, K is a simple kernel weighting function: $K((z - z_0 )/(sd(z)*h)) $. When Z includes two variables (e.g., nonpar=~z1+z2), the method for specifying K 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- z_0 )/(sd(z)*h))$.
The great circle formula is used to define K 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 the 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.
h is specified by the bandwidth or window option. The function cparlwrgrid can be used to search for the value of h that minimizes the cv or gcv criterion.
Since each estimate is a linear function of all n values for y, the full set of estimates takes the form yhat = LY, where L is an nxn matrix. Loader (1999) suggests two measures of the number of degrees of freedom used in estimation: df1 = tr(L) and df2 = tr(L'L). The diagonal elements of tr(L) are stored in the array infl. Since the degrees of freedom measures can differ substantially when target="alldata" rather than using a set of target points, it is a good idea to report final estimates using target="alldata" when possible.
Again following Loader (1999), the degrees of freedom correction used to estimate the error variance, sig2, is df = 2*df1 - df2. Let e represent the vector of residuals, y - yhat. The estimated variance is $sig2 = \sum e^2/(n-df)$. The covariance matrix for $B(z_0)$ is $$\hat{\sigma}^2(\sum_{i=1}^n X_i K(\phi_i) X_i^\top)^{-1}(\sum_{i=1}^n X_i (K(\phi_i))^2 X_i^\top )(\sum_{i=1}^n X_i K(\phi_i) X_i^\top)^{-1}.$$
Estimation can be very slow when targetobs = "alldata". The maketarget command can be used to identify target points.
Available kernel weighting functions include the following:
Kernel | Call abbreviation |
Kernel function K(z) | Rectangular |
``rect'' | $1/2 * I(|z|<1)$ <="" td=""> 1)$> |
Triangular | ``tria'' |
$(1-|z|) * I(|z|<1)$< td=""> | Epanechnikov | 1)$<>
``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)$ |
Loader, Clive. Local Regression and Likelihood. New York: Springer, 1999.
McMillen, Daniel P., "One Hundred Fifty Years of Land Values in Chicago: A Nonparametric Approach," Journal of Urban Economics 40 (1996), 100-124.
McMillen, Daniel P., "Issues in Spatial Data Analysis," Journal of Regional Science 50 (2010), 119-141.
McMillen, Daniel P., "Employment Densities, Spatial Autocorrelation, and Subcenters in Large Metropolitan Areas," Journal of Regional Science 44 (2004), 225-243.
McMillen, Daniel P. and John F. McDonald, "A Nonparametric Analysis of Employment Density in a Polycentric City," Journal of Regional Science 37 (1997), 591-612.
McMillen, Daniel P. and Christian Redfearn, ``Estimation and Hypothesis Testing for Nonparametric Hedonic House Price Functions,'' Journal of Regional Science 50 (2010), 712-733.
Pagan, Adrian and Aman Ullah. Nonparametric Econometrics. New York: Cambridge University Press, 1999.
data(cookdata)
par(ask=TRUE)
cookdata <- cookdata[cookdata$CHICAGO==1&!is.na(cookdata$LNFAR),]
fit1 <- cparlwr(LNFAR~DCBD,nonpar=~DCBD, window=.10,
data=cookdata)
fit2 <- cparlwr(LNFAR~DCBD,nonpar=~LONGITUDE+LATITUDE,window=.10,
distance="LATLONG",data=cookdata)
cookdata$yhat1 <- fit1$yhat
cookdata$yhat2 <- fit2$yhat
o <- order(cookdata$DCBD)
plot(cookdata$DCBD[o], cookdata$LNFAR[o],main="Log Floor Area Ratio",
xlab="Distance from CBD",ylab="Log FAR")
lines(cookdata$DCBD[o], cookdata$yhat1[o], col="red")
plot(cookdata$DCBD[o], cookdata$LNFAR[o],main="Log Floor Area Ratio",
xlab="Distance from CBD",ylab="Log FAR")
points(cookdata$DCBD[o], cookdata$yhat2[o], col="red")
Run the code above in your browser using DataLab