fitNormDistr-methods: fitNormDistr

Description Usage Arguments Details Value Examples

Description

fit normal distributions to diffusion coefficient caclulated by Dcoef method.

Usage

1
2
fitNormDistr(dcoef,components=NULL,log.transform=F,binwidth=NULL,combine.plot=F,output=F,
             seed=NULL, proportion=NULL, means=NULL, sd=NULL, constrain=F)

Arguments

seed

Seed for random number generator. This makes each run easily repeatable. Seed will be automatically assigned if no seed is specified (default). The seed information is stored as an attribute of the returned object. The seed can also be output to a txt file when output=T.

dcoef

diffusion coefficient calculated from Dcoef().

components

parameter specifying the number of components to fit. If NULL (default), a components analysis is done to determine the most likely components and this number is then used for subsequent analysis.

log.transform

logical indicate if log10 transformation is needed, default F.

binwidth

binwidth for the combined plot. If NULL (default), will automatic assign binwidth.

combine.plot

Logical indicate if all the plot should be combined into one, with same scale (/same axises breaks), same color theme, and same bin size for comparison.

output

logical indicate if output file should be generated.

proportion

numeric vector with estimates of each component's proportion of the whole data.

means

numeric vector with estimates of mean(mu) values for each component.

sd

numeric vector with estimates of standard deviation(sigma) values for each component.

constrain

logical indicate if mean and std deviation are set to the given value. This will not work for the unimodal distribution.

Details

components analysis uses the likelihood ratio test (LRT) to assess the number of mixture components. Bad Random seed generation may cause normalmixEM to crash. Running the function again would be the quickest solution to this issue.

Value

proportions

The proportions of mixing components.

mean

The Means of the components.

sd

The Standard Deviations (SD) of components if not log transformed; if log transformed, it is then interpreted as Coefficient of Variation (CV).

loglik

The log likelihood, useful for compare different fitting result, the bigger the better fit.

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
# compare folders
folder1=system.file("extdata","SWR1",package="sojourner")
folder2=system.file("extdata","HTZ1",package="sojourner")
trackll=compareFolder(c(folder1,folder2))
MSD=msd(trackll=trackll)
dcoef=Dcoef(MSD,dt=6,plot=TRUE,output=FALSE)
# fit dcoef
a=fitNormDistr(dcoef,components=NULL,log.transform=FALSE,combine.plot=FALSE,output=FALSE)
# to repeat a
b=fitNormDistr(dcoef,components=NULL,log.transform=FALSE,
combine.plot=FALSE,output=FALSE,seed=attr(a,"seed"))
# if a and b are the same
mapply(identical,a[[1]],b[[1]])
#try with log transformation
c=fitNormDistr(dcoef,components=2,log.transform=TRUE,combine.plot=FALSE,output=FALSE)
#trying with some parameters provided(this will be applied to all dcoef results). 
#with constrain = F, this will be used as the starting values for the EM-algorithm
#normally we should deal with only one dataset when working with constrains, 
#since it will apply to all of them.
folder3=system.file("extdata","HSF", package="sojourner")
trackll=compareFolder(c(folder3),input=2)
MSD=msd(trackll=trackll)
dcoef=Dcoef(MSD,dt=6,plot=TRUE,output=FALSE)
#try with constrain =T, the values will be forced to eqaul the provided ones.
e=fitNormDistr(dcoef,means=c(0.3,0.5), constrain=TRUE)

snjy9182/sojourner documentation built on May 26, 2019, 4:33 a.m.