Package Rearrangement

Similar documents
Package SiZer. February 19, 2015

Package SPIn. R topics documented: February 19, Type Package

Package intccr. September 12, 2017

Package qlearn. R topics documented: February 20, Type Package Title Estimation and inference for Q-learning Version 1.

Package OutlierDC. R topics documented: February 19, 2015

Package RCEIM. April 3, 2017

Package dyncorr. R topics documented: December 10, Title Dynamic Correlation Package Version Date

Package smoothr. April 4, 2018

Package areaplot. October 18, 2017

Package r2d2. February 20, 2015

Package OptimaRegion

Package SAMUR. March 27, 2015

Package splines2. June 14, 2018

Package mcmcse. February 15, 2013

Package iosmooth. R topics documented: February 20, 2015

Package GLDreg. February 28, 2017

Package gains. September 12, 2017

Package FCGR. October 13, 2015

Package texteffect. November 27, 2017

Package ellipse. January 6, 2018

Package curvhdr. April 16, 2017

Package EnQuireR. R topics documented: February 19, Type Package Title A package dedicated to questionnaires Version 0.

Package libstabler. June 1, 2017

Package ExceedanceTools

Package vinereg. August 10, 2018

Package intcensroc. May 2, 2018

Package extremevalues

Package ssmn. R topics documented: August 9, Type Package. Title Skew Scale Mixtures of Normal Distributions. Version 1.1.

Package gsscopu. R topics documented: July 2, Version Date

Package tseriesentropy

STATISTICAL LABORATORY, April 30th, 2010 BIVARIATE PROBABILITY DISTRIBUTIONS

Package spcadjust. September 29, 2016

Package Grid2Polygons

Package quickreg. R topics documented:

Package ArCo. November 5, 2017

Package feature. R topics documented: July 8, Version Date 2013/07/08

Package superbiclust

Package ranger. November 10, 2015

Package munfold. R topics documented: February 8, Type Package. Title Metric Unfolding. Version Date Author Martin Elff

Package kdevine. May 19, 2017

Package kdetrees. February 20, 2015

Package Binarize. February 6, 2017

Package GFD. January 4, 2018

Package DBKGrad. R topics documented: December 2, 2018

Package SCBmeanfd. December 27, 2016

Package addhaz. September 26, 2018

Package incidence. August 24, Type Package

Package rafalib. R topics documented: August 29, Version 1.0.0

Package dkdna. June 1, Description Compute diffusion kernels on DNA polymorphisms, including SNP and bi-allelic genotypes.

Package permuco. February 14, Type Package

Package sbf. R topics documented: February 20, Type Package Title Smooth Backfitting Version Date Author A. Arcagni, L.

Package accrued. R topics documented: August 24, Type Package

Package cgh. R topics documented: February 19, 2015

Cubic Spline Questions

Package beanplot. R topics documented: February 19, Type Package

Package misclassglm. September 3, 2016

Package dcv. August 29, 2013

Package RaPKod. February 5, 2018

Package npcp. August 23, 2017

Package zebu. R topics documented: October 24, 2017

Package pmg. R topics documented: March 9, Version Title Poor Man s GUI. Author John Verzani with contributions by Yvonnick Noel

Package feature. R topics documented: October 26, Version Date

Package survivalmpl. December 11, 2017

Package mlegp. April 15, 2018

Package oaxaca. January 3, Index 11

Package MIICD. May 27, 2017

Package RcmdrPlugin.survival

Package inext. November 12, 2016

Regression III: Advanced Methods

Package Daim. February 15, 2013

Package sure. September 19, 2017

Package lol. R topics documented: December 13, Type Package Title Lots Of Lasso Version Date Author Yinyin Yuan

Package sparsereg. R topics documented: March 10, Type Package

Package enpls. May 14, 2018

Package SmoothHazard

Package bdots. March 12, 2018

Package cosinor. February 19, 2015

Package ICSShiny. April 1, 2018

Package nprotreg. October 14, 2018

Package diagis. January 25, 2018

Package lmesplines. R topics documented: February 20, Version

Package fso. February 19, 2015

Package complmrob. October 18, 2015

Package FWDselect. December 19, 2015

2 sybildynfba-package. Dynamic Flux Balance Analysis

