C=function(a0,a1)
{
IT=c(100,200,300,400,500,600,700)``
w=c(1,2)
n0=matrix(c(58,54,40,36,18,13,8,0,1,0,1,0,0,0),nrow=2)
n0
n1=matrix(c(13,12,23,24,41,35,25,13,21,3,11,0,9,0),nrow=2)
n1
n2=matrix(c(0,1,1,3,1,1,1,2,1,1,0,1,1,1),nrow=2)
n2
n12=matrix(c(1,0,1,5,3,17,6,28,16,35,21,30,39,28),nrow=2)
n12
x<-c(0,1);N1=F1=F2=K=N2=array(0,dim=c(2,7)); alpha=array(0,dim=c(2,1))
for(i in 1:2){
for(j in 1:7){
N1[i,j]=n1[i,j]+n12[i,j]; K[i,j]=n1[i,j]+n2[i,j]+n12[i,j]+n0[i,j]; N2[i,j]=n2[i,j]+n12[i,j];
cat("i,j,N1",i,j,N1,"
")
F1[i,j]=N1[i,j]/K[i,j]
F2[i,j]=N2[i,j]/K[i,j]
alpha=exp(a0+a1*x)+1
c<-exp(-((-log(F1))^(alpha)+((-log(F2))^(alpha))^(1/alpha)))
}}
return(c)
}
enter code here
L=function(a0,a1)
{
unit=matrix(1,nrow=2,ncol=7)
sum1=matrix(0,nrow=2,ncol=7)
sum2=matrix(0,nrow=2,ncol=7)
sum3=matrix(0,nrow=2,ncol=7)
sum4=matrix(0,nrow=2,ncol=7)
t1=t2=t3=t4=array(0,dim=c(2,7))
for(i in 1:2){
for(j in 1:7){
t1[i,j]=n12[i,j]*log(C(a0,a1))
t2[i,j]=n1[i,j]*log(F1[i,j]-C(a0,a1))
t3[i,j]=n2[i,j]*log(F2[i,j]-C(a0,a1))
t4[i,j]=n0[i,j]*log(unit[i,j]-F1[i,j]-F2[i,j]+C(a0,a1))
sum1[i,j]=sum1[i,j]+t1[i,j]
sum2[i,j]=sum2[i,j]+t2[i,j]
sum3[i,j]=sum3[i,j]+t3[i,j]
sum4[i,j]=sum4[i,j]+t4[i,j]
sum[i,j]=sum1[i,j]+sum2[i,j]+sum3[i,j]+sum4[i,j]
}
}
sum
return(-sum)
}
getting error in this program Error in C(a0, a1) : object 'a0' not found a0 and a1 are scalar which is the parameter. It contain some initial values as -0.7 and 0.54. C is a function of a0 and a1. L is a function which is using the function C to compute the sum.