Error in using sdm_d to estimate a Spatial Durbin Model

I am a total newby on Matlab. I am trying to run an sdm_d model (to estimate a Spatial Durbin Model). It works to a certain point, then I get an error message:
Error using svd
Input to SVD must not contain NaN or Inf.
Error in pinv (line 29)
[U,S,V] = svd(A,0);
Error in invpd (line 29)
xinv = pinv(x);
Error in sdm (line 242)
hessi = -invpd(dhessn);
Could anybody help me make sense out of it? I attach my code below:
fid1= fopen('code2006011.txt'); % read text file with string characters
C1 = textscan(fid1, '%30s'); % read text file
fclose(fid1);
n=1798;
%create the weight matrix
W=zeros(n,n);
for i=1:1798
i
for j=1:1798
idm=strcmp(C1{1}(i),C1{1}(j)); % compare two labels
if idm==1
W(i,j)=1; % weight matrix = 1 if same label
end
end
end
for i=1:1798
i
for j=1:1798
if i==j
W(i,j)=0; % create the zero diagonal in the weight matrix
end
end
end
bsxfun(@times,W,1./(sum(W,2))); % row-standardize the matrix W
% load dataset with y and x variables
load lndata2006011.csv;
% 6 columns:
% column1 = para_import (the product is parallely imported)
% column2 = bgn (product type: branded generic)
% column3 = gnr (product type: generic)
% column4 = org (product type: original(brand))
% column5 = lnunitaup (natural log of the unit price)
% column6 = lnamount (natural log of the amount sold)
y = lndata2006011(:,6);
x = [ones(n,1) lndata2006011(:,1:5)];
vnames = strvcat('amount','constant','import','brgeneric','generic','original','price');
info.lflag = 0;
info.rmin = -1;
info.rmax = 1;
results = sdm(y,x,W,info);
prt(results,vnames);
prior.lflag = 0;
prior.novi = 1;
ndraw = 2500;
nomit = 500;
results2 = sdm_g(y,x,W,ndraw,nomit,prior);
prt(results2,vnames);
out = [results.bstd results2.beta_std results.bstd - results2.beta_std
results.pstd results2.rho_std results.pstd - results2.rho_std];
in.cnames = strvcat('Hessian estimates','MCMC estimates','Difference');
rnames = strvcat('Std dev');
vnamesx = strvcat('constant','import','brgeneric','generic','original','price','W*import','W*brgeneric','W*generic','W*original','W*price');
in.rnames = strvcat(rnames,vnamesx,'rho');
in.fmt = '%16.8f';
mprint(out,in);
THANK YOU,
Oana

Answers (0)

Products

Asked:

on 5 Jul 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!