plot_shiny: plot_shiny The generic function for interactive plots of...

View source: R/plot_shiny.R

plot_shinyR Documentation

plot_shiny The generic function for interactive plots of functional data analyses

Description

Interactive Plotting for Functional Data

Usage

plot_shiny(obj, ...)

Arguments

obj

object to be plotted. Currently, allowed data types are fpca mfpca lfpca and fosr.

...

additional arguments passed to plotting functions

Details

Function for interactive plotting of functional data analysis results.

This package builds on the refund package: tools in refund are used to conduct analyses and functions in this package create interactive visualizations of the results of those analyses. There are four major categories of analyses that can be viewed:

  1. Functional principal components analyses implemented by fpca.sc, fpca.face, fpca.ssvd, and fpca2s. Plots show the mean +/- 2SD times each FPC; scree plots; linear combinations of score values and FPCs; reconstructions for each subject; and score scatterplots.

  2. Function-on-scalar regression analyses implemented by bayes_fosr. Plots show the raw data colored by covariate values; fitted values depending on covariates; coefficient functions; and residuals.

  3. Multilevel functional principal components analyses implemented by mfpca.sc. Plots show the mean +/- 2SD times each FPC; scree plots; linear combinations of score values and FPCs; reconstructions for each subject; and score scatterplots for levels 1 and 2. #'

  4. Longitudinal functional principal components analyses

Value

This function outputs a shiny app based on the class of the input object.

Author(s)

Jeff Goldsmith jeff.goldsmith@columbia.edu, Julia Wrobel julia.wrobel@cuanschutz.edu

See Also

plot_shiny.fpca, plot_shiny.mfpca, plot_shiny.fosr

Examples


## Not run: 
library(dplyr)
##### FPCA Example on real data #####

data(cd4)
SC = fpca.sc(cd4)
plot_shiny(SC)


##### FoSR Example #####

data(DTI)
DTI = DTI[complete.cases(DTI),]
fit.fosr = refund::bayes_fosr(cca ~ pasat + sex, data = DTI)
plot_shiny(fit.fosr)

##### FoSR Example with outliers #####

DTI$cca[1,] = DTI$cca[1,] + .4
DTI$cca[2,] = DTI$cca[2,] + .4

fosr.dti2 = bayes_fosr(cca ~ pasat + sex, data = DTI)
plot_shiny(fosr.dti2)

##### Longitudinal FoSR Examples #####

data(DTI2)
class(DTI2$cca) = class(DTI2$cca)[-1]
DTI2 = subset(DTI2, select = c(cca, id, pasat))
DTI2 = DTI2[complete.cases(DTI2),]

fosr.dti3 = bayes_fosr(cca ~ pasat + re(id), data = DTI2, Kt = 10, Kp = 4, cov.method = "FPCA")
plot_shiny(fosr.dti3)
plot_shiny(fosr.dti3$fpca.obj)

##### LFPCA Example on real data #####

data(DTI)
MS <- subset(DTI, case ==1)  # subset data with multiple sclerosis (MS) case

index.na <- which(is.na(MS$cca))
Y <- MS$cca; Y[index.na] <- fpca.sc(Y)$Yhat[index.na]; sum(is.na(Y))
id <- MS$ID
visit.index <- MS$visit
visit.time <- MS$visit.time/max(MS$visit.time)

lfpca.dti1 <- fpca.lfda(Y = Y, subject.index = id,
                       visit.index = visit.index, obsT = visit.time,
                       LongiModel.method = 'lme',
                       mFPCA.pve = 0.95)
plot_shiny(lfpca.dti1)

lfpca.dti2 <- fpca.lfda(Y = Y, subject.index = id,
                       visit.index = visit.index, obsT = visit.time,
                       LongiModel.method = 'fpca.sc',
                       mFPCA.pve = 0.80, sFPCA.pve = 0.80)
plot_shiny(lfpca.dti2)

## End(Not run)



refund.shiny documentation built on Oct. 11, 2022, 1:05 a.m.