Package npregfast. November 30, 2017

Package MeanShift. R topics documented: August 29, 2016

Package docxtools. July 6, 2018

Package PIPS. February 19, 2015

Package FastImputation

Package JOP. February 19, 2015

Package rknn. June 9, 2015

Package fcopulae. November 16, 2017

Package glogis. R topics documented: March 16, Version Date

Package ModelGood. R topics documented: February 19, Title Validation of risk prediction models Version Author Thomas A.

Package OutlierDM. R topics documented: February 19, 2015

Package clustvarsel. April 9, 2018

Package ConvergenceClubs

Package qvcalc. R topics documented: September 19, 2017

Package gsalib. R topics documented: February 20, Type Package. Title Utility Functions For GATK. Version 2.1.

Transcription:

Type Package Package Rearrangement March 2, 2016 Title Monotonize Point and Interval Functional Estimates by Rearrangement Version 2.1 Author Wesley Graybill, Mingli Chen, Victor Chernozhukov, Ivan Fernandez-Val, Alfred Galichon Maintainer Ivan Fernandez-Val <ivanf@bu.edu> The rearrangement operator (Hardy, Littlewood, and Polya 1952) for univariate, bivariate, and trivariate point estimates of monotonic functions. The package additionally provides a function that creates simultaneous confidence intervals for univariate functions and applies the rearrangement operator to these confidence intervals. License GPL (>= 2) LazyLoad yes Depends quantreg, splines NeedsCompilation no Repository CRAN Date/Publication 2016-03-02 01:48:30 R topics documented: Rearrangement-package.................................. 2 GrowthChart........................................ 3 lclm............................................. 4 lcrq2............................................. 5 lines.conint......................................... 6 lplm............................................. 7 lprq2............................................. 8 plot.conint.......................................... 9 points.conint......................................... 10 polygon.conint....................................... 11 1

2 Rearrangement-package rconint............................................ 12 rearrangement........................................ 14 simconboot......................................... 16 Inde 18 Rearrangement-package Point and Interval Rearrangement This package implements the rearrangement operator (Hardy, Littlewood, and Polya 1952) for univariate, bivariate, and trivariate point estimates of monotonic functions. It additionally provides a function that creates simultaneous confidence intervals for univariate functions and applies the rearrangement operator to these confidence intervals. Package: Rearrangement Type: Package Version: 1.0 Date: 2011-09-11 License: GPL(>=2) LazyLoad: yes This package is used for rearranging both point and interval estimates of a target function. Given an original point estimate of a target function, one may use rearrangement to monotonize this estimate. One may also create simultaneous confidence interval estimates using simconboot and monotonize these estimates using rconint. Maintainer: Ivan Fernandez-Val <ivanf@bu.edu> References Chernozhukov, V., I. Fernandez-Val, and a. Galichon. 2009. Improving point and interval estimators of monotone functions by rearrangement. Biometrika 96 (3): 559-575. Chernozhukov, V., I. Fernandez-Val, and a. Galichon. 2010. Quantile and Probability Curves Without Crossing. Econometrica 78(3): 1093-1125. Hardy, G.H., J.E. Littlewood, and G. Polya, Inequalities,2nd ed, Cambridge U. Press,1952 ##rearrangement eample:

GrowthChart 3 library(splines) ages <- unique(sort(age)) aknots <- c(3, 5, 8, 10, 11.5, 13, 14.5, 16, 18) splines_age <- bs(age,kn=aknots) sformula <- height~splines_age sfunc <- approfun(age,lm(sformula)$fitted.values) splreg <- sfunc(ages) rsplreg <- rearrangement(list(ages),splreg) plot(age,height,pch=21,bg= gray,ce=.5,lab="age(years)", ylab="height(cms)", main="cef (Regression Splines)",col= gray ) lines(ages,splreg,col= red,lwd=3) lines(ages,rsplreg,col= blue,lwd=2) legend("topleft",c( Original, Rearranged ),lty=1,col=c( red, blue ),bty= n ) ##rconint eample: ## Not run: nage <- 2 * pi * (age - min(age)) / (ma(age) - min(age)) formula <- height~i(sin(nage))+i(cos(nage))+i(sin(2*nage)) + I(cos(2*nage))+I(sin(3*nage))+ I(cos(3*nage))+ I(sin(4*nage)) + I(cos(4*nage)) j <- simconboot(nage,height,lm,formula) k <- rconint(j) plot(k, border=na, col= darkgray ) polygon.conint(j, border=na, col= lightgray ) polygon.conint(k, border=na, col= darkgray, density=50) points(nage,height) ## End(Not run) GrowthChart Age and Height of White Males This data set contains age and height of US-born white males age two through twenty. Note that age is measured in months and epressed in years, and height is measured in centimeters.

