Skip to content
Snippets Groups Projects
Commit 89b4db01 authored by Wagner Hugo Bonat's avatar Wagner Hugo Bonat
Browse files

Aletarcoes gerais

parent 6492a19d
No related branches found
No related tags found
No related merge requests found
#' Default Multivariate Covariance Generalized Linear models plotting
#'
#' @description takes a fitted mcglm object by \code{mcglm()} and plots, residuals,
#' influence diagnostic measures and algorithm check.
#'
#' @param object a fitted mcglm object as produced by \code{mcglm()}.
#' @param type Specify which graphical analysis will be performed, options are: residuals, influence
#' and algorithm.
#' @exportMethod
plot.mcglm <- function(object, type = "residuals") {
n_resp <- length(object$beta_names)
if(type == "residuals") {
par(mar=c(2.6, 2.5, 0.1, 0.1), mgp = c(1.6, 0.6, 0), mfrow = c(2,n_resp))
for(i in 1:n_resp){
plot(residuals(object, type = "pearson")[,i] ~ fitted(object)[,i],
ylab = "Pearson residuals", xlab = "Fitted values")
temp <- loess.smooth(fitted(object)[,i],residuals(object, type = "pearson")[,i])
lines(temp$x,temp$y)
}
for(i in 1:n_resp) {
plot(residuals(object, type = "pearson")[,i] ~ object$observed[,i],
ylab = "Pearson residuals", xlab = "Observed values")
temp <- loess.smooth(object$observed[,i],residuals(object, type = "pearson")[,i])
lines(temp$x,temp$y)
}
}
if(type == "algorithm") {
n_iter <- length(na.exclude(object$IterationCovariance[,1]))
par(mar=c(2.6, 2.5, 0.1, 0.1), mgp = c(1.6, 0.6, 0), mfrow = c(2,2))
matplot(object$IterationRegression[1:c(n_iter+5),], type = "l", lty = 2, ylab = "Regression",
xlab = "Iterations")
matplot(object$IterationCovariance[1:c(n_iter+5),], type = "l", lty = 2, ylab = "Covariance",
xlab = "Iterations")
matplot(object$ScoreRegression[1:c(n_iter+5),], type = "l", lty = 2, ylab = "Quasi-score Regression",
xlab = "Iterations")
matplot(object$ScoreCovariance[1:c(n_iter+5),], type = "l", lty = 2, ylab = "Quasi-score Covariance",
xlab = "Iterations")
}
}
#' Summarizing Multivariate Covariance Generalized Linear Models fits.
#'
#' @description Summary for mcglm objects.
#'
#' @param object an object of class mcglm, usually, a result of a call to \code{mcglm}.
#' @exportMethod
summary.mcglm <- function(object) {
n_resp <- length(object$beta_names)
output <- list()
for(i in 1:n_resp) {
cat("Call: ")
print(object$linear_pred[[i]])
cat("\n")
cat("Link function:", object$link[[i]])
cat("\n")
cat("Variance function:", object$variance[[i]])
cat("\n")
cat("Covariance function:", object$covariance[[i]])
cat("\n")
cat("Regression:\n")
tab_beta <- coef(object, std.error = TRUE, response = i, type = "beta")[,1:2]
tab_beta$"z value" <- tab_beta[,1]/tab_beta[,2]
rownames(tab_beta) <- object$beta_names[[i]]
output[i][[1]]$Regression <- tab_beta
print(tab_beta)
cat("\n")
cat("Power:\n")
tab_power <- coef(object, std.error = TRUE, response = i, type = "power")[,1:2]
tab_power$'z value' <- tab_power[,1]/tab_power[,2]
rownames(tab_power) <- NULL
output[i][[1]]$Power <- tab_power
print(tab_power)
cat("\n")
cat("tau:\n")
tab_tau <- coef(object, std.error = TRUE, response = i, type = "tau")[,1:2]
tab_tau$'z value' <- tab_tau[,1]/tab_tau[,2]
rownames(tab_tau) <- NULL
output[i][[1]]$tau <- tab_tau
print(tab_tau)
cat("\n")
}
cat("Correlation matrix:\n")
tab_rho <- coef(object, std.error = TRUE, response = NA, type = "correlation")[,c(3,1,2)]
tab_rho$'z value' <- tab_rho[,2]/tab_rho[,3]
print(tab_rho)
cat("\n")
cat("Algorithm:")
print(object$con$method)
cat("Correction:")
print(object$con$correct)
cat("Number iterations:")
iteration_cov <- length(na.exclude(object$IterationCovariance[,1]))
print(iteration_cov)
}
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/mc_confint.mcglm.R
\name{confint.mcglm}
\alias{confint.mcglm}
\title{Confidence Intervals for mcglm}
\usage{
\method{confint}{mcglm}(object, level = 0.95)
}
\arguments{
\item{object}{a fitted mcglm object.}
\item{level}{the confidence level required.}
}
\value{
A data.frame with confidence intervals, parameters names,
response number and parameters type.
}
\description{
Computes confidence intervals for parameters in a fitted mcglm.
}
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/mc_updatedBeta.R
\name{mc_updateBeta}
\alias{mc_updateBeta}
\title{Updated regression parameters}
\usage{
mc_updateBeta(list_initial, betas, information, n_resp)
}
\arguments{
\item{list_initial}{A list of initial values.}
\item{betas}{A vector with actual regression parameters values.}
\item{information}{A list with information about the number of parameters in the model. In general
the output from \code{[mcglm]{mc_getInformation}}.}
\item{n_resp}{A numeric specyfing the number of response variables.}
}
\value{
A list with updated values of the regression parameters.
}
\description{
This function update a list of regression parameters. It will be useful only inside the
fitting algorithm.
}
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/mc_updatedCov.R
\name{mc_updateCov}
\alias{mc_updateCov}
\title{Updated covariance parameters}
\usage{
mc_updateCov(list_initial, covariance, list_power_fixed, information, n_resp)
}
\arguments{
\item{list_initial}{A list of initial values.}
\item{covariance}{A vector with actual covariance parameters values.}
\item{list_power_fixed}{A list of logicals indicating if the power parameter should be
estimated or not.}
\item{information}{A list with information about the number of parameters in the model. In general
the output from \code{[mcglm]{mc_getInformation}}.}
\item{n_resp}{A numeric specyfing the number of response variables.}
}
\value{
A list with updated values of the covariance parameters.
}
\description{
This function update a list of covariance parameters. It will be useful only inside
the fitting algorithm.
}
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/mc_plot.mcglm.R
\name{plot.mcglm}
\alias{plot.mcglm}
\title{Default Multivariate Covariance Generalized Linear models plotting}
\usage{
\method{plot}{mcglm}(object, type = "residuals")
}
\arguments{
\item{object}{a fitted mcglm object as produced by \code{mcglm()}.}
\item{type}{Specify which graphical analysis will be performed, options are: residuals, influence
and algorithm.}
}
\description{
takes a fitted mcglm object by \code{mcglm()} and plots, residuals,
influence diagnostic measures and algorithm check.
}
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/mc_print.mcglm.R
\name{print.mcglm}
\alias{print}
\alias{print.mcglm}
\title{Print a Multivariate Covariance Generalized Linear Model}
\usage{
print.mcglm(object)
}
\arguments{
\item{object}{fitted model objects of class mcglm as produced by mcglm().}
}
\description{
The default print method for a mcglm object.
}
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/mc_summary.mcglm.R
\name{summary.mcglm}
\alias{summary.mcglm}
\title{Summarizing Multivariate Covariance Generalized Linear Models fits.}
\usage{
summary.mcglm(object)
}
\arguments{
\item{object}{an object of class mcglm, usually, a result of a call to \code{mcglm}.}
}
\description{
Summary for mcglm objects.
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment