def bbvi_fit(self,posterior,printer=True,step=0.001,iterations=30000):

		# Starting parameters
		phi = np.zeros(self.param_no)

		# Starting values
		if self.model_type == 'GAS':
			if self.dist in ['Laplace','Normal']:
				phi[0] = np.mean(self.data)
			elif self.dist == 'Poisson':
				phi[0] = np.log(np.mean(self.data))
		elif self.model_type == 'VAR':
			phi = self.create_B_direct().flatten()
			cov = self.estimate_cov()

			# Inelegant - needs refactoring
			for i in range(self.ylen):
				for k in range(self.ylen):
					if i == k:
						phi = np.append(phi,self.param_desc[len(phi)]['prior'].itransform(cov[i,k]))
					elif i > k:
						phi = np.append(phi,self.param_desc[len(phi)]['prior'].itransform(cov[i,k]))			
		elif self.model_type == 'GARCH':
			phi = np.ones(self.param_no)*0.00001
			phi[0] = self.param_desc[0]['prior'].itransform(np.mean(np.power(self.data,2)))
		elif self.model_type == 'EGARCH':
			phi[0] = self.param_desc[0]['prior'].itransform(np.log(np.mean(np.power(self.data,2))))
		elif self.model_type == 'GPNARX':
			phi = np.ones(self.param_no)*0.0
			arma_start = arma.ARIMA(self.data,ar=self.ar,ma=0,integ=self.integ)
			arma_start.fit(printer=False)
			phi[0] = arma_start.params[len(arma_start.params)-1]

		self.params = phi

		# Starting values for approximate distribution
		for i in range(len(self.param_desc)):
			approx_dist = self.param_desc[i]['q']
			if isinstance(approx_dist, dst.Normal):
				self.param_desc[i]['q'].loc = self.params[i]
				if len(self.ses) == 0:
					self.param_desc[i]['q'].scale = -3.0
				else:
					self.param_desc[i]['q'].scale = log(self.ses[i])
		q_list = [k['q'] for k in self.param_desc]
		
		bbvi_obj = ifr.BBVI(posterior,q_list,12,step,iterations)
		q, q_params, q_ses = bbvi_obj.lambda_update()
		self.params = q_params

		for k in range(len(self.param_desc)):
			self.param_desc[k]['q'] = q[k]

		self.normal_posterior_sim(self.params,np.diag(np.exp(q_ses)),"Black Box Variational Inference",printer)
Performs Black Box Variational Inference
dataset/ETHPy150Open RJT1990/pyflux/pyflux/tsm.py/TSM.bbvi_fit