4 lclm Format Source A data frame with 533 observations on the following 3 variables. se a numeric vector. Male = 1 height a numeric vector. Height in cm age a numeric vector. Age in years The data consist of repeated cross sectional measurements of height and age from the 2003-2004 National Health and Nutrition Survey collected by the US National Center for Health Statistics. plot(age,height,pch=21,bg= gray,ce=.5, lab="age (years)",ylab="height (cms)",col= gray ) lclm Local Constant Estimator for Conditional Mean Functions Implements the local nonparametric method kernel estimator with bo kernel (default), for conditional mean functions. lclm(, y, h, ) y h The conditioning covariate The response variable The bandwidth parameter The points at which the function is to be estimated Value The function uses a bo kernel. fitted.values The design points at which the evaluation occurs The estimated function values at these design points

lcrq2 5 ages <- unique(sort(age)) lclm.fit1 <- lclm(age,height,h=1,=ages) lcrq2 Local Constant Estimator for Conditional Quantile Functions Implements the local nonparametric method kernel estimator with bo kernel (default), for conditional quantile functions. This is a modification of Koenker s lprq (from package quantreg). lcrq2(, y, h,, tau) y h tau The conditioning covariate The response variable The bandwidth parameter The points at which the function is to be estimated The quantile(s) to be estimated. This should be a list of quantiles if the function estimates the quantile process Value The function uses a bo kernel. fitted.values The design points at which the evaluation occurs The estimated function values at these design points

6 lines.conint See Also lprq require(quantreg) ages <- unique(sort(age)) lcq.fit1 <- lcrq2(age,height,h=1,=ages,tau=0.01) lines.conint Lines Method for Simultaneous Confidence Intervals A method for the lines generic. It graphs both the upper and lower end-point functions of a confidence interval as lines on a plot. ## S3 method for class conint lines(,...) object of class conint... further arguments to lines.default This is intended for plotting confidence intervals produced by the output of simconboot or rconint. See Also lines,plot.conint,points.conint

lplm 7 nage <- 2*pi*(age-min(age))/(ma(age)-min(age)) formula<-height~i(sin(nage))+i(cos(nage))+i(sin(2*nage))+ I(cos(2*nage))+I(sin(3*nage))+ I(cos(3*nage))+I(sin(4*nage))+I(cos(4*nage)) j<-simconboot(nage,height,lm,formula) plot(nage,height,pch=21,bg= gray,ce=.5,lab="age (years)",ylab="height (cms)",col= gray,at= n ) ais(1, at = seq(-2*pi*min(age)/(ma(age)-min(age)), 2*pi+1, by=5*2*pi/(ma(age)-min(age))), label = seq(0, ma(age)+1, by=5)) lines(j) lplm Local Linear Regression Methods for Conditional Mean Functions Implements the local nonparametric method, local linear regression estimator with bo kernel (default), for conditional mean functions. lplm(, y, h, ) y h The conditioning covariate The response variable The bandwidth parameter The points at which the function is to be estimated Value The function uses a bo kernel. fitted.values The design points at which the evaluation occurs The estimated function values at these design points

8 lprq2 ages <- unique(sort(age)) lplm.fit1 <- lplm(age,height,h=1,=ages) lprq2 Local Linear Regression Methods for Conditional Quantile Functions Implements the local nonparametric method, local linear regression estimator with bo kernel (default), for conditional quantile functions. This is a modification of Koenker s lprq ( from package quantreg). lprq2(, y, h,, tau) y h tau The conditioning covariate The response variable The bandwidth parameter The points at which the function is to be estimated The quantile(s) to be estimated. This should be a list of quantiles if the function estimates the quantile process The function uses a bo kernel. Value fitted.values The design points at which the evaluation occurs The estimated function values at these design points

