% % real2.m is an example matlab program % to read in the solution to a simple real estate search model % and compute reservation price for each type of house % and simulate model % format bank % ----- save output to file ----- % clear all diary real2.mout diary off delete real2.mout diary real2.mout % ----- display date and time of computation ----- % %format short date time0 = clock; % ----- set control vars ----- % iters = 700; % ----- load data ----- % X = load('real1.dat') % ----- compute reservation prices ----- % P11=min(X(X(:,9)==1 & X(:,2)==1 & X(:,3)==1,7)) P12=min(X(X(:,9)==1 & X(:,2)==1 & X(:,3)==2,7)) P13=min(X(X(:,9)==1 & X(:,2)==1 & X(:,3)==3,7)) P21=min(X(X(:,9)==1 & X(:,2)==2 & X(:,3)==1,7)) P22=min(X(X(:,9)==1 & X(:,2)==2 & X(:,3)==2,7)) P23=min(X(X(:,9)==1 & X(:,2)==2 & X(:,3)==3,7)) P31=min(X(X(:,9)==1 & X(:,2)==3 & X(:,3)==1,7)) P32=min(X(X(:,9)==1 & X(:,2)==3 & X(:,3)==2,7)) P33=min(X(X(:,9)==1 & X(:,2)==3 & X(:,3)==3,7)) P = [P11 P12 P13; P21 P22 P23; P31 P32 P33 ] ; % ----- periods and people ----- % t = 50 n = 300 % ----- set parameters ----- % beta0 = 6; beta1 = 1; beta2 = 1; % ----- for each person randomly draw housing hedonic values ----- % omega = discreteinvrnd([.4,.4,.20],n,2) ; % ----- for every person, draw a pricing shock % and compute a price for each period % till the reservation price is meet ----- % [ep,eppr]=qnwnorm(3,0,.40); for i = 1:n for j = 1:t ss = ep(discreteinvrnd(eppr,1,1)); price(i,1) = exp(beta0 + beta1*omega(i,1) + beta2*omega(i,2) + ss ) ; exprice(i,1) = exp(beta0 + beta1*omega(i,1) + beta2*omega(i,2) ) ; timemkt(i,1) = j; if price(i,1) >= floor(P(omega(i,1),omega(i,2))), break, end end end % ----- plot time on the market histogram ----- % figure(1) hist(timemkt,20) title('(A) Distribution of Time on the Market','fontsize',16,'fontname','times') print -depsc2 -tiff -r300 -adobecset real2a % ----- compute mean mean time on the market ----- % mean(timemkt) % ----- compute regression coefficient ----- % inv([ones(n,1) omega]'*[ones(n,1) omega])*[ones(n,1) omega]'*log(price) % ----- save data ----- % X = [ log(price) omega(:,1:2) ] ; save real2.dat X -ascii comptime = etime(clock, time0) diary off