graphResX.fun: Perform a lurking variable plot

Description Usage Arguments Details Value References See Also Examples

View source: R/graphResX.fun.r

Description

This function performs a lurking variable plot to analyze the residuals in terms of different levels of the variable.

Usage

1
graphResX.fun(X, nint, mlePP, typeRes = "Pearson", h = NULL, namX = NULL)

Arguments

X

Numeric vector, the variable for the lurking variable plot.

nint

Number of intervals or levels the variable is divided into.

mlePP

An object of class mlePP-class; usually, the output from fitPP.fun.

typeRes

Label indicating the type of residuals ('Raw' or any type of scaled residuals such as 'Pearson').

h

Optional. Weight function used to calculate the scaled residuals (if typeRes is not equal to 'Raw'). By default, Pearson residuals with h(t)=1/√{\hat λ(t)} are calculated. \hat λ(t) is provided by the lambdafit slot in mlePP.

namX

Optional. Name of variable X.

Details

The residuals for different levels of the variable are analyzed. For a variable X(t), the considered levels are

W(P_{X,j}, P_{X,j+1})=\{ t: P_{X,j} ≤ X(t) < P_{X,j+1} \}

where P_{X,i} is the sample j-percentile of X. This type of plot is specially useful for variables which are not a monotonous function of time.

In the case typeRes='Raw' or typeRes='Pearson', envelopes for the residuals are also plotted. The envelopes are based on an approach analogous to the one in Baddeley et al. (2005) for spatial Poisson processes. The envelopes for raw residuals are

\pm {2 \over l_W} √{∑_i \hat λ(i)}

where index i runs over the integers in the level W(P_{X,j}, P_{X,j+1}), and l_W is its length (number of observations in W). The envelopes for the Pearson residuals are,

\pm 2/√{l_W}.

Value

A list with elements

Xres

Vector of residuals.

xm

Vector of the mean value of the variable in each interval.

pc

Vector of the quantiles that define the levels of the variable.

typeRes

Input argument.

namX

Input argument.

lambdafit

Input argument.

posE

Input argument.

References

Atkinson, A. (1985). Plots, transformations and regression. Oxford University Press.

Baddeley, A., Turner, R., Moller, J. and Hazelton, M. (2005). Residual analysis for spatial point processes. Journal of the Royal Statistical Society, Series B 67, 617-666.

Cebrian, A.C., Abaurrea, J. and Asin, J. (2015). NHPoisson: An R Package for Fitting and Validating Nonhomogeneous Poisson Processes. Journal of Statistical Software, 64(6), 1-24.

See Also

graphResCov.fun, graphres.fun

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
##Simulated process not related to variable X
##Plots dividing the  variable into  50 levels

X1<-rnorm(500)
X2<-rnorm(500)
auxmlePP<-fitPP.fun(posE=round(runif(50,1,500)), inddat=rep(1,500),
	covariates=cbind(X1,X2),start=list(b0=1,b1=0,b2=0))



##Raw residuals
res<-graphResX.fun(X=rnorm(500),nint=50,mlePP=auxmlePP,typeRes="Raw")

##Pearson residuals
res<-graphResX.fun(X=rnorm(500),nint=50,mlePP=auxmlePP,typeRes="Pearson")

NHPoisson documentation built on Feb. 19, 2020, 5:07 p.m.