plot.conint 9 require(quantreg) ages <- unique(sort(age)) llq.fit1 <- lprq2(age,height,h=1,=ages,tau=0.2) plot.conint Plot Method for Simultaneous Confidence Intervals A method for the plot generic. It graphs both the upper and lower end-point functions of a confidence interval as an unfilled polygon. ## S3 method for class conint plot(, border, col,...) object of class conint border, col same usage as in polygon... further arguments to plot.default This is intended for plotting confidence intervals produced by the output of simconboot or rconint. See Also plot, lines.conint, points.conint

10 points.conint nage <- 2 * pi * (age - min(age)) / (ma(age) - min(age)) formula <- height ~ I(sin(nage))+I(cos(nage))+I(sin(2*nage))+I(cos(2*nage))+ I(sin(3*nage))+I(cos(3*nage))+ I(sin(4*nage))+I(cos(4*nage)) j<-simconboot(nage,height,lm,formula) plot(j) points(nage,height) points.conint Points Method for Simultaneous Confidence Intervals A method for the points generic. It graphs both the upper and lower end-point functions of a confidence interval as points on a plot. ## S3 method for class conint points(,...) object of class conint... further arguments to points.default This is intended for plotting confidence intervals produced by the output of simconboot or rconint. See Also points, plot.conint, lines.conint

polygon.conint 11 nage <- 2 * pi * (age - min(age)) / (ma(age) - min(age)) formula<-height~i(sin(nage))+i(cos(nage))+i(sin(2*nage))+i(cos(2*nage))+ I(sin(3*nage))+I(cos(3*nage))+I(sin(4*nage))+I(cos(4*nage)) j <- simconboot(nage,height,lm,formula) plot(nage,height,pch=21,bg= gray,ce=.5,lab="age (years)",ylab="height (cms)",col="gray") points(j) polygon.conint polygon Method for Simultaneous Confidence Intervals polygon.conint graphs both the upper and lower end-point functions of a confidence interval as a standard polygon on a plot. polygon.conint(,...) object of class conint... further arguments to polygon This is intended for plotting confidence intervals produced by the output of simconboot or rconint. See Also polygon

12 rconint ## Not run: nage <- 2 * pi * (age - min(age)) / (ma(age) - min(age)) formula <- height~i(sin(nage))+i(cos(nage))+i(sin(2*nage))+i(cos(2*nage))+ I(sin(3*nage))+I(cos(3*nage))+I(sin(4*nage))+I(cos(4*nage)) j<-simconboot(nage,height,lm,formula) plot(nage,height,pch=21,bg= gray,ce=0.5,lab="age (years)", ylab="height (cms)",col= gray,at= n ) ais(1, at = seq(-2*pi*min(age)/(ma(age)-min(age)), 2*pi+1,by=5*2*pi/(ma(age)-min(age))), label = seq(0, ma(age)+1, by=5)) polygon.conint(j, border=na, col= darkgray ) ## End(Not run) rconint Rearrangement of Simultaneous Confidence Intervals Uses rearrangement to apply the rearrangement operator to objects of class conint. rconint(, n = 100, stochastic = FALSE, avg = TRUE) n stochastic avg object of class conint an integer denoting the number of sample points desired logical. If TRUE, stochastic sampling will be used logical. If TRUE, the average rearrangement will be computed and outputed Implements the rearrangement operator of rearrangement on simultaneous confidence intervals. Intended for use on output of simconboot.

