Description Usage Arguments Details Value References See Also Examples
View source: R/graphResX.fun.r
This function performs a lurking variable plot to analyze the residuals in terms of different levels of the variable.
1 | graphResX.fun(X, nint, mlePP, typeRes = "Pearson", h = NULL, namX = NULL)
|
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 |
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. |
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}.
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. |
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.
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.