Skip to content

Commit

Permalink
version 1.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrommolt authored and gaborcsardi committed Dec 21, 2010
1 parent fc9f41a commit 65e7ee3
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 75 deletions.
10 changes: 5 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Package: bifactorial
Version: 1.4.5
Date: 2010-11-22
Version: 1.4.6
Date: 2010-12-21
Author: Peter Frommolt
Maintainer: Peter Frommolt <peter.frommolt@uni-koeln.de>
Title: Inferences for bi- and trifactorial trial designs
Depends: mvtnorm,multcomp,lattice,graphics,methods,Rcpp (>= 0.7.4)
Depends: mvtnorm,multcomp,lattice,graphics,methods,Rcpp (>= 0.8.8)
LinkingTo: Rcpp
Description: This package makes global and multiple inferences for
given bi- and trifactorial clinical trial designs using
bootstrap methods and a classical approach.
URL: http://portal.ccg.uni-koeln.de
License: GPL
Packaged: 2010-11-22 08:20:52 UTC; frommolt
Packaged: 2010-12-21 12:18:00 UTC; frommolt
Repository: CRAN
Date/Publication: 2010-11-22 10:40:41
Date/Publication: 2010-12-21 17:03:09
2 changes: 1 addition & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PKG_CPPFLAGS = -I. `${R_HOME}/bin/Rscript -e "Rcpp:::CxxFlags()"`
PKG_CPPFLAGS = -I.
PKG_LIBS = `${R_HOME}/bin/Rscript -e "Rcpp:::LdFlags()"`
4 changes: 2 additions & 2 deletions src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PKG_LIBS = `$(R_HOME)/bin$(R_ARCH_BIN)/Rscript -e 'Rcpp:::LdFlags()'`
PKG_CXXFLAGS = `$(R_HOME)/bin$(R_ARCH_BIN)/Rscript -e 'Rcpp:::CxxFlags()'` -I.
PKG_LIBS = $(shell "${R_HOME}/bin${R_ARCH_BIN}/Rscript.exe" -e "Rcpp:::LdFlags()")
PKG_CXXFLAGS = -I.
53 changes: 37 additions & 16 deletions src/ave.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#include <iostream>
#include <math.h>
#include <time.h>
#include "Rcpp.h"
#include "misc.h"
#include <Rcpp.h>
#include <misc.h>
#include <vector>

using namespace Rcpp ;

//Implementations of bootstrap algorithms for the AVE-test (Hung, 2000)
//AVE-test based on Student's t-test in bifactorial designs
RcppExport SEXP avestudent2(SEXP Yr,SEXP nr,SEXP sonstNr,SEXP sonstRr){
RcppResultSet rs; RcppVector<int> sonstN(sonstNr); RcppMatrix<int> n(nr);
int a,b,i,j,k=1,l,m,nsim=sonstN(0),A=sonstN(1),B=sonstN(2),count=0;
IntegerVector sonstN(sonstNr);
NumericMatrix n(nr);
int a,b,i,j,k=1,m,nsim=sonstN(0),A=sonstN(1),B=sonstN(2),count=0;
int ** anfang; double ** mx; double ** vx; double ** oldmean; double ** delta;
anfang=new int *[A+1]; for(i=0;i<A+1;++i){anfang[i]=new int[B+1];}
RcppVector<double> sonstR(sonstRr),Y(Yr); vector<double> X(0),Z(0),tminst(A*B);
NumericVector sonstR(sonstRr),Y(Yr); vector<double> X(0),Z(0),tminst(A*B);
double taveSc=sonstR(0),simerror=sonstR(1);
mx=new double *[A+1]; for(i=0;i<A+1;++i){mx[i]=new double[B+1];}
vx=new double *[A+1]; for(i=0;i<A+1;++i){vx[i]=new double[B+1];}
Expand Down Expand Up @@ -47,12 +51,16 @@ RcppExport SEXP avestudent2(SEXP Yr,SEXP nr,SEXP sonstNr,SEXP sonstRr){
}}
++k;
}
rs.add("count",count); rs.add("nsim",nsim); return rs.getReturnList();
return List::create(
_["count"] = count,
_["nsim"] = nsim
) ;
}

//AVE-test based on Student's t-test in trifactorial designs
RcppExport SEXP avestudent3(SEXP Yr,SEXP nr,SEXP sonstNr,SEXP sonstRr){
RcppResultSet rs; RcppVector<int> sonstN(sonstNr), n(nr); RcppVector<double> sonstR(sonstRr),Y(Yr);
int a,b,c,i,j,k=1,l,m,nsim=sonstN(0),A=sonstN(1),B=sonstN(2),C=sonstN(3);
IntegerVector sonstN(sonstNr), n(nr); NumericVector sonstR(sonstRr),Y(Yr);
int a,b,c,i,j,k=1,m,nsim=sonstN(0),A=sonstN(1),B=sonstN(2),C=sonstN(3);
int *** anfang; anfang=new int **[A+1];
for(i=0;i<A+1;++i){anfang[i]=new int *[B+1]; for(j=0;j<B+1;++j){anfang[i][j]=new int[C+1];}}
double taveSc=sonstR(0),simerror=sonstR(1); int count=0;
Expand Down Expand Up @@ -100,13 +108,19 @@ RcppExport SEXP avestudent3(SEXP Yr,SEXP nr,SEXP sonstNr,SEXP sonstRr){
}}
++k;
}
rs.add("count",count); rs.add("nsim",nsim); return rs.getReturnList();
return List::create(
_["count"] = count,
_["nsim"] = nsim
);
}

//AVE-test based on a Z statistic in bifactorial designs
RcppExport SEXP avebinomial2(SEXP nr,SEXP pr,SEXP sonstNr,SEXP sonstRr){
RcppResultSet rs; RcppVector<int> sonstN(sonstNr); RcppMatrix<int> n(nr);
RcppVector<double> sonstR(sonstRr); RcppMatrix<double> p(pr);
int a,b,i,j,k=1,l,m,nsim=sonstN(0),A=sonstN(1),B=sonstN(2);
IntegerVector sonstN(sonstNr);
IntegerMatrix n(nr);
NumericVector sonstR(sonstRr);
NumericMatrix p(pr);
int a,b,k=1,nsim=sonstN(0),A=sonstN(1),B=sonstN(2);
double zave=sonstR(0),simerror=sonstR(1),count=0,p1,p2;
vector<double> zminst(A*B); vector<int> Z1(0),Z2(0);
while(k<=nsim){
Expand All @@ -130,12 +144,17 @@ RcppExport SEXP avebinomial2(SEXP nr,SEXP pr,SEXP sonstNr,SEXP sonstRr){
}}
++k;
}
rs.add("count",count); rs.add("nsim",nsim); return rs.getReturnList();
return List::create(
_["count"] = count,
_["nsim"] = nsim
);
}

//AVE-test based on a Z statistic in trifactorial designs
RcppExport SEXP avebinomial3(SEXP nr,SEXP pr,SEXP sonstNr,SEXP sonstRr){
RcppResultSet rs; RcppVector<int> sonstN(sonstNr), n(nr); RcppVector<double> sonstR(sonstRr), p(pr);
int a,b,c,i,j,k=1,l,m,nsim=sonstN(0),A=sonstN(1),B=sonstN(2),C=sonstN(3);
IntegerVector sonstN(sonstNr), n(nr);
NumericVector sonstR(sonstRr), p(pr);
int a,b,c,k=1,nsim=sonstN(0),A=sonstN(1),B=sonstN(2),C=sonstN(3);
double zave=sonstR(0),simerror=sonstR(1),count=0,p1,p2,pi;
vector<double> zminst(A*B*C); vector<int> Z1(0),Z2(0);
while(k<=nsim){
Expand Down Expand Up @@ -166,5 +185,7 @@ RcppExport SEXP avebinomial3(SEXP nr,SEXP pr,SEXP sonstNr,SEXP sonstRr){
}}
++k;
}
rs.add("count",count); rs.add("nsim",nsim); return rs.getReturnList();
return List::create(
_["count"] = count,
_["nsim"] = nsim ) ;
}
61 changes: 42 additions & 19 deletions src/krit.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#include <iostream>
#include <math.h>
#include <time.h>
#include "Rcpp.h"
#include "misc.h"
#include <vector>
#include <Rcpp.h>
#include <misc.h>

using namespace Rcpp ;

