predict.dfrr: Prediction for dichotomized function-on-scalar regression

Description Usage Arguments Details See Also Examples

View source: R/predict.dfrr.R

Description

Takes a dfrr-object created by dfrr() and returns predictions given a new set of values for a model covariates and an optional ydata-like data.frame of observations for the dichotomized response.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## S3 method for class 'dfrr'
predict(
  object,
  newdata,
  newydata = NULL,
  standardized = NULL,
  unstandardized = !standardized,
  return.fourier.coefs = NULL,
  return.evaluations = !return.fourier.coefs,
  time_to_evaluate = NULL,
  ...
)

Arguments

object

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

newdata

a data.frame containing the values of all of the model covariates at which the latent functional response is going to be predicted.

newydata

(optional) a ydata-like data.frame containing the values of dichotomized response sparsly observed in the domain of function.

standardized, unstandardized

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

return.fourier.coefs, return.evaluations

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

time_to_evaluate

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

...

dot argument, just for consistency with the generic function

Details

This function will return either the Fourier coefficients or the evaluation of predictions. 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 predictions on the set of time points specified by vector time, equals to fitted(dfrr_fit,return.fourier.coefs=T)%*%t(eval.basis(time,basis(dfrr_fit))).

See Also

plot.predict.dfrr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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)
dfrr_fit<-dfrr(Y~X,yind=time)


newdata<-data.frame(X=c(1,0))
  preds<-predict(dfrr_fit,newdata=newdata)
  plot(preds)

newdata<-data.frame(X=c(1,0))
newydata<-data.frame(.obs=rep(1,5),.index=c(0.0,0.1,0.2,0.3,0.7),.value=c(1,1,1,0,0))
preds<-predict(dfrr_fit,newdata=newdata,newydata = newydata)
plot(preds)

asgari-fatemeh/dfrr documentation built on Aug. 12, 2020, 3:06 a.m.