Skip to content

asgari-fatemeh/dfrr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dfrr Build Status

Dichotomized functional response regression

Implementing Function-on-Scalar Regression model, in which the response function is dichotomized and observed sparsely.

The output is a dfrr-object, which then can be injected into other methods/functions to postprocess the fitted model, including: coef.dfrr,fitted.dfrr, residuals.dfrr, predict.dfrr, fpca.dfrr, summary.dfrr, model.matrix.dfrr, plot.dfrr, plot.coef.dfrr, plot.fitted.dfrr, plot.residuals.dfrr, qq.dfrr, plot.predict.dfrr, plot.fpca.dfrr

Installation

After installing `devtools' first, type in the following in R

require(devtools)
install_github("asgari-fatemeh/dfrr")

Usage

dfrr(
  formula,
  yind = NULL,
  data = NULL,
  ydata = NULL,
  method = c("REML", "ML"),
  rangeval = NULL,
  basis = NULL,
  ...
)

Example

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

##### Fitting dfrr model to the Madras Longitudinal Schizophrenia data
data(madras)

ids<-unique(madras$id)
N<-length(ids)

ydata<-data.frame(.obs=madras$id,.index=madras$month,.value=madras$y)
xdata<-data.frame(Age=rep(NA,N),Gender=rep(NA,N))
for(i in 1:N){
  dt<-madras[madras$id==ids[i],]
  xdata[i,]<-c(dt$age[1],dt$gender[1])
}
rownames(xdata)<-ids

madras_dfrr<-dfrr(Y~Age+Gender+Age*Gender, data=xdata, ydata=ydata, J=11)
coefs<-coef(madras_dfrr)
plot(coefs)

fpcs<-fpca(madras_dfrr)
plot(fpcs)

About

Dichotomized functional response regression

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages