[R] Fortran

Heberto Ghezzo Heberto at meakins.lan.mcgill.ca
Thu Oct 26 17:41:27 CEST 2000


Hi to the list.
I think this has been discussed but i did not find anything in the 
FAQ.
I am using R1.1 in Win98V2, compiler mingw32 etc.
I want to program the calculation of the p value for Dunnett test for 
comparing k treatment means with a control. The program in fortran 
is in AppStat 251 1989,V38,p3. and in Statlib AP251
I substituted their main by the following R

.First.lib <- function(lib, pkg) {
library.dynam("dunnett", pkg, lib)
}

pdunnett <- function(x,k,n,lowr=-x)
{
#uses Dunnett code to compute the p of a Dunnett test
#
  kk <- k
  k <- k-1
  bpd<-vector(mode="double",length=k)
  for (i in 2:kk) bpd[i-1] <- 1/sqrt(1+n[1]/n[i])
  ndf <- sum(n)-kk
#
  d<-vector(mode="double",length=k)
  a<-vector(mode="double",length=k)
  b<-vector(mode="double",length=k)
  inf <- vector(mode="integer",length=k)
#
  inf[1] <- 2
  d <- rep(0.0,k)
  b <- rep(lowr,k)
  a <- rep(x,k)
  errb <- 0.0001
  ierc <- 0
  hnc <- 0.0
  prob <- 0.51
  bnd <- 0.0
  iflt <- 0
  buf <- 2.0
#  this is the subroutine called
#      SUBROUTINE # 
MVSTUD(NDF,A,B,BPD,ERRB,N,INF,D,IERC,HNC,PROB,
#     *    BND,IFLT,buf)
#
  ans <- .Fortran("mvstud",
ndf=as.integer(ndf),
a=as.double(a),
b=as.double(b),
bpd=as.double(bpd),
errb=as.double(errb),
n=as.integer(k),
inf=as.integer(inf),
d=as.double(d),
ierc=as.integer(ierc),
hnc=as.double(hnc),
prob=as.double(prob),
bnd=as.double(bnd),
iflt=as.integer(iflt),
buf=as.double(buf) )
#
  list(prob=ans[[11]],bnd=ans[[12]],buf=ans[[14]])
}

but I can get anything back, I put buf=10; return; at the beginning of 
MVSTUD but buf is still 2.
Can some charitable soul tell me what I am doing wrong?
As always thanks for the help
.

R. Heberto Ghezzo  Ph.D.
Meakins-Christie Labs
McGill University
Montreal - Canada
heberto at meakins.lan.mcgill.ca
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list