def plot_coefficients(self, submodel=-2, exclude_constant=True, eqidx=0, plot=True, store_values_to_file=None): """ Plot a barchart of coefficient values. This can be used in a regression model, when coefficients are standardized (i.e. using the estimation module opus_core.estimate_linear_regression_standardized). store_values_to_file can be a file name where the values are stored. """ coef = self.get_coefficients(submodel) values = coef.get_coefficient_values() names = coef.get_coefficient_names() sd = coef.get_standard_errors() idx=ones(names.shape[1], dtype="bool") if exclude_constant: pos = coef.get_constants_positions() if pos.size > 0: idx[pos]=0 if store_values_to_file is not None: n = idx.sum() result = concatenate((reshape(names[eqidx, idx], (n,1)), reshape(values[eqidx, idx], (n,1)), reshape(sd[eqidx, idx], (n,1))), axis=1) write_to_text_file(store_values_to_file, array(['coefficient_name', 'estimate', 'standard_error']), delimiter='\t') write_table_to_text_file(store_values_to_file, result, delimiter='\t', mode='a') if plot: plot_barchart(values[eqidx, idx], labels = names[eqidx, idx], errors=sd[eqidx, idx]) else: return {'names': names[eqidx, idx], 'values': values[eqidx, idx], 'errors': sd[eqidx, idx]}
def plot_utility_diagnose(filename): from opus_core.plot_functions import plot_barchart data, coef_names = load_table_from_text_file(filename, convert_to_float=True, header=True) plot_barchart(data[2, :], labels=coef_names)
def plot_utility_diagnose(filename): from opus_core.plot_functions import plot_barchart data, coef_names = load_table_from_text_file(filename, convert_to_float=True, header=True) plot_barchart(data[2,:], labels = coef_names)