resQQplot.fun: Perform a qqplot for the residuals of a NHPP

Description Usage Arguments Details Value References See Also Examples

Description

This function performs a qqplot comparing the empirical quantiles of the residuals with the expected quantiles under the fitted NHPP, calculated by a Monte Carlo approach.

It calls the auxiliary function resSim.fun (not intended for the users), see Details section.

Usage

1
2
resQQplot.fun(nsim, objres, covariates, clevel = 0.95, cores = 1, 
tit ="", fixed.seed=NULL, histWgraph=TRUE)

Arguments

nsim

Number of simulations for the calculations.

objres

A list with the same elements of the output list from the function CalcRes.fun or CalcResD.fun.

covariates

Matrix of covariates to fit the NHPP (each column is a covariate).

clevel

Confidence level of the residual envelope.

cores

Optional. Number of cores of the computer to be used in the calculations. Default: one core is used.

tit

Character string. A title for the plot.

fixed.seed

An integer or NULL. If it is an integer, that is the value used to set the seed in random generation processes. It it is NULL, a random seed is used.

histWgraph

Logical flag. Only used in Windows platforms. If it is TRUE, a new graphical device is opened with the option record=TRUE.

Details

The expected quantiles are calculated as the median values of the simulated samples. Confidence intervals for each quantile r_{(i)} with pointwise significance level clevel are calculated as quantiles of probability 1-clevel /2 and clevel/2 of the simulated sample for each residual.

All type of residuals (disjoint or overlapping and Pearson or raw residuals) are supported by this function. However, the qqplot for overlapping residuals can be a high time consuming process. So, disjoint residuals should be prefered in this function.

The auxiliary function resSim.fun generates a NHPP with intensity λ(t), fits the model using the covariate matrix and calculates the residuals.

Value

A list with elements

resmed

Numeric vector containing the mean of the simulated residuals in each point.

ressup

Numeric vector of the upper values of the simulated envelopes.

resinf

Numeric vector of the lower values of the simulated envelopes.

objres

Input argument.

nsim

Input argument.

fixed.seed

Input argument.

References

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

simNHP.fun, GenEnv.fun

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
X1<-rnorm(500)
X2<-rnorm(500)

aux<-fitPP.fun(tind=TRUE,covariates=cbind(X1,X2), 
	posE=round(runif(40,1,500)), inddat=rep(1,500),
	tim=c(1:500), tit="Simulated example", start=list(b0=1,b1=0,b2=0),dplot=FALSE)

auxRes<-CalcResD.fun(mlePP=aux,lint=50)


#if we want reproducible results, we can fixed the seed in the generation process
#(the number of cores used in the calculations must also be the same to reproduce
# the result)

auxqq<-resQQplot.fun(nsim=50,objres=auxRes, covariates=cbind(X1,X2), fixed.seed=123)

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