bestgam: Fit an optimal smoothing spline to a data vector y, indexed...

Description Usage Arguments Details Value Author(s) Examples

Description

For a data vector y, where tp assigns a time point to each value in y, a smoothing spline is fitted through the data points. To find an optimal spline, a series of fits is performed with increasing number of degrees of freedom and the optimal fit is selected via ANOVA testing and selection using the selection.criterion.

Usage

1
bestgam(y, tp, xn, selection.criterion = "aic")

Arguments

y

Numeric vector. The data points.

tp

Numeric vector. The corresponding time points.

xn

Numeric vector. The time values for the prediction.

selection.criterion

String. Either "aic" for Akaike's Information Criterion, "BIC" for Bayesian Information Criterion or "pvalue" for model selection according to the p-value.

Details

Several smoothing splines with increasing number of degrees of freedom are fit to the data (maximal number of df is one less than time points). Additionally, a constant and linear model fit is produced. The linear and smoothing spline fits are each compared to the constant fit via analysis of variance/deviance (ANOVA) to decide whether significant improvement of the complex model fits compared to the simple constant fit were got. This can also be seen as identification of a significant effect over time. To select a specific curve, the resulting p-values from the ANOVA are used. Either directly by selecting the minimal p-value of all fit comparisons, or by plugging in the p-value into AIC or BIC and maximising the respective statistic.

After the optimal fit is selected, a prediciton of the time profile is calculated, using the time vector xn as predictor variable in the fit.

esub is a helper for the gam fitting, usually not called directly.

Value

Returns a vector with the predicted values for the time vector xn.

Author(s)

Christian Bender
Tim Beissbarth
Stephan Gade

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
## Not run: 
## load package
library(ddepn)
library(multicore)
library(gam)

## sample a network and data
set.seed(1234)
n <- 6
signet <- signalnetwork(n=n, nstim=2, cstim=0, prop.inh=0.2)
phit <- signet$phi
stimuli <- signet$stimuli
dataset <- makedata(phit, stimuli, mu.bg=1200, sd.bg=400, mu.signal.a=2000, sd.signal.a=1000)

## select an experiment

prepare_bestgam <- function(dataset, experiment, protein) {
  stimuli <- dataset$stimuli
  dat <- dataset$datx
  stim <- names(stimuli[[experiment]])
  sel <- grep(paste("^",stim,"_.*$",sep=""), colnames(dat))
  y <- dat[protein,sel]
  tp <- as.numeric(sub("^.*_","",colnames(dat)[sel]))
  #ord <- order(tp)
  #y <- y[ord]
  #tp <- tp[ord]
  xn <- seq(0,max(tp),0.1)
  return(list(y=y, tp=tp, xn=xn))
}

## no effect observed in experiment 1, protein 2
lst <- prepare_bestgam(dataset, 1, 2)
yhat <- bestgam(lst$y, lst$tp, lst$xn, "aic")
plot(lst$y~lst$tp)
lines(lst$xn,yhat)
 
## effect observed in experiment 1, protein 5
lst <- prepare_bestgam(dataset, 1, 5)
yhat <- bestgam(lst$y, lst$tp, lst$xn, "aic")
plot(lst$y~lst$tp)
lines(lst$xn,yhat)
 

## End(Not run)

ddepn documentation built on May 2, 2019, 4:42 p.m.