From d7bb8d4a0fd146ab27ca5d73f3c1ce5dcaf6736a Mon Sep 17 00:00:00 2001
From: Walmes Zeviani <walmes@ufpr.br>
Date: Thu, 7 Jan 2016 16:57:40 -0200
Subject: [PATCH] Add tags and tidy code/text.

---
 R/mc_dexpm.R          | 48 ++++++++++++++++++++++++-------------------
 R/mc_getInformation.R | 23 +++++++++++++--------
 2 files changed, 42 insertions(+), 29 deletions(-)

diff --git a/R/mc_dexpm.R b/R/mc_dexpm.R
index 212410d..10cb874 100644
--- a/R/mc_dexpm.R
+++ b/R/mc_dexpm.R
@@ -1,32 +1,38 @@
-#' Exponential-matrix covariance link function
+#' @title Exponential-matrix covariance link function
+#' @author Wagner Hugo Bonat
 #'
-#'@description Given a matrix \code{U} the function \code{mc_expm}
-#'returns the exponential-matrix \eqn{expm(U)} and some auxiliares matrices to compute
-#'its derivatives. This function is based on the eigen-value decomposition it means that it is
-#'very slow.
+#' @description Given a matrix \code{U} the function \code{mc_expm}
+#'     returns the exponential-matrix \eqn{expm(U)} and some auxiliares
+#'     matrices to compute its derivatives. This function is based on
+#'     the eigen-value decomposition it means that it is very slow.
 #'
-#'@param U A matrix.
-#'@param n A number specifing the dimension of the matrix U. Default \code{n = dim(U)[1]}.
-#'@param sparse Logical defining the class of the output matrix. If \code{sparse = TRUE} the output
-#'class will be 'dgCMatrix' if \code{sparse = FALSE} the class will be 'dgMatrix'.
-#'@param inverse Logical defining if the inverse will be computed or not.
-#'@return A list with \eqn{\Omega = expm(U)} its inverse (if \code{inverse = TRUE}) and
-#' auxiliares matrices to compute the derivatives.
+#' @param U A matrix.
+#' @param n A number specifing the dimension of the matrix U. Default
+#'     \code{n = dim(U)[1]}.
+#' @param sparse Logical defining the class of the output matrix. If
+#'     \code{sparse = TRUE} the output class will be 'dgCMatrix' if
+#'     \code{sparse = FALSE} the class will be 'dgMatrix'.
+#' @param inverse Logical defining if the inverse will be computed or
+#'     not.
+#' @return A list with \eqn{\Omega = expm(U)} its inverse (if
+#'     \code{inverse = TRUE}) and auxiliares matrices to compute the
+#'     derivatives.
 #'
-#'@seealso \code{\link[Matrix]{expm}}, \code{\link[base]{eigen}},
-#'\code{link[mcglm]{mc_dexp_gold}}.
+#' @seealso \code{\link[Matrix]{expm}}, \code{\link[base]{eigen}},
+#'     \code{link[mcglm]{mc_dexp_gold}}.
 
 mc_expm <- function(U, n = dim(U)[1], sparse = FALSE, inverse = FALSE) {
-    tt = eigen(U, symmetric = TRUE)
-    UU = tt$vectors
-    Q = tt$values
-    eQr = Diagonal(n, exp(tt$values))
+    tt <- eigen(U, symmetric = TRUE)
+    UU <- tt$vectors
+    Q <- tt$values
+    eQr <- Diagonal(n, exp(tt$values))
     inv_UU <- t(UU)
-    Omega = Matrix(UU %*% eQr %*% inv_UU, sparse = sparse)
+    Omega <- Matrix(UU %*% eQr %*% inv_UU, sparse = sparse)
     if (inverse == TRUE) {
-        eQr_INV = Diagonal(n, exp(-tt$values))
+        eQr_INV <- Diagonal(n, exp(-tt$values))
         inv_Omega <- Matrix(UU %*% eQr_INV %*% inv_UU, sparse = sparse)
-        saida <- list(Omega = Omega, inv_Omega = inv_Omega, UU = UU, Q = Q, inv_UU = inv_UU)
+        saida <- list(Omega = Omega, inv_Omega = inv_Omega, UU = UU, 
+                      Q = Q, inv_UU = inv_UU)
     }
     if (inverse == FALSE) {
         saida <- list(Omega = Omega, UU = UU, Q = Q, inv_UU = inv_UU)
diff --git a/R/mc_getInformation.R b/R/mc_getInformation.R
index 946f044..7c1d363 100644
--- a/R/mc_getInformation.R
+++ b/R/mc_getInformation.R
@@ -1,19 +1,24 @@
-#' Getting information about model parameters
+#' @title Getting information about model parameters
+#' @author Wagner Hugo Bonat
 #'
-#' @description This computes all information required about the number of model parameters.
+#' @description This computes all information required about the number
+#'     of model parameters.
 #'
 #' @param list_initial A list of initial values.
-#' @param list_power_fixed A list of logical specyfing if the power parameters should be estimated or not.
+#' @param list_power_fixed A list of logical specyfing if the power
+#'     parameters should be estimated or not.
 #' @param n_resp A number specyfing the nmber of response variables.
-#' @return The number of \eqn{\beta}'s, \eqn{\tau}'s, power and correlation parameters.
+#' @return The number of \eqn{\beta}'s, \eqn{\tau}'s, power and
+#'     correlation parameters.
 
-mc_getInformation <- function(list_initial, list_power_fixed, n_resp) {
+mc_getInformation <- function(list_initial, list_power_fixed,
+                              n_resp) {
     n_betas <- lapply(list_initial$regression, length)
     n_taus <- lapply(list_initial$tau, length)
     n_power <- lapply(list_initial$power, length)
     for (i in 1:n_resp) {
         if (list_power_fixed[[i]] == TRUE) {
-            n_power[i] = 0
+            n_power[i] <- 0
         }
     }
     if (n_resp == 1) {
@@ -22,7 +27,9 @@ mc_getInformation <- function(list_initial, list_power_fixed, n_resp) {
     if (n_resp != 1) {
         n_rho <- length(list_initial$rho)
     }
-    n_cov <- sum(do.call(c, n_power)) + n_rho + sum(do.call(c, n_taus))
-    saida <- list(n_betas = n_betas, n_taus = n_taus, n_power = n_power, n_rho = n_rho, n_cov = n_cov)
+    n_cov <- sum(do.call(c, n_power)) + n_rho +
+        sum(do.call(c, n_taus))
+    saida <- list(n_betas = n_betas, n_taus = n_taus, n_power = n_power,
+                  n_rho = n_rho, n_cov = n_cov)
     return(saida)
 }
-- 
GitLab