I am sorry if this question is vague or uninformed.  I am just  
learning R and struggling.  I am using the book Hierarchical Modeling  
and Inference in Ecology and they provide examples of R code.  I have  
the following code from the book but when I run it I don't get any  
output.  I cannot get the values of 'out' to show up.  Basically, I  
just want to see my estimates for b0, b1, b2, and b3.  Any time that I  
have used or see function( ) there have been arguments and I just call  
for the value of the function.  In this case there doesn't seem to be  
a value for the function.  Any help would be appreciated.

Thanks,
Dan


`panel3pt1.fn` <-
function(){

source("utilfns.Rd")

data<- read.table("wtmatrix.txt",header=T,na.strings=T)
elev<-data[,"elev"]
forest<-data[,"forest"]
elev<-scale(elev,center=TRUE)
forest<-scale(forest,center=TRUE)
pamat<-data[,c("y.1","y.2","y.3")]
z<-pamat[,1]
M<-length(z)


lik<-function(parms){
     b0<-parms[1]
     b1<-parms[2]
     b2<-parms[3]
     b3<-parms[4]
     ones<-rep(1,M)
     ### Compute binomial success probabilities
     probs<-expit(b0*ones+b1*elev+b2*(elev^2)+b3*forest)
     lik<-rep(0,length(z))
     ### evaluate log of binomial pmf
     tmp<-log(dbinom(z,1,probs))
     ### substitute 0 for missing values
     lik[!is.na(z)]  <-  tmp[!is.na(z)]
     lik<-  -1*sum(lik)
     return(lik)
}

  out <- nlm(lik,c(0,0,0,0),hessian=TRUE)

  return(out)


}

------------------------------------------------------------------------------------
Daniel J. Hocking
122 James  Hall
Department of Natural Resources & the Environment
University of New Hampshire
Durham, NH 03824

dhocking@unh.edu
http://sites.google.com/site/danieljhocking/
www.hockingphotography.smugmug.com

"Without data, all you are is just another person with an opinion."
-------------------------------------------------------------------------------------







	[[alternative HTML version deleted]]

