Skip to content

Commit

Permalink
Merge pull request #3 from friendly/roxygen
Browse files Browse the repository at this point in the history
Roxygen
  • Loading branch information
friendly committed May 6, 2024
2 parents 387575b + 003cfb2 commit d95199e
Show file tree
Hide file tree
Showing 104 changed files with 7,994 additions and 3,554 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ README.md
^docs$
^pkgdown$
.nojekyll
man-old/
NAMESPACE-old
.build-steps.R
33 changes: 24 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
Package: candisc
Type: Package
Title: Visualizing Generalized Canonical Discriminant and Canonical Correlation Analysis
Version: 0.8-6
Date: 2021-10-06
Depends: R (>= 3.5.0), car, heplots (>= 0.8-6), graphics, stats
Suggests: rgl, corrplot,
Version: 0.9.0
Date: 2024-05-05
Depends: R (>= 3.5.0), heplots (>= 0.8-6)
Imports: car, graphics, stats
Suggests:
rgl,
carData,
corrplot,
knitr,
rmarkdown,
MASS, rpart, rpart.plot
MASS,
rpart,
rpart.plot
LazyLoad: yes
LazyData: yes
Authors@R: c(person(given = "Michael", family = "Friendly", role=c("aut", "cre"), email="friendly@yorku.ca"),
person(given = "John", family = "Fox", role="aut"))
Author: Michael Friendly [aut, cre], John Fox [aut]
Authors@R: c(
person(given = "Michael",
family = "Friendly",
role=c("aut", "cre"),
email="friendly@yorku.ca",
comment = c(ORCID = "0000-0002-3237-0941")),
person(given = "John",
family = "Fox", role="aut",
comment = c(ORCID = "0000-0002-1196-8012"))
)
Maintainer: Michael Friendly <friendly@yorku.ca>
Language: en-US
Description: Functions for computing and visualizing
Expand All @@ -27,6 +40,8 @@ Description: Functions for computing and visualizing
visualizations of terms in an 'mlm' via the 'plot.candisc' and 'heplot.candisc' methods. Related plots are
now provided for canonical correlation analysis when all predictors are quantitative.
License: GPL (>= 2)
Packaged: 10/9/2008 6:12PM; Michael Friendly
Encoding: UTF-8
VignetteBuilder: knitr
URL: https://github.com/friendly/candisc/, https://friendly.github.io/candisc/
BugReports: https://github.com/friendly/candisc/issues
RoxygenNote: 7.3.1
133 changes: 78 additions & 55 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,55 +1,78 @@
# last modified 6 October 2007 by J. Fox
# last modified 22 April 2009 by M. Friendly

import(car)

import(heplots)
import(graphics)
import(stats)
importFrom("grDevices", "palette")
importFrom("utils", "menu")

export(candisc, candiscList, dataIndex,
cancor, vectors, Wilks, scores, redundancy, vecscale, can_lm, varOrder)
#S3method(can_lm, mlm)
S3method(candisc, mlm)
S3method(candiscList, mlm)
S3method(coef, candisc)
S3method(plot, candisc)
S3method(plot, candiscList)
S3method(print, candisc)
S3method(print, candiscList)
S3method(summary, candisc)
S3method(summary, candiscList)

# the following may be moved to the heplots package
S3method(heplot, candisc)
S3method(heplot3d, candisc)
S3method(heplot, candiscList)
S3method(heplot3d, candiscList)

# new for cancor
S3method(cancor, default)
S3method(cancor, formula)
S3method(print, cancor)
S3method(summary, cancor)
S3method(coef, cancor)
S3method(Wilks, cancor)
S3method(Wilks, candisc)
S3method(heplot, cancor)
S3method(scores, cancor)
S3method(print, cancor.redundancy)
S3method(plot, cancor)
S3method(heplot3d, cancor)

S3method(varOrder, mlm)
S3method(varOrder, data.frame)









# Generated by roxygen2: do not edit by hand

S3method(Wilks,cancor)
S3method(Wilks,candisc)
S3method(cancor,default)
S3method(cancor,formula)
S3method(candisc,mlm)
S3method(candiscList,mlm)
S3method(coef,cancor)
S3method(coef,candisc)
S3method(heplot,cancor)
S3method(heplot,candisc)
S3method(heplot,candiscList)
S3method(heplot3d,cancor)
S3method(heplot3d,candisc)
S3method(heplot3d,candiscList)
S3method(plot,cancor)
S3method(plot,candisc)
S3method(plot,candiscList)
S3method(predictor.names,default)
S3method(print,cancor)
S3method(print,cancor.redundancy)
S3method(print,candisc)
S3method(print,candiscList)
S3method(scores,cancor)
S3method(summary,cancor)
S3method(summary,candisc)
S3method(summary,candiscList)
S3method(varOrder,data.frame)
S3method(varOrder,default)
S3method(varOrder,mlm)
export(Wilks)
export(can_lm)
export(cancor)
export(candisc)
export(candiscList)
export(dataIndex)
export(predictor.names)
export(redundancy)
export(scores)
export(varOrder)
export(vecscale)
export(vectors)
importFrom(car,Anova)
importFrom(car,dataEllipse)
importFrom(car,loessLine)
importFrom(car,showLabels)
importFrom(grDevices,palette)
importFrom(graphics,abline)
importFrom(graphics,arrows)
importFrom(graphics,boxplot)
importFrom(graphics,layout)
importFrom(graphics,lines)
importFrom(graphics,par)
importFrom(graphics,points)
importFrom(graphics,polygon)
importFrom(graphics,symbols)
importFrom(graphics,text)
importFrom(heplots,heplot)
importFrom(heplots,heplot3d)
importFrom(stats,aggregate)
importFrom(stats,complete.cases)
importFrom(stats,contrasts)
importFrom(stats,cor)
importFrom(stats,cov)
importFrom(stats,cov.wt)
importFrom(stats,formula)
importFrom(stats,lsfit)
importFrom(stats,model.frame)
importFrom(stats,model.matrix)
importFrom(stats,model.response)
importFrom(stats,model.weights)
importFrom(stats,pf)
importFrom(stats,qchisq)
importFrom(stats,terms)
importFrom(stats,update)
importFrom(stats,var)
importFrom(utils,menu)
55 changes: 55 additions & 0 deletions NAMESPACE-old
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# last modified 6 October 2007 by J. Fox
# last modified 22 April 2009 by M. Friendly

import(car)

import(heplots)
import(graphics)
import(stats)
importFrom("grDevices", "palette")
importFrom("utils", "menu")

export(candisc, candiscList, dataIndex,
cancor, vectors, Wilks, scores, redundancy, vecscale, can_lm, varOrder)
#S3method(can_lm, mlm)
S3method(candisc, mlm)
S3method(candiscList, mlm)
S3method(coef, candisc)
S3method(plot, candisc)
S3method(plot, candiscList)
S3method(print, candisc)
S3method(print, candiscList)
S3method(summary, candisc)
S3method(summary, candiscList)

# the following may be moved to the heplots package
S3method(heplot, candisc)
S3method(heplot3d, candisc)
S3method(heplot, candiscList)
S3method(heplot3d, candiscList)

# new for cancor
S3method(cancor, default)
S3method(cancor, formula)
S3method(print, cancor)
S3method(summary, cancor)
S3method(coef, cancor)
S3method(Wilks, cancor)
S3method(Wilks, candisc)
S3method(heplot, cancor)
S3method(scores, cancor)
S3method(print, cancor.redundancy)
S3method(plot, cancor)
S3method(heplot3d, cancor)

S3method(varOrder, mlm)
S3method(varOrder, data.frame)









7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Version 0.9.0 (2024-05-05)

* Created `pkgdown` site, https://friendly.github.io/candisc/
* Convert documentation to roxygen
* Extend description of candisc/cancor methods
* Added `diabetes` vignette giving more discursive examples

## Version 0.8-6 (2021-10-06)

* Fix JSS URLs -> DOI
Expand Down
29 changes: 29 additions & 0 deletions R/.build-steps.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Sys.setenv(RGL_USE_NULL = TRUE)

# get list of possibly misspelled words
wds <- spelling::spell_check_package()
cat(paste(wds[, "word"], collapse = "\n"))
# to add all words
update_wordlist()

# check reverse dependencies
devtools::revdep()
# [1] "Guerry" "heplots" "KnowBR" "MorphoTools2"
# [5] "MultivariateAnalysis" "smacof" "SurveyCC"

