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

Description Usage Arguments Details Author(s) See Also Examples

View source: R/plot_shiny.R

Description

Interactive Plotting for Functional Data

Usage

1

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

Author(s)

Jeff Goldsmith jeff.goldsmith@columbia.edu, Julia Wrobel jw3134@cumc.columbia.edu

See Also

plot_shiny.fpca, plot_shiny.mfpca, plot_shiny.fosr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
## Not run: 

library(refund)
library(dplyr)

##### FPCA Example on real data #####

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

##### FPCA Examples on simulated data #####

set.seed(2678695)
n = 101
m = 101
s1 = 20
s2 = 10
s = 4
t = seq(-1, 1, l=m)
v1 = t + sin(pi*t)
v2 = cos(3*pi*t)
V = cbind(v1/sqrt(sum(v1^2)), v2/sqrt(sum(v2^2)))
U = matrix(rnorm(n*2), n, 2)
D = diag(c(s1^2, s2^2))
eps = matrix(rnorm(m*n, sd=s), n, m)
Y = U%*%D%*%t(V) + eps

SC = fpca.sc(Y)
FACE = fpca.face(Y)
SSVD = fpca.ssvd(Y, verbose=FALSE)
S = fpca2s(Y)
 
plot_shiny(SC)
plot_shiny(FACE)
plot_shiny(SSVD)
plot_shiny(S)

#' ##### MFPCA Example #####

data(DTI)
Y = DTI$cca
id = DTI$ID

mfpca.dti = mfpca.sc(Y=Y, id = id, twoway = FALSE)
plot_shiny(mfpca.dti)

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

data(DTI)
DTI = DTI[complete.cases(DTI),]
fit.fosr = 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)

refunders/refund.shiny documentation built on Aug. 20, 2020, 12:43 p.m.