Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V1.0.2 #7

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .github/depends.Rds
Binary file not shown.
9 changes: 0 additions & 9 deletions .github/workflows/R-CMD-Check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ jobs:
fail-fast: false
matrix:
config:
<<<<<<< HEAD
=======
- {os: macOS-latest, r: 'devel'}
>>>>>>> 0b2980cdabe5a79011e3b114b64229a3923ad087
- {os: macOS-latest, r: '4.0'}
- {os: macOS-latest, r: '3.6'}
- {os: macOS-latest, r: '3.5'}
Expand Down Expand Up @@ -92,14 +89,11 @@ jobs:
- name: Check
env:
_R_CHECK_CRAN_INCOMING_: false
<<<<<<< HEAD
_R_CHECK_DONTTEST_EXAMPLES_: false
DISPLAY: 99.0
run: |
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
=======
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
>>>>>>> 0b2980cdabe5a79011e3b114b64229a3923ad087
shell: Rscript {0}

- name: Show testthat output
Expand All @@ -112,8 +106,5 @@ jobs:
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
<<<<<<< HEAD
path: check
=======
path: check
>>>>>>> 0b2980cdabe5a79011e3b114b64229a3923ad087
9 changes: 0 additions & 9 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ jobs:
fail-fast: false
matrix:
config:
<<<<<<< HEAD
=======
- {os: macOS-latest, r: 'devel'}
>>>>>>> 0b2980cdabe5a79011e3b114b64229a3923ad087
- {os: macOS-latest, r: '4.0'}
- {os: macOS-latest, r: '3.6'}
- {os: macOS-latest, r: '3.5'}
Expand Down Expand Up @@ -92,14 +89,11 @@ jobs:
- name: Check
env:
_R_CHECK_CRAN_INCOMING_: false
<<<<<<< HEAD
_R_CHECK_DONTTEST_EXAMPLES_: false
DISPLAY: 99.0
run: |
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
=======
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
>>>>>>> 0b2980cdabe5a79011e3b114b64229a3923ad087
shell: Rscript {0}

- name: Show testthat output
Expand All @@ -112,8 +106,5 @@ jobs:
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
<<<<<<< HEAD
path: check
=======
path: check
>>>>>>> 0b2980cdabe5a79011e3b114b64229a3923ad087
22 changes: 0 additions & 22 deletions CITATION.cff

This file was deleted.

42 changes: 19 additions & 23 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Package: asmcjr
Type: Package
Title: 2nd Edition Analyzing Spatial Models of Choice and Judgment
Version: 1.0.1
Authors@R: c(person("Dave", "Armstrong", role=c("aut", "cre"), email="[email protected]"),
person("Royce", "Carroll", role="aut"),
person("Chris", "Hare", role="aut"),
person("Ryan", "Bakker", role="aut"),
Version: 1.0.2
Authors@R: c(person("Dave", "Armstrong", role = c("aut", "cre"), email = "[email protected]"),
person("Royce", "Carroll", role = "aut"),
person("Chris", "Hare", role = "aut"),
person("Ryan", "Bakker", role = "aut"),
person("Keith", "Poole", role="ctb"),
person("Howard", "Rosenthal", role="ctb"),
person("David", "Liao", role="ctb"))
person("David", "Liao", role=c("ctb", "aut")))
Description: Supports the book - 2nd Edition Analyzing Spatial Models of Choice and Judgment, CRC Press (2020).
Depends: R(>= 3.5.0), rjags
Depends: R (>= 3.4.0), rjags
Imports:
boot,
basicspace,
Expand All @@ -25,22 +25,18 @@ Imports:
stats,
smacof,
tibble,
utils,
lifecycle

Description: Supports the book - Analyzing Spatial Models of Choice and Judgment in R, CRC Press (2014).
Depends: R(>= 3.5.0)
Imports: ggplot2, basicspace, boot, MASS, stats, grDevices, MCMCpack, plyr, smacof, tibble, ellipse, utils, coda, graphics
Suggests: rjags, covr
License: GPL (>=2)
utils
Suggests:
knitr,
rmarkdown,
testthat (>= 3.0.0)
License: GPL (>=3)
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.0
Suggests:
covr,
knitr,
rmarkdown
RoxygenNote: 7.2.3
VignetteBuilder: knitr
URL: https://github.com/davidaarmstrong/asmcjr
BugReports: https://github.com/davidaarmstrong/asmcjr/issues
RdMacros: lifecycle
URL: https://github.com/uniofessex/asmcjr
BugReports: https://github.com/uniofessex/asmcjr/issues
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
SystemRequirements: pandoc (>= 1.14) - http://pandoc.org
29 changes: 1 addition & 28 deletions NAMESPACE
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,29 +1,2 @@
useDynLib(asmcjr, .registration=TRUE)
exportPattern("^[[:alpha:]]+")
import(ggplot2)
import(boot)
import(basicspace)
import(rjags)
importFrom("MCMCpack", "procrustes")
importFrom("plyr", "aaply")
importFrom("tibble", "as_tibble", "add_column")
importFrom("grDevices", "rgb")
importFrom("graphics", "lines", "symbols")
importFrom("stats", "density", "na.omit", "quantile", "rnorm",
"sd", "runif", "end", "qnorm", "start", "window", "time")
importFrom("utils", "combn", "globalVariables")
importFrom("MASS", "polr")
importFrom("smacof", "smacofRect")
importFrom("ellipse", "ellipse")
importFrom("coda", "as.mcmc.list", "geweke.diag", "nchain", "nvar",
"varnames", "chanames", "niter", "mcpar", "mcmc")
# Generated by roxygen2: do not edit by hand


