Displaying 1 result from an estimated 1 matches for "fthg".
Did you mean:
ftag
2010 Dec 16
1
Optim function with meta parameters
....csv("c:/csv/sa0910.csv",header=T,sep=",")
est<-c()
poisson.lik<-function(theta,x){
lambda<-theta[1]
mu<-theta[2]
n<-length(data[,1])
logl<-sum(x[,1])*log(lambda)-n*lambda+sum(x[,2])*log(mu)-n*mu
return(-logl)
}
for(i in 1:10){
data<-data.frame(subset(sa0910$FTHG,sa0910$Team1==levels(sa0910$Team1)[i]),subset(sa0910$FTAG,sa0910$Team2==levels(sa0910$Team2)[i]))
est[i]<-optim(c(1,1),p.lik,x=data,method="BFGS",hessian=T)
}
Now I should be able to do the task, defining lambda=alfa(i)*beta(j)*gamma
and mu=alfa(j)*beta(i) where i indicates team1 and...