rconint 13 Value An object of class conint with the following elements: y sorted Lower Upper cef the original data the original y data the original data, sorted with repeated elements removed the rearranged lower end-point function. Represented as a vector of values corresponding to sorted the rearranged upper end-point function. Represented as a vector of values corresponding to sorted the corresponding estimates References Chernozhukov, V., I. Fernandez-Val, and a. Galichon. 2009. Improving point and interval estimators of monotone functions by rearrangement. Biometrika 96 (3): 559-575. Chernozhukov, V., I. Fernandez-Val, and a. Galichon. 2010. Quantile and Probability Curves Without Crossing. Econometrica 78(3): 1093-1125. See Also simconboot, rearrangement ## Not run: nage <- 2 * pi * (age - min(age)) / (ma(age) - min(age)) formula <- height ~ I(sin(nage))+I(cos(nage))+I(sin(2*nage))+I(cos(2*nage))+ I(sin(3*nage))+I(cos(3*nage))+I(sin(4*nage))+I(cos(4*nage)) j <- simconboot(nage,height,lm,formula) k <- rconint(j) plot(k, border=na, col= darkgray,lab = Age (years),ylab = Height (cms),at = "n") ais(1, at = seq(-2*pi*min(age)/(ma(age)-min(age)), 2*pi+1,by=5*2*pi/(ma(age)-min(age))), label = seq(0, ma(age)+1, by=5)) polygon.conint(j, border=na, col= lightgray ) polygon.conint(k, border=na, col= darkgray, density=50) points(nage,height,col= gray80 ) legend(min(nage),ma(height),c("95% CI Original", "95% CI Rearranged"),lty=c(1,1),lwd=c(2,2), col=c("lightgray","darkgray"),bty="n"); ## End(Not run)

14 rearrangement rearrangement Rearrangement Monotonize a step function by rearrangement. Returns a matri or array of points which are monotonic, or a monotonic function performing linear (or constant) interpolation. rearrangement(,y,n=1000,stochastic=false,avg=true,order=1:length()) y n stochastic avg order a list or data frame, the entries of which are vectors containing the values corresponding to the fitted y values a vector, matri, or three-dimensional array containing the fitted values of a model, typically the result of a regression an integer denoting the number of sample points desired logical. If TRUE, stochastic sampling will be used logical. If TRUE, the average rearrangement will be computed and outputted a vector containing the desired permutation of the elements of 1:length(). The rearrangement will be performed in the order specified if avg= FALSE, otherwise all the possible orderings are computed and the average rearrangement is reported This function applies this rearrangement operator of Hardy, Littlewood, and Polya (1952) to the estimate of a monotone function. Note: rearrangement currently only operates on univariate, bivariate, and trivariate regressions (that is, length()<=3). Value rearrangement returns a matri or array of equivalent dimension and size to y that is monotonically increasing in all of its dimensions.

rearrangement 15 References Chernozhukov, V., I. Fernandez-Val, and a. Galichon. 2009. Improving point and interval estimators of monotone functions by rearrangement. Biometrika 96 (3): 559-575. Chernozhukov, V., I. Fernandez-Val, and a. Galichon. 2010. Quantile and Probability Curves Without Crossing. Econometrica 78(3): 1093-1125. See Also Hardy, G.H., J.E. Littlewood, and G. Polya, Inequalities,2nd ed, Cambridge U. Press,1952 rconint, quantile ##Univariate eample: library(splines) ages <- unique(sort(age)) aknots <- c(3, 5, 8, 10, 11.5, 13, 14.5, 16, 18) splines_age <- bs(age,kn=aknots) sformula <- height~splines_age sfunc <- approfun(age,lm(sformula)$fitted.values) splreg <- sfunc(ages) rsplreg <- rearrangement(list(ages),splreg) plot(age,height,pch=21,bg= gray,ce=.5,lab="age (years)",ylab="height (cms)", main="cef (Regression Splines)",col= gray ) lines(ages,splreg,col= red,lwd=3) lines(ages,rsplreg,col= blue,lwd=2) legend("topleft",c( Original, Rearranged ),lty=1,col=c( red, blue ),bty= n ) ##Bivariate eample: ## Not run: library(quantreg) ages <- unique(sort(age)) taus <- c(1:999)/1000 nage <- 2 * pi * (age - min(age)) / (ma(age) - min(age)) nages <- 2 * pi * (ages - min(ages)) / (ma(ages) - min(ages)) fform <- height ~ I(sin(nage))+I(cos(nage))+I(sin(2*nage))+I(cos(2*nage))+ I(sin(3*nage))+I(cos(3*nage))+I(sin(4*nage))+I(cos(4*nage)) ffit <- rq(fform, tau = taus) fcoefs <- t(ffit$coef) freg <- rbind(1, sin(nages), cos(nages), sin(2*nages), cos(2*nages),sin(3*nages), cos(3*nages), sin(4*nages), cos(4*nages) ) fcqf <- crossprod(t(fcoefs),freg) rrfcqf <- rearrangement(list(taus,ages),fcqf, avg=true) tdom <-c(1,10*c(1:99),999) adom <-c(1,5*c(1:floor(length(ages)/5)), length(ages))

