n=matrix(scan("C:/Users/wenche_adm/Desktop/Nils/uio/Exercises/norwegianclaims3.txt"),byrow=T,ncol=4);
nn=matrix(0,2,7);
T=nn;
for (i in 1:2)
{
for (j in 1:7)
{
T[i,j]=sum(n[n[,1]==j&n[,2]==i-1,3]);#counts exposure. take all that equal j
# in the first column (age group)and i-1 in the second column (gender)
# for all that satisfy these criteria take the third column which is exposure
nn[i,j]=sum(n[n[,1]==j&n[,2]==i-1,4]);
}
}
muhat=nn/T;
sd=muhat/sqrt(T);