Skip to content

Commit

Permalink
error in dynlib
Browse files Browse the repository at this point in the history
  • Loading branch information
jomulder committed Sep 23, 2023
1 parent 143434f commit 94c525d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 74 deletions.
6 changes: 1 addition & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
S3method(BF,bartlett_htest)
S3method(BF,bergm)
S3method(BF,coeftest)
S3method(BF,cor_test)
S3method(BF,coxph)
S3method(BF,default)
S3method(BF,ergm)
S3method(BF,glm)
S3method(BF,hetcor)
S3method(BF,htest)
S3method(BF,lm)
S3method(BF,lmerMod)
Expand All @@ -31,11 +29,9 @@ S3method(get_estimates,survreg)
S3method(get_estimates,t_test)
S3method(get_estimates,zeroinfl)
S3method(print,BF)
S3method(print,cor_test)
S3method(summary,BF)
export(BF)
export(bartlett_test)
export(cor_test)
import(bain)
importFrom(MASS,ginv)
importFrom(Matrix,rankMatrix)
Expand All @@ -49,6 +45,7 @@ importFrom(mvtnorm,pmvnorm)
importFrom(mvtnorm,pmvt)
importFrom(mvtnorm,rmvnorm)
importFrom(mvtnorm,rmvt)
importFrom(pracma,Rank)
importFrom(pracma,rref)
importFrom(sandwich,sandwich)
importFrom(stats,approxfun)
Expand Down Expand Up @@ -80,7 +77,6 @@ importFrom(stats,rt)
importFrom(stats,runif)
importFrom(stats,sd)
importFrom(stats,setNames)
importFrom(stats,terms)
importFrom(stats,var)
importFrom(stats,vcov)
importFrom(utils,getFromNamespace)
Expand Down
5 changes: 2 additions & 3 deletions R/BF.gaussian.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ Savage.Dickey.Gaussian <- function(prior.mean,

# compute relative meausures (fit or complexity) under a multivariate Gaussian distribution
#' @importFrom mvtnorm dmvnorm pmvnorm
#' @importFrom Matrix rankMatrix
Gaussian_measures <- function(mean1,Sigma1,n1=0,RrE1,RrO1,names1=NULL,constraints1=NULL){
K <- length(mean1)
relE <- relO <- 1
Expand All @@ -234,7 +233,7 @@ Gaussian_measures <- function(mean1,Sigma1,n1=0,RrE1,RrO1,names1=NULL,constraint
qO1 <- nrow(RO1)
rO1 <- RrO1[,(K+1)]

if(rankMatrix(RO1)[[1]]==nrow(RO1)){ #RO1 is of full row rank. So use transformation.
if(Rank(RO1)==nrow(RO1)){ #RO1 is of full row rank. So use transformation.
meanO <- c(RO1%*%mean1)
SigmaO <- RO1%*%Sigma1%*%t(RO1)
check_vcov(SigmaO)
Expand Down Expand Up @@ -270,7 +269,7 @@ Gaussian_measures <- function(mean1,Sigma1,n1=0,RrE1,RrO1,names1=NULL,constraint
rO1 <- RrO1[,(K+1)]
Rr1 <- rbind(RrE1,RrO1)

if(rankMatrix(Rr1)[[1]] == nrow(Rr1)){
if(Rank(Rr1) == nrow(Rr1)){

R1 <- rbind(RE1,RO1)

Expand Down
11 changes: 5 additions & 6 deletions R/BF.lm.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#' @importFrom pracma rref
#' @importFrom pracma rref Rank
#' @importFrom mvtnorm dmvnorm pmvnorm rmvnorm dmvt pmvt rmvt
#' @importFrom Matrix rankMatrix
#' @importFrom stats rWishart qt
#' @importFrom MASS ginv
#' @describeIn BF S3 method for an object of class 'lm'
Expand Down Expand Up @@ -631,7 +630,7 @@ MatrixStudent_measures <- function(Mean1,Scale1,tXXi1,df1,RrE1,RrO1,Names1=NULL,
qO1 <- nrow(RO1)
rO1 <- RrO1[,(K*P+1)]

if(rankMatrix(RO1)[[1]]==nrow(RO1)){ #RO1 is of full row rank. So use transformation.
if(Rank(RO1)==nrow(RO1)){ #RO1 is of full row rank. So use transformation.

Scale1inv <- solve(Scale1)
relO <- unlist(lapply(1:1e3,function(s){
Expand Down Expand Up @@ -690,7 +689,7 @@ MatrixStudent_measures <- function(Mean1,Scale1,tXXi1,df1,RrE1,RrO1,Names1=NULL,
mean1_E <- RE1 %*% mean1
relE <- mean(unlist(lapply(covm1_E,function(temp) dmvnorm(rE1,mean=mean1_E,sigma=temp))))

if(rankMatrix(Rr1)[[1]] == nrow(Rr1)){
if(Rank(Rr1) == nrow(Rr1)){
covm1_O <- lapply(SigmaList,function(temp) R1%*%(kronecker(temp,tXXi1))%*%t(R1) )
mean1_O <- c(R1%*%mean1)

Expand Down Expand Up @@ -755,7 +754,7 @@ Student_measures <- function(mean1,Scale1,df1,RrE1,RrO1,names1=NULL,constraints1
qO1 <- nrow(RO1)
rO1 <- RrO1[,(K+1)]

if(rankMatrix(RO1)[[1]]==nrow(RO1)){ #RO1 is of full row rank. So use transformation.
if(Rank(RO1)==nrow(RO1)){ #RO1 is of full row rank. So use transformation.
meanO <- c(RO1%*%mean1)
scaleO <- RO1%*%Scale1%*%t(RO1)
relO <- ifelse(nrow(scaleO)==1,
Expand Down Expand Up @@ -837,7 +836,7 @@ Student_measures <- function(mean1,Scale1,df1,RrE1,RrO1,names1=NULL,constraints1
Tscale1OgE <- as.vector((df1 + (t(matrix(rE1 - Tmean1E)) %*% solve(Tscale1EE) %*% matrix(rE1 - Tmean1E))) /
(df1 + qE1)) * (Tscale1OO - Tscale1OE %*% solve(Tscale1EE) %*% t(Tscale1OE))

if(rankMatrix(RO1tilde)[[1]] == nrow(RO1tilde)){
if(Rank(RO1tilde) == nrow(RO1tilde)){
rO1tilde <- as.vector(rO1tilde)

delta_trans <- as.vector(RO1tilde %*% Tmean1OgE)
Expand Down
1 change: 1 addition & 0 deletions R/BF_cortest.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@


#' @title Bayesian correlation analysis
#'
#' @name cor_test
Expand Down
9 changes: 4 additions & 5 deletions R/BFhetcor.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#' @method BF hetcor
#' @export
BF.hetcor <- function(x,
hypothesis = NULL,
prior.hyp = NULL,
...){
hypothesis = NULL,
prior.hyp = NULL,
...){
get_est <- get_estimates(x)
P <- nrow(x$std.errors)
numcorr <- P*(P-1)/2
Expand Down Expand Up @@ -40,7 +40,7 @@ BF.hetcor <- function(x,
relcomp <- t(matrix(unlist(
lapply(1:numhyp, function(h){
jointuniform_measures(P,numcorr, 1, RrE[[h]], RrO[[h]], Fisher=0)
})
})
),nrow=2))
relfit <- t(matrix(unlist(lapply(1:numhyp,function(h){
Gaussian_measures(estimates,errcov,RrE1=RrE[[h]],RrO1=RrO[[h]],names1=names(estimates),
Expand Down Expand Up @@ -105,4 +105,3 @@ BF.hetcor <- function(x,
return(BF_out)

}

16 changes: 8 additions & 8 deletions R/cor_test.print.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#' @method print cor_test
#' @export
print.cor_test <- function(x,
digits = 3,
na.print = "", ...){
digits = 3,
na.print = "", ...){

estimates <- x$correstimates
names <- x$corrnames
Expand All @@ -11,13 +11,13 @@ print.cor_test <- function(x,
numcorr <- P*(P-1)/2
countg = 0
corrlist <- lapply(1:groups,function(g){
lapply(1:3,function(b){
matje <- matrix(NA,P,P)
row.names(matje) <- colnames(matje) <- x$variables[[1]]
matje[lower.tri(diag(P))] <- estimates[numcorr*(g-1)+1:numcorr,1+b]
matje
})
lapply(1:3,function(b){
matje <- matrix(NA,P,P)
row.names(matje) <- colnames(matje) <- x$variables[[1]]
matje[lower.tri(diag(P))] <- estimates[numcorr*(g-1)+1:numcorr,1+b]
matje
})
})

cat("\n")
cat("Unconstrained Bayesian estimates","\n", sep = "")
Expand Down
47 changes: 0 additions & 47 deletions man/cor_test.Rd

This file was deleted.

0 comments on commit 94c525d

Please sign in to comment.