Skip to content
Snippets Groups Projects
Commit 4671672c authored by Walmes Marques Zeviani's avatar Walmes Marques Zeviani
Browse files

Add tags and tidy code and text

  - Add @title, @name and @author.
  - Tidy code and text.
parent 3222d2a8
No related branches found
No related tags found
No related merge requests found
#' Bias-corrected standard error for regression parameters
#' @title Bias-corrected standard error for regression parameters
#' @name mc_bias_corrected_std
#' @author Wagner Hugo Bonat
#'
#' @description Compute bias-corrected standard error for regression parameters in the context
#' of clustered observations. It is also robust and has improved finite sample properties.
#' @description Compute bias-corrected standard error for regression
#' parameters in the context of clustered observations. It is also
#' robust and has improved finite sample properties.
#'
#' @param object An object of mcglm class.
#' @param id a vector which identifies the clusters. The length and order of id should be the
#' same as the number of observations. Data are assumed to be sorted so that observations on a cluster
#' are contiguous rows for all entities in the formula.
#' @return A matrix. Note that the function assumes that the data are in the correct order.
#' @param id a vector which identifies the clusters. The length and
#' order of id should be the same as the number of
#' observations. Data are assumed to be sorted so that observations
#' on a cluster are contiguous rows for all entities in the formula.
#' @return A matrix. Note that the function assumes that the data are in
#' the correct order.
#' @export
mc_bias_corrected_std <- function(object, id) {
......@@ -26,7 +31,8 @@ mc_bias_corrected_std <- function(object, id) {
for (i in 1:n_id) {
idTF <- id == uni_id[i]
if (sum(idTF) == 1) {
Di[[i]] <- Matrix(D[idTF,], nrow = sum(idTF), ncol = dim(D)[2])
Di[[i]] <- Matrix(D[idTF, ], nrow = sum(idTF),
ncol = dim(D)[2])
} else {
Di[[i]] <- D[idTF, ]
}
......@@ -36,9 +42,8 @@ mc_bias_corrected_std <- function(object, id) {
H <- bdiag(Hi)
I <- Diagonal(dim(temp_data)[1], 1)
inv_IH <- solve(I - H)
Vbeta = inv_M%*%(t(D)%*%object$inv_C%*%inv_IH%*%R%*%inv_IH%*%
object$inv_C%*%D)%*%inv_M
output = sqrt(diag(Vbeta))
Vbeta <- inv_M %*% (t(D) %*% object$inv_C %*% inv_IH %*%
R %*% inv_IH %*% object$inv_C %*% D) %*% inv_M
output <- sqrt(diag(Vbeta))
return(output)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment