logLik-methods              package:vsn              R Documentation

_C_a_l_c_u_l_a_t_e _t_h_e _l_o_g _l_i_k_e_l_i_h_o_o_d _a_n_d _i_t_s _g_r_a_d_i_e_n_t _f_o_r
_t_h_e _v_s_n _m_o_d_e_l

_D_e_s_c_r_i_p_t_i_o_n:

     '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.

_U_s_a_g_e:

     ## S4 method for signature 'vsnInput':
     logLik(object, p, refh=numeric(0), refsigma=as.numeric(NA))

     plotVsnLogLik(object, p, whichp=1:2, expand=1, ngrid=31, fun=logLik, ...)

_A_r_g_u_m_e_n_t_s:

  object: A 'vsnInput' object.

       p: A matrix whose columns are the set of parameters at which the
          likelihoods are to be evaluated.

    refh: Numeric vector of length 0 or 'nrow(object)'. If the length
          is 0, there is no reference and and 'refsigma' must be
          missing. See 'vsn2'.

refsigma: Numeric scalar.

  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 that heuristic is not very good in particular
          for the offset (a) parameters; see example.

   ngrid: Grid size.

     fun: Function to use for log-likelihood calculation. This
          parameter is exposed only for testing purposes.

     ...: Arguments that get passed on to 'fun', use this for 'refh'
          and 'refsigma'.

_D_e_t_a_i_l_s:

     'logLik' is an R interface to the likelihood computations in vsn
     (which are done in C).

_V_a_l_u_e:

     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 'refh' and 'refsigma' 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.

_A_u_t_h_o_r(_s):

     Wolfgang Huber <URL: http://www.ebi.ac.uk/huber>

_S_e_e _A_l_s_o:

     'vsn2'

_E_x_a_m_p_l_e_s:

     data("kidney")

     v = new("vsnInput", x=exprs(kidney),
       pstart=array(as.numeric(NA), dim=c(1, ncol(kidney), 2)))
      
     fit = vsn2(kidney)

     p = sapply(exp(seq(-1, 1, length=31)), function(f) fit@par*c(1,1,f,1))

     ll = logLik(v, p)

     plot(p[3, ], ll[1, ], type="l", xlab=expression(b[1]), ylab=expression(-log(L)), log="x")
     abline(v=fit@par[3], col="red")

     plotVsnLogLik(v, fit@par, whichp=c(1,3), expand=c(0.01, 1))