# revdep
#remotes::install_github("r-lib/revdepcheck")
#library(revdepcheck)
revdepcheck::revdep_check(num_workers = 4)


library(devtools)

# prepare pkgdown site
build_readme()
pkgdown::build_site()

devtools::build()
devtools::build_vignettes()

devtools::check_win_devel()
37 changes: 37 additions & 0 deletions R/Wilks.cancor.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
#' Wilks Lambda Tests for Canonical Correlations
#'
#' Tests the sequential hypotheses that the \eqn{i}th canonical correlation and
#' all that follow it are zero, \deqn{\rho_i = \rho_{i+1} = \cdots = 0}
#'
#' Wilks' Lambda values are calculated from the eigenvalues and converted to F
#' statistics using Rao's approximation.
#'
#' @aliases Wilks Wilks.cancor Wilks.candisc
#' @param object An object of class \code{"cancor""} or \code{"candisc""}
#' @param \dots Other arguments passed to methods (not used)
#' @return A data.frame (of class \code{"anova"}) containing the test
#' statistics
#' @author Michael Friendly
#' @seealso \code{\link{cancor}}, ~~~
#' @references Mardia, K. V., Kent, J. T. and Bibby, J. M. (1979).
#' \emph{Multivariate Analysis}. London: Academic Press.
#' @keywords htest
#' @examples
#'
#' data(Rohwer, package="heplots")
#' X <- as.matrix(Rohwer[,6:10]) # the PA tests
#' Y <- as.matrix(Rohwer[,3:5]) # the aptitude/ability variables
#'
#' cc <- cancor(X, Y, set.names=c("PA", "Ability"))
#' Wilks(cc)
#'
#' iris.mod <- lm(cbind(Petal.Length, Sepal.Length, Petal.Width, Sepal.Width) ~ Species, data=iris)
#' iris.can <- candisc(iris.mod, data=iris)
#' Wilks(iris.can)
#'
#'
#' @export Wilks
Wilks <- function (object, ...) {
UseMethod("Wilks")
}

#' @describeIn Wilks \code{"cancor"} method.
#' @export
Wilks.cancor <- function(object, ...) {
# tests of canonical dimensions

Expand Down Expand Up @@ -45,6 +80,8 @@ tests
# Rao's F approximation for canonical discriminant analysis
# using code from Martina Vandebroek <martina.vandebroek@kuleuven.be>

#' @describeIn Wilks \code{print()} method for \code{"candisc"} objects.
#' @export
Wilks.candisc <- function(object, ...) {

ev <- object$eigenvalues
Expand Down
23 changes: 20 additions & 3 deletions R/can_lm.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
#' Transform a Multivariate Linear model mlm to a Canonical Representation

#' @description
#'
#' This function uses \code{\link{candisc}} to transform the responses in a
#' multivariate linear model to scores on canonical variables for a given term and then uses
#' those scores as responses in a linear (lm) or multivariate linear model (mlm).

#'
#' The function constructs a model formula of the form \code{Can ~ terms} where
#' Can is the canonical score(s) and terms are the terms in the original mlm,
#' then runs lm() with that formula.
#'
#'
#' @param mod A \code{mlm} object
#' @param term One term in that model
#' @param ... Arguments passed to \code{\link{candisc}}
#' @param \dots Arguments passed to \code{\link{candisc}}
#' @return A \code{lm} object if \code{term} is a rank 1 hypothesis, otherwise a \code{mlm} object

#' @author Michael Friendly
#' @seealso \code{\link{candisc}}, \code{\link{cancor}}
#' @examples
#'
#' iris.mod <- lm(cbind(Petal.Length, Sepal.Length, Petal.Width, Sepal.Width) ~ Species, data=iris)
#' iris.can <- can_lm(iris.mod, "Species")
#' iris.can
#' car::Anova(iris.mod)
#' car::Anova(iris.can)
#'
#' @export can_lm
can_lm <- function(mod, term, ...) {
if (!(inherits(mod, "mlm"))) stop("model must be a mlm")
term.names <- gsub(" ", "", labels(terms(mod)))
Expand Down
Loading

0 comments on commit d95199e

Please sign in to comment.