fitted.dfrr: Obtain fitted curves for a dfrr model

View source: R/fitted.dfrr.R

fitted.dfrrR Documentation

Obtain fitted curves for a dfrr model

Description

Fitted curves refer to the estimations of latent functional response curves. The results can be either the Fourier coefficients or evaluation of the fitted functions. See Details.

Usage

## S3 method for class 'dfrr'
fitted(
  object,
  return.fourier.coefs = NULL,
  return.evaluations = !return.fourier.coefs,
  time_to_evaluate = NULL,
  standardized = NULL,
  unstandardized = !standardized,
  ...
)

Arguments

object

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

return.fourier.coefs, return.evaluations

a boolean indicating whether the Fourier coefficients of the fitted curves are returned (return.fourier.coefs=TRUE), or evaluations of the fitted curves (return.evaluations=TRUE). Defaults to return.fourier.coefs=TRUE.

time_to_evaluate

a numeric vector indicating the set of time points for evaluating the fitted latent functions, for the case of return.evaluations=TRUE.

standardized, unstandardized

a boolean indicating whether stanadrdized/unstandardized fitted latent curves is reported. Only standardized fitted curves are identifiable, thus the arugment is defaults to standardized=TRUE.

...

dot argument, just for consistency with the generic function

Details

This function will return either the Fourier coefficients or the evaluation of fitted curves to the binary sequences. Fourier coefficients which are reported are based on the a set of basis which can be determined by basis(dfrr_fit). Thus the evaluation of fitted latent curves on the set of time points specified by vector time, equals to fitted(dfrr_fit)%*%t(eval.basis(time,basis(dfrr_fit))).

Consider that the unstandardized estimations are not identifiable. So, it is recommended to extract and report the standardized estimations.

Value

This function returns a matrix of dimension NxM or NxJ, depending the argument return.evaluations. If return.evaluations=FALSE, the returned matrix is NxJ, where N denotes the sample size (the number of rows of the argument 'newData'), and J denotes the number of basis functions. Then, the NxJ matrix is the fourier coefficients of the fitted curves. If return.evaluations=TRUE, the returned matrix is NxM, where M is the length of the argument time_to_evaluate. Then, the NxM matrix is the fitted curves evaluated at time points given in time_to_evaluate.

See Also

plot.fitted.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)
fitteds<-fitted(dfrr_fit)
plot(fitteds)


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