df4counts: Generates a Data Frame from a repeatedTrain Object After Time...

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/repeatedTrain.R

Description

Generates a data.frame object out of a repeatedTrain object after time binning in order to study trials stationarity with a glm fit.

Usage

1
df4counts(repeatedTrain, breaks = length(repeatedTrain))

Arguments

repeatedTrain

a repeatedTrain object or a list which can be coerced to such an object.

breaks

a numeric. A single number is interpreted has the number of bins; a vector is interpreted as the position of the "breaks" between bins.

Details

The bins are placed between the floor of the smallest spike time and the ceiling of the largest one when breaks is a scalar. After time binning the number of spikes of each trial falling in each bin is counted (in the same way as the counts component of a psth list is obtained). This matrix of count is then formatted as a data frame.

Value

A data.frame with the following variables:

Count

a count (number of spikes in a given bin at a given trial).

Bin

the bin index (a factor.

Trial

the trial index (a factor.

Rate

the count divided by the length of the corresponding bin.

Time

the time of the midpoints of the bins.

Note

When a glm of the poisson family is used for subsequent analysis the important implicit hypothesis of an inhomogenous Poisson train is of course made.

Author(s)

Christophe Pouzat christophe.pouzat@gmail.com

See Also

as.repeatedTrain, psth

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
## Not run: 
## Load the Vanillin responses of the first
## cockroach data set
data(CAL1V)
## convert them into repeatedTrain objects
## The stimulus command is on between 4.49 s and 4.99s
CAL1V <- lapply(CAL1V,as.repeatedTrain)
## Generate raster plot for neuron 1
raster(CAL1V[["neuron 1"]],c(4.49,4.99))
## make a smooth PSTH of these data
psth(CAL1V[["neuron 1"]],stimTimeCourse=c(4.49,4.99),breaks=c(bw=0.5,step=0.05),colCI=2,xlim=c(0,10))
## add a grid to the plot
grid()
## The response starts after 4.5 s and is mostly over after 6 s: create
## breaks accordingly
myBreaks <- c(0,2.25,4.5,seq(4.75,6.25,0.25),seq(6.5,11,0.5))
## get a count data frame
CAL1Vn1DF <- df4counts(CAL1V[["neuron 1"]],myBreaks)
## use a box plot to look at the result
boxplot(Rate ~ Time, data=CAL1Vn1DF)
## watch out here the time scale is distorted because of our
## choice of unequal bins
## Fit a glm of the Poisson family taking both Bin and Trial effects
CAL1Vn1DFglm <- glm(Count ~ Bin + Trial,family=poisson,data=CAL1Vn1DF)
## use an anova to see that both the Bin effect and the trial effect are
## highly significant
anova(CAL1Vn1DFglm, test="Chisq")

## End(Not run)

STAR documentation built on May 2, 2019, 11:44 a.m.