S3method(plot, aldmck_ci)
S3method(plot, mlsmu6)
S3method(plot, bayesunfold)
S3method(print, aldmck_ci)
S3method(start, mcmc.list)
S3method(end, mcmc.list)
S3method(window, mcmc.list)
S3method(window, mcmc)
38 changes: 19 additions & 19 deletions R/asmcjr.r
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ plot.mlsmu6 <- function(x, ..., selected.stims=NULL, ind.id.size=3, stim.id.size


bayesunfold <-
function(input, dims = 2, nsamp = 2000, burnin = 1000, cred.level = 0.9, slice.starts = c("lbfgs", "random"), print.lbfgs="console", print.slice="console", ...)
function(input, dims = 2, nsamp = 2000, burnin = 1000, cred.level = 0.9, slice.starts = c("lbfgs", "random"), print.lbfgs="console", print.slice="console", ...)
{
#
if(cred.level > 1 | cred.level < 0){stop("cred.level must be between 0 and 1\n")}
Expand Down Expand Up @@ -864,7 +864,7 @@ sigma_squared_hat_sd <- sd(result4[[4]][(burnin+1):(burnin+nsamp)])
# SAMPLES
#
samples <- matrix(result4[[3]], ncol=NDIM, byrow=TRUE)
## took out because wasn't needed.
## took out because wasn't needed.
#samples <- cbind(samples, 0)
#z.mean <- colMeans(samples[,1:(ncolX*NS)])
#z.mat <- matrix(z.mean, byrow=TRUE, ncol=NS)
Expand All @@ -880,7 +880,7 @@ stim.mean <- aaply(stim.array, c(1,2), mean, na.rm=TRUE)
stim.lower <- aaply(stim.array, c(1,2), quantile, ll, na.rm=TRUE)
stim.upper <- aaply(stim.array, c(1,2), quantile, ul, na.rm=TRUE)

## arrays the data as first column in columns 1:ncolX and
## arrays the data as first column in columns 1:ncolX and
## second column of stimuli in (ncolX+1):(ncolX*NS)
stim.samples <- matrix(c(stim.array), ncol=ncolX*NS, byrow=TRUE)
stim.samples <- stim.samples[-nrow(stim.samples), ]
Expand All @@ -894,13 +894,13 @@ for(j in 1:(nsamp-1)){
individuals[[j]] <- matrix(c(samples[j,-(1:(ncolX*NS))], 0), ncol=NS, byrow=TRUE)
# individuals[[j]] <- rbind(individuals[[j]], c(0,0))
}
indiv.array <- array(as.numeric(unlist(individuals)),
indiv.array <- array(as.numeric(unlist(individuals)),
dim=c(nrowX, NS, (nsamp-1)))
indiv.mean <- aaply(indiv.array, c(1,2), mean, na.rm=TRUE)
indiv.lower <- aaply(indiv.array, c(1,2), quantile, ll, na.rm=TRUE)
indiv.upper <- aaply(indiv.array, c(1,2), quantile, ul, na.rm=TRUE)

## arrays the data as first column in columns 1:nrowX and
## arrays the data as first column in columns 1:nrowX and
## second column of stimuli in (nrowX+1):(nrowX*NS)

indiv.samples <- matrix(c(indiv.array), ncol=nrowX*NS, byrow=TRUE)
Expand All @@ -921,7 +921,7 @@ orig.res = list(stim.samples = stim.samples,
stimuli = list(mean = stim.mean, lower=stim.lower, upper=stim.upper),
individuals = list(mean = indiv.mean, lower=indiv.lower, upper=indiv.upper))

### Results With Procrustes Roatation
### Results With Procrustes Roatation
stim.rot <- matrix(NA, nrow=(nsamp-1), ncol=ncolX*2)
indiv.rot <- matrix(NA, nrow=(nsamp-1), ncol=length(c(individuals[[1]])))
for(i in 1:(nsamp-1)){
Expand All @@ -930,14 +930,14 @@ for(i in 1:(nsamp-1)){
indiv.rot[i,] <- c(with(p, s * individuals[[i]] %*% R + matrix(tt, nrow(individuals[[i]]), ncol(individuals[[i]]), byrow = TRUE)))
}
stim.mean <- matrix(colMeans(stim.rot, na.rm=TRUE), ncol=dims)
stim.lower <- matrix(apply(stim.rot, 2, quantile,
stim.lower <- matrix(apply(stim.rot, 2, quantile,
ll, na.rm=TRUE), ncol=dims)
stim.upper <- matrix(apply(stim.rot, 2, quantile,
stim.upper <- matrix(apply(stim.rot, 2, quantile,
ul, na.rm=TRUE), ncol=dims)
indiv.mean <- matrix(colMeans(indiv.rot), ncol=dims)
indiv.lower <- matrix(apply(indiv.rot, 2, quantile,
indiv.lower <- matrix(apply(indiv.rot, 2, quantile,
ll, na.rm=TRUE), ncol=dims)
indiv.upper <- matrix(apply(indiv.rot, 2, quantile,
indiv.upper <- matrix(apply(indiv.rot, 2, quantile,
ul, na.rm=TRUE), ncol=dims)

if(!is.null(colnames(input))){
Expand All @@ -959,12 +959,12 @@ rotated.res = list(stim.samples = stim.samples,



BUobject <- list(retained.obs = keep, smacof.result = SMACOF.result,
BUobject <- list(retained.obs = keep, smacof.result = SMACOF.result,
lbfgs.result = list(stimuli=lbfgs.stimuli, individuals=lbfgs.individuals),
samples = samples, result4 = result4,
samples = samples, result4 = result4,
sigma_squared_hat = sigma_squared_hat,
sigma_squared_hat_sd = sigma_squared_hat_sd,
unrotated = orig.res,
sigma_squared_hat_sd = sigma_squared_hat_sd,
unrotated = orig.res,
rotated = rotated.res)

class(BUobject) <- "bayesunfold"
Expand All @@ -984,13 +984,13 @@ plot.bayesunfold <- function(x, ..., which.res =c("rotated", "unrotated"), label
stims <- res$stimuli$mean
rownames(stims) <- rownames(x$smacof.result$conf.col)
indivs <- res$individuals$mean
stim.data <- as_tibble(stims, rownames="names")
stim.data <- as_tibble(stims, rownames="names")
names(stim.data)[2:3] <- c("D1", "D2")
indiv.data <- as_tibble(res$individuals$mean, rownames=NULL)
names(indiv.data)[1:2] <- c("D1", "D2")
stim.data <- add_column(stim.data, D1.lower=res$stimuli$lower[,1], D2.lower=res$stimuli$lower[,2],
stim.data <- add_column(stim.data, D1.lower=res$stimuli$lower[,1], D2.lower=res$stimuli$lower[,2],
D1.upper = res$stimuli$upper[,1], D2.upper = res$stimuli$upper[,2])
indiv.data <- add_column(indiv.data, D1.lower=res$individuals$lower[,1], D2.lower=res$individuals$lower[,2],
indiv.data <- add_column(indiv.data, D1.lower=res$individuals$lower[,1], D2.lower=res$individuals$lower[,2],
D1.upper = res$individuals$upper[,1], D2.upper = res$individuals$upper[,2])
if(!is.null(individual.id)){
indiv.data <- add_column(indiv.data, names=individual.id)
Expand All @@ -1007,15 +1007,15 @@ plot.bayesunfold <- function(x, ..., which.res =c("rotated", "unrotated"), label
if(plot.stimuli & plot.individuals){
if(is.null(individual.id)){
if(lab == "text"){
g <- ggplot(stim.data, aes_string(x="D1", y="D2")) + geom_point(data=indiv.data, col="gray75", pch=1, cex=.5 ) + geom_text(aes(label=names, colour=names))
g <- ggplot(stim.data, aes_string(x="D1", y="D2")) + geom_point(data=indiv.data, col="gray75", pch=1, cex=.5 ) + geom_text(aes(label=names, colour=names))
}
if(lab == "color"){
g <- ggplot(stim.data, aes_string(x="D1", y="D2")) + geom_point(data=indiv.data, col="gray75", pch=1, cex=.5 ) + geom_point(aes(colour=names))
}
}
else{
if(lab == "text"){
g <- ggplot(stim.data, aes_string(x="D1", y="D2")) + geom_point(data=indiv.data, pch=1, cex=.5 ) + geom_text(aes(label=names, colour=names))
g <- ggplot(stim.data, aes_string(x="D1", y="D2")) + geom_point(data=indiv.data, pch=1, cex=.5 ) + geom_text(aes(label=names, colour=names))
}
if(lab == "color"){
g <- ggplot(stim.data, aes_string(x="D1", y="D2")) + geom_point(data=indiv.data, pch=1, cex=.5 ) + geom_point(aes(colour=names))
Expand Down
Loading
Loading