//Implementations of bootstrap algorithms for simultaneous confidence intervals
//Confidence intervals based on Student's t-test in bifactorial designs
RcppExport SEXP kritstudent2(SEXP Yr,SEXP nr,SEXP parNr){
int a,b,i,k=0,m; SEXP rl=0; RcppResultSet rs; RcppVector<int> parN(parNr),n(nr);
int a,b,i,k=0,m;
IntegerVector parN(parNr),n(nr);
int nsim=parN(0),A=parN(1),B=parN(2);
int ** anfang; anfang=new int *[A+1];
for(i=0;i<A+1;++i){anfang[i]=new int[B+1];}
RcppVector<double> Y(Yr),maxi(nsim),mini(nsim);
NumericVector Y(Yr),maxi(nsim),mini(nsim);
vector<double> X(0),Z(0),tst(A*B);
double ** mx; mx=new double *[A+1]; for(i=0;i<A+1;++i){mx[i]=new double[B+1];}
double ** vx; vx=new double *[A+1]; for(i=0;i<A+1;++i){vx[i]=new double[B+1];}
Expand All @@ -30,17 +33,23 @@ RcppExport SEXP kritstudent2(SEXP Yr,SEXP nr,SEXP parNr){
tst.push_back((mx[a][b]-mx[a][0])/sqrt((vx[a][b]/n(c2(a,b,B)))+(vx[a][0]/n(c2(a,0,B)))));
tst.push_back((mx[a][b]-mx[0][b])/sqrt((vx[a][b]/n(c2(a,b,B)))+(vx[0][b]/n(c2(0,b,B)))));
}}
mini(k)=minimalwert(tst); maxi(k)=maximalwert(tst); ++k;
mini[k]=minimalwert(tst);
maxi[k]=maximalwert(tst); ++k;
}
rs.add("mini",mini); rs.add("maxi",maxi); return rs.getReturnList();
return List::create(
_["mini"] = mini,
_["maxi"] = maxi
) ;
}

//Confidence intervals based on Student's t-test in trifactorial designs
RcppExport SEXP kritstudent3(SEXP Yr,SEXP nr,SEXP parNr){
int a,b,c,i,j,k=0,m; SEXP rl=0; RcppResultSet rs; RcppVector<int> parN(parNr),n(nr);
int a,b,c,i,j,k=0,m;
IntegerVector parN(parNr),n(nr);
int nsim=parN(0),A=parN(1),B=parN(2),C=parN(3);
int *** anfang; anfang=new int **[A+1];
for(i=0;i<A+1;++i){anfang[i]=new int *[B+1]; for(j=0;j<B+1;++j){anfang[i][j]=new int[C+1];}}
RcppVector<double> Y(Yr),maxi(nsim),mini(nsim);
NumericVector Y(Yr),maxi(nsim),mini(nsim);
vector<double> X(0),Z(0),tst(A*B);
double *** mx; mx=new double **[A+1];
for(i=0;i<A+1;++i){mx[i]=new double *[B+1]; for(j=0;j<B+1;++j){mx[i][j]=new double[C+1];}}
Expand All @@ -62,15 +71,20 @@ RcppExport SEXP kritstudent3(SEXP Yr,SEXP nr,SEXP parNr){
tst.push_back((mx[a][b][c]-mx[a][0][c])/sqrt((vx[a][b][c]/n(c3(a,b,c,B,C)))+(vx[a][0][c]/n(c3(a,0,c,B,C)))));
tst.push_back((mx[a][b][c]-mx[0][b][c])/sqrt((vx[a][b][c]/n(c3(a,b,c,B,C)))+(vx[0][b][c]/n(c3(0,b,c,B,C)))));
}}}
mini(k)=minimalwert(tst); maxi(k)=maximalwert(tst); ++k;
mini[k]=minimalwert(tst);
maxi[k]=maximalwert(tst); ++k;
}
rs.add("mini",mini); rs.add("maxi",maxi); return rs.getReturnList();
return List::create(
_["mini"] = mini,
_["maxi"] = maxi
) ;
}

