You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: sar_gv.m
    path of file: ./repos/malini/Codes/FC_EC_calculation code/DynamicFC/jplv7/spatial/sar_models
    
    the code of the file until where you have to start completion: function results = sar_gv(y,x,W,ndraw,nomit,prior)
% PURPOSE: Bayesian estimates of the spatial autoregressive model
% THIS FUNCTION: estimates the heteroscedasticity parameter r
%                and returns results in results.rdraw for posterior inference
%          y = rho*W*y + XB + e, e = N(0,sige*V), V = diag(v1,v2,...vn) 
%          r/vi = ID chi(r)/r
%          r = Gamma(delta,2)
%          B = N(c,T), 
%          1/sige = Gamma(nu,d0), 
%          rho = Uniform(rmin,rmax) 
%-------------------------------------------------------------
% USAGE: results = sar_gv(y,x,W,ndraw,nomit,prior)
% where: y = dependent variable vector (nobs x 1)
%  
    
function calls to save time)
%          results.acc   = acceptance rate for dof M-H sampling
% --------------------------------------------------------------
% NOTES: purpose of this function is to provide an inference
%        on the hyperparameter r in the heteroscedastic Bayesian sar model
%        Use the results.rdraw to draw this inference
% --------------------------------------------------------------
% SEE ALSO: (sar_gvd demo) 
% --------------------------------------------------------------
% REFERENCES: James P. LeSage, `Bayesian Estimation of Spatial Autoregressive
%             Models',  International Regional Science Review, 1997 
%             Volume 20, number 1\&2, pp. 113-129.
% see also:   LeSage and Pace (2009) Chapter 5 on Bayesian estimation 
%             of spatial regression models.
% For lndet information see: Chapter 4 
%----------------------------------------------------------------

% written by:
% James P. LeSage, last updated 3/2010
% Dept of Finance & Economics
% Texas State University-San Marcos
% 601 University Drive
% San Marcos, TX 78666
% jlesage@spatial-econometrics.com


timet = clock;

% error checking on inputs
[n junk] = size(y);
[n1 k] = size(x);
[n3 n4] = size(W);
time1 = 0;
time2 = 0;
time3 = 0;

results.nobs  = n;
results.nvar  = k;
results.y = y;      

if n1 ~= n
error('sar_gv: x-matrix contains wrong # of observations');
elseif n3 ~= n4
error('sar_gv: W matrix is not square');
elseif n3~= n
error('sar_gv: W matrix is not the same size at y,x');
end