Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
new examples and makeDF update
  • Loading branch information
mlcollyer committed May 14, 2019
1 parent ccde604 commit c25ce85
Show file tree
Hide file tree
Showing 16 changed files with 96 additions and 2,200 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
@@ -1,8 +1,8 @@
Package: RRPP
Date: 2019-04-02
Date: 2019-05-13
Type: Package
Title: Linear Model Evaluation with Randomized Residuals in a Permutation Procedure
Version: 0.4.1.9000
Version: 0.4.2
Author: Michael Collyer, Dean Adams
Maintainer: Michael Collyer <mlcollyer@gmail.com>
Description: Linear model calculations are made for many random versions of data.
Expand Down
26 changes: 11 additions & 15 deletions MD5
Expand Up @@ -3,22 +3,18 @@
87b2565a0e24012435c3090aa3b96c06 *data/PlethMorph.rda
4b4ee52bfcac42caf2b6b3c506af6db0 *data/Pupfish.rda
b7ceda4ee18eb3d0d3f966360dc02936 *data/PupfishHeads.rda
2293750f4c32081d67791a7e01b062df *DESCRIPTION
2fbc09d855306a4f99e53839eba87928 *DESCRIPTION
4b9ec9953a6af5354c47d2f9c8ff5922 *inst/CITATION
6efde0e97a07ac6d22261c2f0d3692de *inst/doc/ANOVA.vs.MANOVA.html
070e9a22fe4f8a290a46ac3598513879 *inst/doc/ANOVA.vs.MANOVA.Rmd
f6bdfae3b1f45e7526b6feeb03d17adc *inst/doc/Using.RRPP.html
6f61ac0efa7dab47ce7dd5f7b3401c82 *inst/doc/Using.RRPP.Rmd
00cb966631067dc597098ccceb3b84f8 *man/add.trajectories.Rd
c3b4760d53b0d12b9a6fbce6842554ea *man/anova.lm.rrpp.Rd
da78dcbc0abb4e22926a34272552cf1f *man/anova.lm.rrpp.Rd
eef4721fad3a88829eaef7937229dd7c *man/classify.Rd
54d52d7c0950f9c6a7bf4b351d1a49f8 *man/coef.lm.rrpp.Rd
017bd97e98d3dcd432a33e32945757df *man/fitted.lm.rrpp.Rd
cf9f206514b25b983a337af2fe7f485d *man/lm.rrpp.Rd
b9d72bff47416844da875dec83927679 *man/lm.rrpp.Rd
d0e291d2a7f237e0a69145dd8c61b44e *man/manova.update.Rd
b08077f2ad22b38d6e0ecf63660ed18c *man/model.comparison.Rd
c75db7099ad7a5d9bf80757369e495ea *man/motionpaths.Rd
7c5cb0100dad4de4b79b6c2cafa72e6a *man/pairwise.Rd
5505a0acd9e340f6a19fdb932f7979a6 *man/pairwise.Rd
4ba4f9fdbeffa3718c5c2bca0db78ad2 *man/PlethMorph.Rd
ba59abd91f8751ff1601107c997228cb *man/plot.lm.rrpp.Rd
f8ce4b58b48b33ae16ba5f0986d12781 *man/plot.model.comparison.Rd
Expand Down Expand Up @@ -52,23 +48,23 @@ beb55085de49d23665272a0db65d1dff *man/summary.lm.rrpp.Rd
a80a54cfe4673d90783a3ba49f9b4535 *man/summary.pairwise.Rd
73f2a913f66ac6af76747a7cd93c9070 *man/summary.predict.lm.rrpp.Rd
3d74de459d57a98acae66188a6150e7b *man/summary.trajectory.analysis.Rd
f22bbf5e151d912a8efcb00990a588fa *man/trajectory.analysis.Rd
4c4eb0ee5cbbb8fee5bc67d9fff4eb9c *man/trajectory.analysis.Rd
600001722c89e75928dbe4984812fdc5 *man/vec.cor.matrix.Rd
8dd28dfe65e0542561bc6096514f7d94 *NAMESPACE
afdab721f7f7c500a6225dd3459b679b *NEWS
262059f161b3a6bef292cdd97fc9c414 *R/anova.lm.rrpp.r
a693f637b4c684e4d7b4a26bb51c6587 *NEWS
1eeb1c1bf2a1e622543831c976dd0887 *R/anova.lm.rrpp.r
c2cda15833b34d15cbc97c9cd4530666 *R/classify.r
52536f21f7ea4cdcfa3ebfe15b4ffbac *R/coef.lm.rrpp.r
a022c6ffaaa6d4af5742bc1b3994d012 *R/lm.rrpp.r
56ee5f8f73f6fde2cd8ba3c00b76e0a2 *R/lm.rrpp.r
10b4f87d160a6c9a93012bea6ecddac3 *R/manova.update.r
d0c2e9bfde3601544d96c22161e1e4ae *R/model.comparison.r
fdda74b2c42e5ae7ddcb00ef0693da96 *R/pairwise.r
c6867066687afcd124b93086e60bd82b *R/pairwise.r
d0ba1ce3ec27cb68ab30db856e025784 *R/predict.lm.rrpp.r
be65a023ec04fe716867de7a1907b645 *R/reveal.model.designs.r
6ee08c8d67c4f81c9c813b7d49df7358 *R/RRPP.support.code.r
e46cbff761668fea655ea41ef3d111a9 *R/RRPP.support.code.r
b89fcf6916542d1b9659736f4699c83c *R/RRPP.utils.r
7b0567386b877e39cd8f6b38ef3babe5 *R/shared.support.code.r
cb7993a4baab56437c76a0b66786c1e5 *R/trajectory.analysis.r
5cd235e150ecb646edc3fc2e5903afb4 *R/trajectory.analysis.r
987d403df491c09b6db91776c4443a53 *README.md
7db72b7e01004751c5cf9d9eb2c9122c *RRPP.Rproj
070e9a22fe4f8a290a46ac3598513879 *vignettes/ANOVA.vs.MANOVA.Rmd
Expand Down
6 changes: 3 additions & 3 deletions NEWS
@@ -1,8 +1,8 @@
RRPP VERSION 0.4.1.9000 (Development)
RRPP VERSION 0.4.2 (Patch release)

