R: Calculate the log likelihood and its gradient for the vsn...
logLik-methods
R Documentation
Calculate the log likelihood and its gradient for
the vsn model
Description
logLik calculates the log likelihood and its gradient
for the vsn model. plotVsnLogLik makes a false color plot for
a 2D section of the likelihood landscape.
Usage
## S4 method for signature 'vsnInput'
logLik(object, p, mu = numeric(0), sigsq=as.numeric(NA), calib="affine")
plotVsnLogLik(object,
p,
whichp = 1:2,
expand = 1,
ngrid = 31L,
fun = logLik,
main = "log likelihood",
...)
Arguments
object
A vsnInput object.
p
For plotVsnLogLik, a vector or a 3D array with the
point in parameter space around which to plot the likelihood.
For logLik, a matrix whose columns are the set of parameters at which
the likelihoods are to be evaluated.
mu
Numeric vector of length 0 or nrow(object).
If the length is 0, there is no reference and sigsq must be
NA (the default value). See vsn2.
sigsq
Numeric scalar.
calib
as in vsn2.
whichp
Numeric vector of length 2, with the indices of those
two parameters in p along which the section is to be taken.
expand
Numeric vector of length 1 or 2 with expansion factors
for the plot range. The range is auto-calculated using a heuristic,
but manual adjustment can be useful; see example.
ngrid
Integer scalar, the grid size.
fun
Function to use for log-likelihood calculation. This
parameter is exposed only for testing purposes.
main
This parameter is passed on levelplot.
...
Arguments that get passed on to fun, use this for
mu, sigsq, calib.
Details
logLik is an R interface to the likelihood computations in vsn (which are done in C).
Value
For logLik, a numeric matrix of size nrow(p)+1 by ncol(p).
Its columns correspond to the columns of p.
Its first row are the likelihood values, its rows 2...nrow(p)+1
contain the gradients.
If mu and sigsq are
specified, the ordinary negative log likelihood is calculated using these
parameters as given. If they are not specified, the profile negative log likelihood
is calculated.
For plotVsnLogLik, a dataframe with the 2D grid coordinates and
log likelihood values.
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(vsn)
Loading required package: Biobase
Loading required package: BiocGenerics
Loading required package: parallel
Attaching package: 'BiocGenerics'
The following objects are masked from 'package:parallel':
clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
clusterExport, clusterMap, parApply, parCapply, parLapply,
parLapplyLB, parRapply, parSapply, parSapplyLB
The following objects are masked from 'package:stats':
IQR, mad, xtabs
The following objects are masked from 'package:base':
Filter, Find, Map, Position, Reduce, anyDuplicated, append,
as.data.frame, cbind, colnames, do.call, duplicated, eval, evalq,
get, grep, grepl, intersect, is.unsorted, lapply, lengths, mapply,
match, mget, order, paste, pmax, pmax.int, pmin, pmin.int, rank,
rbind, rownames, sapply, setdiff, sort, table, tapply, union,
unique, unsplit
Welcome to Bioconductor
Vignettes contain introductory material; view with
'browseVignettes()'. To cite Bioconductor, see
'citation("Biobase")', and for packages 'citation("pkgname")'.
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/vsn/vsnLikelihood.Rd_%03d_medium.png", width=480, height=480)
> ### Name: logLik-methods
> ### Title: Calculate the log likelihood and its gradient for the vsn model
> ### Aliases: logLik-methods logLik,vsnInput-method plotVsnLogLik
>
> ### ** Examples
>
>
> data("kidney")
>
> v = new("vsnInput", x=exprs(kidney),
+ pstart=array(as.numeric(NA), dim=c(1, ncol(kidney), 2)))
>
> fit = vsn2(kidney)
> print(coef(fit))
, , 1
[,1] [,2]
[1,] -0.5504617 -0.5350711
, , 2
[,1] [,2]
[1,] -5.835777 -5.861253
>
> p = sapply(seq(-1, 1, length=31), function(f) coef(fit)+c(0,0,f,0))
>
> ll = logLik(v, p)
>
> plot(p[3, ], ll[1, ], type="l", xlab=expression(b[1]), ylab=expression(-log(L)))
> abline(v=coef(fit)[3], col="red")
>
> plotVsnLogLik(v, coef(fit), whichp=c(1,3), expand=0.2)
>
>
>
>
>
> dev.off()
null device
1
>