//Confidence intervals based on a Z statistic in bifactorial designs
RcppExport SEXP kritbinomial2(SEXP pr,SEXP nr,SEXP parNr){
int a,b,i,j,k=0,m; SEXP rl=0; RcppResultSet rs; RcppVector<int> parN(parNr),n(nr);
int a,b,i,k=0; IntegerVector parN(parNr),n(nr);
int nsim=parN(0),A=parN(1),B=parN(2);
RcppVector<double> p(pr),maxi(nsim),mini(nsim);
NumericVector p(pr),maxi(nsim),mini(nsim);
vector<int> X(0); vector<double> zst(A*B); double pm;
double ** px; px=new double *[A+1]; for(i=0;i<A+1;++i){px[i]=new double[B+1];}
double ** vx; vx=new double *[A+1]; for(i=0;i<A+1;++i){vx[i]=new double[B+1];}
Expand All @@ -86,15 +100,21 @@ RcppExport SEXP kritbinomial2(SEXP pr,SEXP nr,SEXP parNr){
zst.push_back((px[a][b]-px[a][0])/sqrt((vx[a][b]/n(c2(a,b,B)))+(vx[a][0]/n(c2(a,0,B)))));
zst.push_back((px[a][b]-px[0][b])/sqrt((vx[a][b]/n(c2(a,b,B)))+(vx[0][b]/n(c2(0,b,B)))));
}}
mini(k)=minimalwert(zst); maxi(k)=maximalwert(zst); ++k;
mini[k]=minimalwert(zst);
maxi[k]=maximalwert(zst); ++k;
}
rs.add("mini",mini); rs.add("maxi",maxi); return rs.getReturnList();
}
return List::create(
_["mini"] = mini,
_["maxi"] = maxi
) ;
}

//Confidence intervals based on a Z statistic in trifactorial designs
RcppExport SEXP kritbinomial3(SEXP pr,SEXP nr,SEXP parNr){
int a,b,c,i,j,k=0,m; RcppResultSet rs; RcppVector<int> parN(parNr),n(nr);
int a,b,c,i,j,k=0;
IntegerVector parN(parNr),n(nr);
int nsim=parN(0),A=parN(1),B=parN(2),C=parN(3);
RcppVector<double> p(pr),maxi(nsim),mini(nsim);
NumericVector p(pr),maxi(nsim),mini(nsim);
vector<int> X(0); vector<double> zst(A*B*C);
double *** px; px=new double **[A+1];
for(i=0;i<A+1;++i){px[i]=new double *[B+1]; for(j=0;j<B+1;++j){px[i][j]=new double[C+1];}}
Expand All @@ -121,5 +141,8 @@ RcppExport SEXP kritbinomial3(SEXP pr,SEXP nr,SEXP parNr){
}}}
mini(k)=minimalwert(zst); maxi(k)=maximalwert(zst); ++k;
}
rs.add("mini",mini); rs.add("maxi",maxi); return rs.getReturnList();
return List::create(
_["mini"] = mini,
_["maxi"] = maxi
) ;
}
11 changes: 6 additions & 5 deletions src/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using namespace std;
#include <valarray>
using std::valarray;
#include <time.h>
#include "Rcpp.h"
#include <Rcpp.h>
//Determine largest integer smaller than x///////////////////////////
int gaussklammer(double x){
int k=0;
Expand Down Expand Up @@ -78,12 +78,12 @@ double summe(vector<int>& X){
//Determine the minimum of x and y///////////////////////////////////
double min(double x, double y){
if(x<=y){ return x; }
if(y<=x){ return y; }
return y;
}
//Determine the maximum of x and y///////////////////////////////////
double max(double x, double y){
if(x>=y){ return x; }
if(y>=x){ return y; }
return y;
}
//Determine the minimum of the data X////////////////////////////////
double minimalwert(vector<double>& X){
Expand All @@ -109,8 +109,9 @@ double betrag(double x){
else{return -x;}
}
//Calculate number of simulations according to prespecified standard error
int newnsim(RcppVector<int>& count,int k, int nsim,double simerror,int D){
vector<double> abst(D); int l,lmax;
int newnsim(Rcpp::IntegerVector& count,int k, int nsim,double simerror,int D){
vector<double> abst(D);
int l,lmax=0;
if(simerror!=9 & k==900){
for(l=0;l<=D-1;++l){abst[l]=betrag(double(count(l))-double(450));}
for(l=0;l<=D-1;++l){if(abst[l]==minimalwert(abst)){lmax=l;}}//Der Fehler wird für p=.5 maximal
Expand Down
2 changes: 1 addition & 1 deletion src/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ double max(double x, double y);
double maximalwert(vector<double>& X);
double minimalwert(vector<double>& X);
double betrag(double x);
int newnsim(RcppVector<int>& count, int k, int nsim,double simerror,int D);
int newnsim(Rcpp::IntegerVector& count, int k, int nsim,double simerror,int D);
int c2(int a,int b,int B);
int c20(int a,int b,int B);
int c3(int a,int b,int c,int B,int C);
Expand Down

0 comments on commit 65e7ee3

Please sign in to comment.