16 simconboot par(mfrow=c(2,1)) persp(taus[tdom],ages[adom],rrfcqf[tdom,adom],lab= quantile, ylab= age,zlab= height,col= lightgreen,theta=315,phi=25,shade=.5) title("cqp: Average Quantile/Age Rearrangement") contour(taus,ages,rrfcqf,lab= quantile,ylab= age,col= green, levels=10*c(ceiling(min(fcqf)/10):floor(ma(fcqf)/10))) title("cqp: Contour (RR-Quantile/Age)") ## End(Not run) simconboot Simultaneous Confidence Interval Estimation using Bootstrap simconboot obtains a simultaneous confidence interval for a function. It estimates the lower and upper endpoint functions of the interval by bootstrap. simconboot(,y,estimator,formula,b=200,alpha=0.05,sampsize=length(), seed=8,colint=c(5:39)/2,...) y estimator formula B alpha sampsize seed colint a numerical vector of values a numerical vector of y values estimator to be used in regression formula to be used in the estimator an integer with the number of bootstrap repetitions a real number between 0 and 1 reflecting the desired confidence level an integer with the sample size of each bootstrap repetition if desired, seed to be set for the random number generator the points to be evaluated when ploting... further arguments to be passed to the estimator estimator can be any of a set of standard regression models, most commonly lm or rq (from package quantreg) for global estimators and the built-in functions lclm, lplm, lcrq2, lprq2 for local estimators. Note: formula=0 for all the local estimators.

simconboot 17 Value An object of class conint with the following elements: y sorted Lower Upper cef the original data the original y data the original data, sorted with repeated elements removed the lower endpoint function. Represented as a vector of values corresponding to sorted the upper endpoint function. Represented as a vector of values corresponding to sorted the corresponding estimates See Also rconint nage <- 2 * pi * (age - min(age)) / (ma(age) - min(age)) nages <- unique(sort(nage)) formula <- height~i(sin(nage))+i(cos(nage))+i(sin(2*nage))+i(cos(2*nage))+ I(sin(3*nage))+I(cos(3*nage))+I(sin(4*nage))+I(cos(4*nage)) j <- simconboot(nage,height,lm,formula) plot(j, border=na, col= darkgray,lab = Age (years),ylab = Height (cms),at = "n") ais(1, at = seq(-2*pi*min(age)/(ma(age)-min(age)), 2*pi+1, by=5*2*pi/(ma(age)-min(age))), label = seq(0, ma(age)+1, by=5)) points(nage,height) lines(nages, j$cef, lty=2, col= green )

Inde Topic aplot lines.conint, 6 points.conint, 10 polygon.conint, 11 Topic datasets GrowthChart, 3 Rearrangement-package, 2 Topic device plot.conint, 9 Topic manip rconint, 12 rearrangement, 14 Rearrangement-package, 2 Topic models rconint, 12 rearrangement, 14 Rearrangement-package, 2 simconboot, 16 Topic optimize rconint, 12 rearrangement, 14 Topic package Rearrangement-package, 2 Topic regression lclm, 4 lcrq2, 5 lplm, 7 lprq2, 8 rconint, 12 rearrangement, 14 Rearrangement-package, 2 simconboot, 16 lm, 16 lplm, 7, 16 lprq, 5, 6, 8 lprq2, 8, 16 plot, 9 plot.conint, 6, 9, 10 plot.default, 9 points, 10 points.conint, 6, 9, 10 points.default, 10 polygon, 9, 11 polygon.conint, 11 quantile, 15 rconint, 2, 6, 9 11, 12, 15, 17 Rearrangement (Rearrangement-package), 2 rearrangement, 2, 12 14, 14 Rearrangement-package, 2 rq, 16 simconboot, 2, 6, 9 13, 16 GrowthChart, 3 lclm, 4, 16 lcrq2, 5, 16 lines, 6 lines.conint, 6, 9, 10 lines.default, 6 18