Theoracf_function(phi,series.name){
#compute theoretical acf of AR(2) model, returns as an acf object
# done for lags 0 through 20
# that can be plugged into Splus's acf.plot function
###################################################################
# computing for lags 0 and 1
tacf0_c(1,phi[1]/(1-phi[2]))
# now for lags 2 through 20 from the difference equation
for(lag in 2:20) tacf0_c(tacf0, phi[1]*tacf0[lag] + phi[2]*tacf0[lag-1] )
# bundling together into an appropriate acf type object
tacf_list(acf=array(tacf0,c(21,1,1)),lag=array(0:20,c(21,1,1)),
   n.used=1e10,type="correlation",series=paste(series.name,".theory",sep=""))
return(tacf)
}