BUG FIXES
o Tweaked supportcode for lm.rrpp to work better with missing data frames.
o Fixed eigen absolute eigen value issue with Cov.proj.
o Tweaked support code for lm.rrpp to work better with missing data frames.
o Fixed eigen absolute eigenvalue issue with Cov.proj.
o Added forgotten code from last update to fix non-full rank design matrices.
o Fixed trajectory.analysis traj.list issue, to not use grep for sorting trajectories. (Now lexical ordering of interactions is used.)
o Changed det to determinant in all needing functions, to use modulus for
Expand Down
26 changes: 16 additions & 10 deletions R/RRPP.support.code.r
Expand Up @@ -204,21 +204,27 @@ makeDf <- function(Terms, Y, data = NULL) {

} else {

ind.var.names <- rownames(attr(Terms, "factors"))[-1]
df <- vector("list", length = length(ind.var.names))
names(df) <- ind.var.names
for(i in 1:length(ind.var.names)) {
ind.facts<- rownames(attr(Terms, "factors"))[-1]
nterms <- length(ind.facts)
ind.var.names <- union(ind.facts, all.vars(Terms)[-1])
df <- vector("list", length = nterms)
i <- k <- 1
while(i <= length(ind.var.names)) {
f <- as.formula(paste("~", ind.var.names[i]))
temp <- if(is.null(data)) try(eval(f[[2]]), silent = TRUE) else
try(eval(f[[2]], as.environment(data), enclos = parent.frame()), silent = TRUE)
if(inherits(temp, "try-error")) temp <- try(eval(f[[2]]), silent = TRUE)
if(inherits(temp, "try-error"))
stop("Cannot find data in global environment.\n",
call. = FALSE) else
df[[i]] <- temp
if(!inherits(temp, "try-error")) {
df[[k]] <- temp
names(df)[[k]] <- ind.var.names[[i]]
k <- k +1
}
i <- i+1
}

if(is.null(names(df))) names(df) <- ind.var.names
check <- sapply(df, length)
if(any(check == 0))
stop("One or more terms was not found in the data frame or global environment.\n",
call. = FALSE)

df <- as.data.frame(df)

Expand Down
17 changes: 13 additions & 4 deletions R/anova.lm.rrpp.r
Expand Up @@ -30,16 +30,25 @@
#' Pupfish$logSize <- log(Pupfish$CS) # better to not have functions in formulas
#'
#'# Single-Model ANOVA
#' fit <- lm.rrpp(coords ~ logSize + Sex*Pop, SS.type = "I", data = Pupfish)
#'
#' # Note: one should increase RRPP iterations but a smaller number is used here for demonstration
#' # efficiency. Generally, iter = 999 will take less
#' # than 1s for this example with a modern computer.
#'
#' fit <- lm.rrpp(coords ~ logSize + Sex*Pop, SS.type = "I",
#' data = Pupfish, print.progress = FALSE, iter = 499)
#' anova(fit)
#' anova(fit, effect.type = "MS")
#' anova(fit, effect.type = "Rsq")
#' anova(fit, effect.type = "cohenf")
#'
#' # Multi-Model ANOVA (like a Likelihood Ratio Test)
#' fit.size <- lm.rrpp(coords ~ logSize, SS.type = "I", data = Pupfish)
#' fit.sex <- lm.rrpp(coords ~ logSize + Sex, SS.type = "I", data = Pupfish)
#' fit.pop <- lm.rrpp(coords ~ logSize + Pop, SS.type = "I", data = Pupfish)
#' fit.size <- lm.rrpp(coords ~ logSize, SS.type = "I", data = Pupfish,
#' print.progress = FALSE, iter = 499)
#' fit.sex <- lm.rrpp(coords ~ logSize + Sex, SS.type = "I", data = Pupfish,
#' print.progress = FALSE, iter = 499)
#' fit.pop <- lm.rrpp(coords ~ logSize + Pop, SS.type = "I", data = Pupfish,
#' print.progress = FALSE, iter = 499)
#' anova(fit.size, fit.sex, fit.pop) # compares two models to the first
#'
#' # see lm.rrpp examples for mixed model ANOVA example and how to vary SS type
Expand Down
10 changes: 8 additions & 2 deletions R/lm.rrpp.r
Expand Up @@ -132,8 +132,13 @@
#'
#' PupfishHeads$logHeadSize <- log(PupfishHeads$headSize)
#' names(PupfishHeads)
#'
#' # Note: one should increase RRPP iterations but a smaller number is used here for demonstration
#' # efficiency. Generally, iter = 999 will take less
#' # than 1s for this example with a modern computer.
#'
#' fit <- lm.rrpp(logHeadSize ~ sex + locality/year, SS.type = "I", data = PupfishHeads)
#' fit <- lm.rrpp(logHeadSize ~ sex + locality/year, SS.type = "I",
#' data = PupfishHeads, print.progress = FALSE, iter = 499)
#' summary(fit)
#' anova(fit, effect.type = "F") # Maybe not most appropriate
#' anova(fit, effect.type = "Rsq") # Change effect type, but still not most appropriate
Expand All @@ -144,7 +149,8 @@
#'
#' # Change to Type III SS
#'
#' fit <- lm.rrpp(logHeadSize ~ sex + locality/year, SS.type = "III", data = PupfishHeads)
#' fit <- lm.rrpp(logHeadSize ~ sex + locality/year, SS.type = "III",
#' data = PupfishHeads, print.progress = FALSE, iter = 499)
#' summary(fit)
#' anova(fit, effect.type = "F", error = c("Residuals", "locality:year", "Residuals"))
#'
Expand Down
11 changes: 8 additions & 3 deletions R/pairwise.r
Expand Up @@ -88,8 +88,12 @@
#'
#' ## Pairwise comparisons of LS means
#'
#' # Note: one should increase RRPP iterations but a smaller number is used here for demonstration
#' # efficiency. Generally, iter = 999 will take less
#' # than 1s for these examples with a modern computer.
#'
#' fit1 <- lm.rrpp(Y ~ logSize + Sex * Pop, SS.type = "I",
#' data = Pupfish, print.progress = FALSE, iter = 999)
#' data = Pupfish, print.progress = FALSE, iter = 499)
#' summary(fit1, formula = FALSE)
#' anova(fit1)
#'
Expand All @@ -109,13 +113,14 @@
#' ## Pairwise comparisons of slopes
#'
#' fit2 <- lm.rrpp(Y ~ logSize * Sex * Pop, SS.type = "I",
#' data = Pupfish, print.progress = FALSE, iter = 999)
#' data = Pupfish, print.progress = FALSE, iter = 199)
#' summary(fit2, formula = FALSE)
#' anova(fit1, fit2)
#'
#' # Using a null fit that excludes all factor-covariate interactions, not just the last one
#'
#' PW2 <- pairwise(fit2, fit.null = fit1, groups = pup.group, covariate = Pupfish$logSize)
#' PW2 <- pairwise(fit2, fit.null = fit1, groups = pup.group,
#' covariate = Pupfish$logSize, print.progress = FALSE)
#' PW2
#' summary(PW2, confidence = 0.95, test.type = "dist") # distances between slope vector lengths
#' summary(PW2, confidence = 0.95, test.type = "dist", stat.table = FALSE)
Expand Down
5 changes: 3 additions & 2 deletions R/trajectory.analysis.r
Expand Up @@ -67,9 +67,10 @@
#' @examples
#' ### Analysis of sexual dimorphism vectors (factorial approach)
#' data(Pupfish)
#' fit <- lm.rrpp(coords ~ Pop * Sex, data = Pupfish, iter = 999)
#' fit <- lm.rrpp(coords ~ Pop * Sex, data = Pupfish, iter = 499)
#' reveal.model.designs(fit)
#' TA <- trajectory.analysis(fit, groups = Pupfish$Pop, traj.pts = Pupfish$Sex)
#' TA <- trajectory.analysis(fit, groups = Pupfish$Pop,
#' traj.pts = Pupfish$Sex, print.progress = FALSE)
#' summary(TA, attribute = "MD") # Magnitude difference (absolute difference between path distances)
#' summary(TA, attribute = "TC", angle.type = "deg") # Correlations (angles) between trajectories
#' summary(TA, attribute = "SD") # No shape differences between vectors
Expand Down
121 changes: 0 additions & 121 deletions inst/doc/ANOVA.vs.MANOVA.Rmd

This file was deleted.

0 comments on commit c25ce85

Please sign in to comment.