residuals.dfrr: Obtain residuals for a dfrr model

View source: R/residuals.dfrr.R

residuals.dfrrR Documentation

Obtain residuals for a dfrr model

Description

Returns the residuals of a fitted dfrr model. A dfrr model is of the form:

Y_{i}(t)=I(W_{i}(t)>0),

in which I(.) is the indicator function and W_{i}(t)=Z_{i}(t)+\epsilon_{i}(t)\times\sigma^2, where Z_{i}(t) is the functional part of the model and epsilon_{i}(t)\times\sigma^2 is the measurement error. The functional part of the model, consisting a location and a residual function of the form:

Z_{i}(t)=\sum_{j=1}^{q}\beta_{j}(t)*x_{ji}+\varepsilon_{i}(t),

and \epsilon_{i}(t) are iid standard normal for each i and t. The residuals reported in the output of this functions is the estimation of the measurement error of the model i.e. \epsilon_{i}(t)\times\sigma^2, which is estimated by:

E(W_{i}(t)-Z_{i}(t)\mid Y_{i}(t)).

Usage

## S3 method for class 'dfrr'
residuals(object, standardized = NULL, unstandardized = !standardized, ...)

Arguments

object

a fitted dfrr-object obtained from invoking the function dfrr.

standardized, unstandardized

a boolean indicating whether stanadrdized/unstandardized residuals are reported. Defaults to standardized=TRUE.

...

dot argument, just for consistency with the generic function

Value

This function returns either a matrix or a data.frame. If the argument ydata is specified, the return value is 'ydata' with a column added, namely 'residual'. Otherwise, the return value is a matrix of residuals of dimension NxM where N is the number of sample curves, and M is the length of argument 'yind' passed to the function dfrr.

See Also

plot.residuals.dfrr, qq.dfrr

Examples

set.seed(2000)
N<-50;M<-24

X<-rnorm(N,mean=0)
time<-seq(0,1,length.out=M)
Y<-simulate_simple_dfrr(beta0=function(t){cos(pi*t+pi)},
                        beta1=function(t){2*t},
                        X=X,time=time)

#The argument T_E indicates the number of EM algorithm.
#T_E is set to 1 for the demonstration purpose only.
#Remove this argument for the purpose of converging the EM algorithm.
dfrr_fit<-dfrr(Y~X,yind=time,T_E=1)
resid<-residuals(dfrr_fit)


plot(resid)
# We can also use the qq function to draw the QQ-plot.


dfrr documentation built on May 31, 2023, 5:32 p.m.