Description Usage Arguments Details Value Note Author(s) References Examples
Testing the difference of two varying distributions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
ydata1 |
a |
ydata2 |
same as |
nperm |
a scalar, number of permutation |
grid |
a vector, evaluation grids of |
dist.method |
the distance measure to be used. This must be one of Wasserstein
distance ( |
mgcv.gam |
a logical variable, whether to apply |
... |
passed to arguments of |
exclude |
passed to |
permadj |
a logical variable, whether to adjust the permutated data to cover
the entire range, esp. in case of sparsity. Defaults to |
mc.cores |
passed to |
seeds |
set the seed for the permutation via |
stepdown |
a logical variable, which denotes to apply the step-down min P. It defaults to |
This is the Details section
.index |
a vector, evaluation grids. |
pval |
a vector or matrix of (adjusted) p values. |
vdparam |
a list of paramters of varying distributions. |
If ydata1
and ydata2
are lists of
data.frame
s, the lenghs of two lists must be the same.
If mgcv.gam
is TRUE
, ...
and exclue
are NULL
(default settings), then they both default to
formula <- list(.value ~ s(.index) + s(.obs, bs = "re"), ~ s(.index))
,
family = gauss()
and exclude <- "s(.obs)"
, repectively.
Normal distribution (gauss()
) in mgcv::gam
is supported. And gamlss.family
is supported as well by
DVDtest
for fitting a GAMLSS-type varying distributions with various types of random effect.
Note that the permuted data may not match some specific distributions during the permutation.
Meng Xu, Philip Reiss
reiss-EMR18.pdf
Wood, S. N., Pya, N., & Safken, B. (2016). Smoothing parameter and model selection for general smooth models. Journal of the American Statistical Association, 111(516), 1548-1563.
Rigby, R. A., & Stasinopoulos, D. M. (2005). Generalized additive models for location, scale and shape. Journal of the Royal Statistical Society: Series C (Applied Statistics), 54(3), 507-554.
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 | ## Data Generation ##
p <- 6
mu1 <- function(t) 0.2*(p-1)*sin(pi*t)+t+1
mu2 <- function(t) -0.2*(p-1)*sin(pi*t)+t+1
sig1 <- function(t) t+1
sig2 <- sig1
nperson <- 10
fun1 <- function(t) rnorm(nperson, mu1(t), sig1(t))
fun2 <- function(t) rnorm(nperson, mu2(t), sig2(t))
tp <- seq(0,1,,10)
data1 <- sapply(tp,fun1)
data2 <- sapply(tp,fun2)
library(reshape2)
colnames(data2) <- colnames(data1) <- tp
rownames(data2) <- 1:nperson+2*nperson
dg1 <- melt(data1)
dg2 <- melt(data2)
colnames(dg1) <- colnames(dg2) <- c('.obs','.index','.value')
# library(ggplot2)
# ggplot() + geom_line(data = dg1, aes(x = .index,y = .value, group = .obs))
# + geom_line(data = dg2, aes(x = .index, y = .value, group = .obs))
ngrid <- 50
ev.grid <- seq(0, 1, , ngrid)
nperm. <- 30
####Estimated with mgcv::gam
library(mgcv)
simu.test1 <- DVDtest(dg1, dg2, nperm. ,ev.grid)
####Estimated with gamlss::gamlss -! under debugging
## Not run:
library(gamlss)
library(gamlss.add)
simu.test2 <- DVDtest(dg1, dg2, nperm.,ev.grid, formula = .value ~ ga(~s(.index)) +
ga(~s(.obs, bs = "re")),
sigma.formula = ~ga(~s(.index)), family = NO, mgcv.gam=FALSE)
## End(Not run)
####Plot
simu.figs <- DVDplot(simu.test1)
simu.figs$pfig
simu.figs$kfig[[1]]
####Non-normal case -! under debugging
## Not run:
mu1 <- function(t) 0.2*(p-1)*sin(pi*t)+t+1
mu2 <- function(t) -0.2*(p-1)*sin(pi*t)+t+1
sig1 <- function(t) t+1
sig2 <- sig1
nu1 <- function(t) t+1
nu2 <- nu1
nperson <- 10
library(gamlss)
fun1 <- function(t) rGG(nperson, mu1(t), sig1(t),nu1(t))
fun2 <- function(t) rGG(nperson, mu2(t), sig2(t),nu2(t))
tp <- seq(0,1,,10)
data1 <- sapply(tp,fun1)
data2 <- sapply(tp,fun2)
library(reshape2)
colnames(data2) <- colnames(data1) <- tp
rownames(data2) <- 1:nperson+2*nperson
dg1 <- melt(data1)
dg2 <- melt(data2)
colnames(dg1) <- colnames(dg2) <- c('.obs','.index','.value')
ngrid <- 50
ev.grid <- seq(0, 1, , ngrid)
nperm. <- 30
simu.test3 <- DVDtest(dg1, dg2, nperm.,ev.grid, formula = .value ~ pb(.index),
sigma.formula = ~pb(.index),
nu.formula= ~pb(.index), seeds=123,
random = ~1|.obs, family = GG, mgcv.gam = FALSE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.