Learn R Programming

htree (version 1.0.0)

partdep_hrf: Partial dependence

Description

Partial dependence for historical tree ensembles.

Usage

partdep_htb(object,xindx,xlim=NULL,ngrid=25,subsample=.1,
	ntrees=NULL,plot.it=TRUE,cat.plot=FALSE)
partdep_hrf(object,xindx,xlim=NULL,ngrid=25,subsample=.1,
	plot.it=TRUE,cat.plot=FALSE,which.class=1)

Arguments

object

an object of class htree.

xindx

Column index of training data, object$x, for which partial dependence is computed.

xlim

Optional range for partial dependence.

ngrid

Number of values in grid for partial dependence.

subsample

Fraction of training data sampled for calculation.

plot.it

If TRUE then a plot is produced.

ntrees

Number of trees to in predictions (only for htb).

cat.plot

If TRUE then a plot useful for categorical values is shown, defaults to FALSE.

which.class

If TRUE then a plot useful for categorical values is shown, defaults to FALSE.

Value

Returns x and y, the grid and partial dependence values. If htb run includes cross-validation then approximate standard errors are also output (based on leave-out-m (subjects) jackknifing). If hrf estimation is run with se=TRUE then approximate bootstrap standard errors are returned (resampling subjects with replacement).

References

J.H. Friedman (2001). “Greedy Function Approximation: A Gradient Boosting Machine,” Annals of Statistics 29(5):1189-1232.

See Also

hrf, htb

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
# -- random intercept example --- #

p=5;sigma_e=.5;sigma_a=.5;v=rep(1,p);n=500;pnoise=2
random_intercept=rnorm(n,sd=sigma_a)
random_intercept=as.numeric(matrix(random_intercept,nrow=p,ncol=n,byrow=TRUE))
x=random_intercept+rnorm(n*p,sd=sigma_e)
z_cat=sample(c(0,.3),length(x),replace=TRUE)
x=x+z_cat
id=sort(rep(1:n,p))
time<-rep(1:p,n)
znoise=matrix(rnorm(n*p*pnoise),ncol=pnoise)
xx=cbind(time,x,as.numeric(z_cat>0),znoise)

# fit historical random forest
hb=hrf(x=xx,time=time,id=id,yindx=2,ntrees=100,mtry=4,nsamp=5,se=TRUE,B=50)

# partial dependence of second predictor (the historical values of response) 
pd=partdep_hrf(hb,xindx=2,ngrid=25,subsample=.1)

# partial dependence of categorical predictor 
pd=partdep_hrf(hb,xindx=3,ngrid=25,subsample=.1,cat.plot=TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab