Skip to content

Commit

Permalink
version 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoprojs authored and cran-robot committed Oct 6, 2023
1 parent e6ec65b commit e4e21a4
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 10 deletions.
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
Package: MTest
Type: Package
Title: A Procedure for Multicollinearity Testing using Bootstrap
Version: 1.0.1
Date: 2023-09-20
Version: 1.0.2
Date: 2023-10-06
Authors@R: c(person("Víctor", "Morales-Oñate",role=c("aut","cre"),email="victor.morales@uv.cl",comment = c(ORCID = "0000-0003-1922-6571")),person("Bolívar", "Morales-Oñate", role = "aut",email = "bmoralesonate@gmail.com",comment = c(ORCID = "0000-0003-4980-8759")))
Maintainer: Víctor Morales-Oñate <victor.morales@uv.cl>
Description: Functions for detecting multicollinearity. This test gives statistical support to two of the most famous methods for detecting multicollinearity in applied work: Klein’s rule and Variance Inflation Factor (VIF). See the URL for the papers associated with this package, as for instance, Morales-Oñate and Morales-Oñate (2015) <doi:10.33333/rp.vol51n2.05>.
Depends: R (>= 4.1.0)
License: GPL (>= 3)
Encoding: UTF-8
Imports: car
Imports: car, ggplot2,plotly
Repository: CRAN
URL: https://github.com/vmoprojs/MTest
BugReports: https://github.com/vmoprojs/MTest/issues
LazyData: true
NeedsCompilation: no
Packaged: 2023-09-20 10:51:52 UTC; victormorales
Packaged: 2023-10-06 12:32:24 UTC; victormorales
Author: Víctor Morales-Oñate [aut, cre]
(<https://orcid.org/0000-0003-1922-6571>),
Bolívar Morales-Oñate [aut] (<https://orcid.org/0000-0003-4980-8759>)
Date/Publication: 2023-09-20 11:10:02 UTC
Date/Publication: 2023-10-06 13:10:02 UTC
7 changes: 4 additions & 3 deletions MD5
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
42dfbc9050ed5e0ff0d9afbe56ade212 *DESCRIPTION
ca6b69660ab9ae7f10b01bc1773b413d *NAMESPACE
ba821e2c627f1f13834a2e66872ab1c6 *R/MTest.R
52391516a5edb74d8832b707cb43baf8 *DESCRIPTION
c6db890666121f50a79d66a1c8c66411 *NAMESPACE
6601294a8a9d605888fd1bcb9950b93a *R/MTest.R
1501717ff082b6726f453168ae7280d1 *R/pairwiseKStest.R
439bf689fa27cf9affd0335332142165 *build/partial.rdb
89bc2ba09e07d8ada709c04e793c101c *data/simDataMTest.RData
40818813104c7d3548dae683eb452cd0 *man/MTest.Rd
e043fd9b1da9d1e5329d80eafaf80094 *man/pairwiseKStest.Rd
c42f0f23d8cb5003ec8bc865bed0a450 *man/plot.MTest.Rd
30dfd752af61eaecfff2cffbdc217306 *man/simDataMTest.Rd
6 changes: 5 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export(MTest,pairwiseKStest)
importFrom("stats", "formula", "ks.test", "lm", "terms")
S3method(print,MTest)
importFrom("utils", "stack")
importFrom("ggplot2", "ggplot", "aes", "stat_ecdf", "geom_density")
importFrom("plotly","ggplotly")
S3method(print,MTest)
S3method(plot,MTest)
51 changes: 50 additions & 1 deletion R/MTest.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@ MTest <- function (object, nboot = 100, nsam = NULL, trace = FALSE, seed = NULL,
sep = ""))
rownames(sol.rsq) <- 1:nrow(sol.rsq)

return(list(Bvals = sol.rsq, pval_vif = pval_vif, pval_klein = pval_klein,
MTest <- (list(Bvals = sol.rsq, pval_vif = pval_vif, pval_klein = pval_klein,
vif.tot = vif.global, R.tot = R.aux.global,nsam = nsam))

structure(c(MTest, call = call), class = c("MTest"))
}


Expand Down Expand Up @@ -116,4 +118,51 @@ print.MTest <- function(x, digits = max(3, getOption("digits") - 3), ...)

cat('\n##################################################################\n')
invisible(x)
}


plot.MTest <- function(x,type = 1,plotly = FALSE,...)
{
if(!inherits(x,"MTest")) stop("Enter an object obtained from the function MTest\n")
ind <- values <- NULL
boot.sol <- x
boot.sol <- stack(data.frame(boot.sol$Bvals))
boot.global <- boot.sol[boot.sol["ind"]=="global",]
var =
boot.aux <- boot.sol[boot.sol["ind"]!="global",]

# ****** ECDF
g_ecdf_global <- ggplot2::ggplot(boot.global,
ggplot2::aes(values,color = ind)) +
ggplot2::stat_ecdf(geom = "step")
g_ecdf_aux <- ggplot2::ggplot(boot.aux,
ggplot2::aes(values,color = ind)) +
ggplot2::stat_ecdf(geom = "step")
g_ecdf_sol <- ggplot2::ggplot(boot.sol,
ggplot2::aes(values,color = ind)) +
ggplot2::stat_ecdf(geom = "step")

# ******* Density
g_dens_sol <- ggplot2::ggplot(boot.sol,
ggplot2::aes(x=values,color = ind)) +
ggplot2::geom_density()

if(type == 2 & plotly == FALSE)
{
print(g_ecdf_sol)
}
if(type == 1 & plotly == FALSE)
{
print(g_dens_sol)
}
if(plotly==TRUE & type == 1)
{
g_dens_sol <- plotly::ggplotly(g_dens_sol)
print(g_dens_sol)
}
if(plotly==TRUE & type == 2)
{
g_ecdf_sol <- plotly::ggplotly(g_ecdf_sol)
print(g_ecdf_sol)
}
}
39 changes: 39 additions & 0 deletions man/plot.MTest.Rd
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
\name{plot.MTest}
\alias{plot.MTest}
\encoding{UTF-8}
\title{Plot density or empirical cumulative distribution from MTest}

\description{
Plot density or empirical cumulative distribution from \code{Bvals} in \code{\link{MTest} output}.
}

\usage{
\method{plot}{MTest}(x, type=1,plotly = FALSE,...)
}

\arguments{

\item{x}{an object of the class \code{"MTest"} }
\item{type}{Numeric; 1 if density, 2 if ecdf plot is returned}
\item{plotly}{Logical; if \code{FALSE}, a \code{ggplotly} plot is returned}
\item{\dots}{other arguments to be passed to the function
\code{\link{ggplot}} }
}


\value{
Produces a plot.
No values are returned.
}

\details{
This function plots density or empirical cumulative distribution function from MTest bootstrap replications.
}



\seealso{
\code{\link{MTest}} for procedure and examples.
}

\keyword{MTest}

0 comments on commit e4e21a4

Please sign in to comment.