z: Matrix with d-dimensional coordinates (d>=1$ for each entry in y, and d columns)
x.adjust: Optionally, further adjustment covariates to be included in the model with no testing being performed
function_id: Function identifier. It is assumed that one observes multiple functions over z, this is the identifier of each individual function
Sigma: Error covariance. By default 'identity', other options are 'MA', 'AR' or 'AR/MA' (meaning that BIC is used to choose between MA and AR). Alternatively the user can supply a function such that Sigma(z[i,],z[j,]) returns the within-function cov(y[i,], y[j,])
localgridsize: Local test probabilities will be returned for a grid of z values of size localgridsize for each dimension
localgrid: Regions at which tests will be performed. Defaults to dividing each [min(z[,i]), max(z[,i])] into 10 equal intervals. If provided, localgrid must be a list with one entry for each z[,i], containing a vector with the desired grid for that z[,i]
nbaseknots: Number of knots for the spline approximation to the baseline effect of x on y
nlocalknots: Number of knots for the basis capturing the local effects
basedegree: Degree of the spline approximation to the baseline
cutdegree: Degree of the cut spline basis used for testing
usecutbasis: If FALSE, then the basis is not cut and a standard spline basis is returned (not recommended unless you know what you're doing)
priorCoef: Prior on the coefficients, passed on to modelSelection
priorGroup: Prior on grouped coefficients, passed on to modelSelection
priorDelta: Prior on the models, passed on to modelSelection
mc.cores: If package parallel is available on your system and nlocalknots has several entries defining several resolution levels, they will be run in parallel on mc.cores
return.mcmc: Set to TRUE to return the MCMC output from modelSelection
verbose: If TRUE some progress information is printed
...: Other arguments to be passed on to modelSelection, e.g. family='binomial' for logistic regression
Details
Local variable selection considers the model
yi=β0(zi)+sumj=1pβj(zi,xi)+ei
β0(zi) is the baseline mean
βj(zi,xi) is local effect of covariate j at coordinate z_i
ei a Gaussian error term assumed either independent or with a covariance structure given by Sigma. If assuming independence it is possible to consider alternatives to Gaussianity, e.g. set family='binomial' for logistic regression or family='poisson' for Poisson regression
Note: a sum-to-zero type constraint is set on β1(zi,xi) so that it defines a deviation from the baseline mean β0(zi)
We model β0 using B-splines of degree basedegree with nbaseknots knots. We model βj using B-splines of degree cutdegree with nlocalknots. Using cutdegree=0 runs fastest is usually gives similar inference than higher degrees, and is hence recommended by default.
Returns
Object of class localtest, which extends a list with elements
covareffects: Estimated local covariate effects at different z values, 0.95 posterior intervals and posterior probability for the existence of an effect
pplocalgrid: Posterior probabilities for the existence of an effect for regions of z values. Do not use these unless you know what you're doing
covareffects.mcmc: MCMC output used to build covareffects. Only returned if return.mcmc=TRUE
ms: Objects of class msfit returned by modelSelection
pp_localknots: Posterior probability for each resolution level (value of nlocalknots)
Sigma: Input parameter
nlocalknots: Input parameter
basedegree: Input parameter
cutdegree: Input parameter
knots: Input parameters
regionbounds: List with region bounds defined by the local testing knots at each resolution level
Author(s)
David Rossell
Examples
#Simulate outcome and 2 covariates#Covariate 1 has local effect for z>0#Covariate 2 has no effect for any ztruemean=function(x,z){ ans= double(nrow(x)) group1=(x[,1]==1) ans[group1]= ifelse(z[group1]<=0, cos(z[group1]),1) ans[!group1]= ifelse(z[!group1]<=0, cos(z[!group1]),1/(z[!group1]+1)^2) return(ans)}n=1000x1= rep(0:1,c(n/2,n/2))x2= x1 + rnorm(n)x= cbind(x1,x2)z= runif(n,-3,3)m= truemean(x,z)y= truemean(x,z)+ rnorm(n,0,.5)#Run localnulltest with 10 knotsfit0= localnulltest(y, x=x, z=z, nlocalknots=10, niter=1000)#Estimated covariate effects and posterior probabilitiesb= coef(fit0)b