def _prepare_simulate(self): # Priors # scaled inverted chi-square. Tuple (v,s2) = (degrees freedom,scale) self.prior_b = gt.create_chisquare_si(1.0,0.5) self.prior_e = gt.create_chisquare_si(1.0,0.5) # Parameters - theta self.theta = np.asmatrix(np.zeros(self.num_parameters).reshape(self.num_parameters,1)) self.loc_hat = np.asmatrix(np.zeros(self.num_locations).reshape(self.num_locations,1)) # used for Garcia-Cortes & Sorensen method self.loc_star = np.asmatrix(np.zeros(self.num_locations).reshape(self.num_locations,1)) self.y_star = np.asmatrix(np.zeros(self.num_y).reshape(self.num_y,1)) self.loc_tilde = np.asmatrix(np.zeros(self.num_locations).reshape(self.num_locations,1)) ## Aliases self.B = np.matrix(self.theta[0:self.num_fixed,0],copy=False) self.B_hat = np.matrix(self.loc_hat[0:self.num_fixed,0],copy=False) # self.B = np.asmatrix(np.zeros(self.num_fixed).reshape(self.num_fixed,1)) self.b = np.matrix(self.theta[self.num_fixed:self.num_locations,0],copy=False) self.b_hat = np.matrix(self.loc_hat[self.num_fixed:,0],copy=False) # self.b = np.asmatrix(np.zeros(self.num_random).reshape(self.num_random,1)) ## Initial Values # B and b initialised to 0 - is this correct for B? self.B[0,0] = 10 self.B[1,0] = 1.5 ### Variance components # one sigma for each random effect self.theta[self.sigma2_b_idx,0] = 0.5 # one sigma for each random effect self.theta[self.sigma2_e_idx,0] = 0.5 # Restore buffer self.restore_initialize() # other initializations self._compute_mm_equations()
def set_default_priors(self): default_gpriors = [gt.create_chisquare_si(1.0, 0.5) for i in range(0, self.c)] default_rpriors = [gt.create_chisquare_si(1.0, 0.5)] # Set priors to defaults scaled inverse chi-square. User can change them later. assert self.set_priors(Gpriors=default_gpriors, Rpriors=default_rpriors)