// Poisson regression with spatially smoothed mean. DATA_SECTION init_int n // Number of observations init_vector y(1,n) // Poisson counts init_int p // Number of fixed effects (b's) init_matrix X(1,n,1,p) // Covariate matrix init_matrix Z(1,n,1,2) // Locations (xy-coordinates) // Makes columns of X orthogonal to improve stability number ncol1 number ncol2 matrix dd(1,n,1,n); // Distance matrix LOC_CALCS int i, j; // make the columns of X orthonormal dmatrix tX=trans(X); ncol1=norm(tX(1)); tX(1)/=ncol1; tX(2)-= tX(1)*tX(2)*tX(1); cout << tX(1)*tX(2) << endl; ncol2=norm(tX(2)); tX(2)/=ncol2; X=trans(tX); cout << norm(column(X,1)) << endl; cout << norm(column(X,2)) << endl; cout << column(X,1)*column(X,2) << endl; dd.initialize(); for(i=1;i<=n;i++) { for ( j=1;j