plot.krls: Plot method for Kernel-based Regularized Least Squares (KRLS)...

Description Usage Arguments Details Author(s) See Also Examples

Description

Produces two types of plots. The first type of plot shows histograms for the pointwise partial derivatives to examine the heterogeneity in the marginal effects of each predictor (which==1). The second type of plot shows estimates of the conditional expectation functions of E[Y|X] for each predictor (which==2). For each plot, the predictor of interest varies from its 1st to its 3rd quartile values, while the other predictors are kept at the means (or other values specified in setx). For binary varibales the E[Y|X] are predicted at the max and the min value of the predictor (instead of the range from the 1st to the 3rd quantile).

Usage

1
2
3
4
 ## S3 method for class 'krls'
plot(x,which=c(1:2),
 main="distributions of pointwise marginal effects",
 setx="mean",ask = prod(par("mfcol")) < nplots,nvalues=50,probs=c(.25,.75),...)

Arguments

x

An object of class "krls" that results from call to krls.

which

if a subset of the plots is required, specify a subset of the numbers 1:2.

main

main title for histograms of pointwise partial derivatives.

setx

either one of mean or median to hold other predictors at their mean or median values for the conditional expectation plots. Alternativley the user can specific a numeric vector with predictor values at which the other predictors should be fixed for the conditional expectation plots. If specifed in this way there must be one value per predictor and the order of the values much match the order of the predictor used in the predictor matrix of the krls fit passed in x.

ask

logical; if TRUE, the user is asked before each plot, see par (ask=.).

nvalues

scalar that specifies the number of values at which conditional expectations should be plotted.

probs

vector with numbers between 0 and 1 that specify the quantiles that determine the range for of the predictor values for which the conditional expectation should be plotted. By default we vary each predictor from the 1st quartile to the 3rd quartile value.

...

additional arguments to be passed to lower level functions

Details

Notice that the historgrams for the partial derivatives can only be plotted if the KRLS object was computed with krls(,derivatives=TRUE).

Author(s)

Jens Hainmueller (Stanford) and Chad Hazlett (MIT)

See Also

krls

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# non-linear example
# set up data
N <- 200
x1 <- rnorm(N)
x2 <- rbinom(N,size=1,prob=.2)
y <- x1^3 + .5*x2 + rnorm(N,0,.15)
X <- cbind(x1,x2)

# fit model
krlsout <- krls(X=X,y=y)
# summarize marginal effects and contribution of each variable
summary(krlsout)
# plot marginal effects and conditional expectation plots
plot(krlsout)

KRLS documentation built on May 2, 2019, 5:51 a.m.

Related to plot.krls in KRLS...