예제 #1
0
def run_regression(survey, version):
	"""Runs logistic regressions.

	survey: Survey
	version: which model to run

	Returns: Regressions object
	"""
	dep, control = DataUtilities.get_version(version)

	print dep, control
	reg = survey.make_logistic_regression(dep, control)
	#print reg
	return Regressions([reg])
예제 #2
0
def test_models(version=(30,-1), resample_flag=False, patients = -1, printReg = True):
	means = dict(educ_from_12=4,
			born_from_1960=10)

	if patients == -1:
		patients = DataUtilities.getDictReadofPatientsFilled()
	#patients = getDictReadofPatientsFilled()
	# read the survey
	survey, complete = read_complete(version, patients)

	print DataUtilities.get_version(version)

	#compare_survey_and_complete(survey, complete)

	#print 'all respondents', survey.len()

	#print 'complete', complete.len()

	# run the models
	if printReg:
		regs = run_regression_and_print(survey, version=version, means=means)
	else:
		regs = run_regression(survey, version)
	return regs
예제 #3
0
def read_complete(version,patients):
	survey = read_survey(patients)

	# give respondents random values
	#[r.clean_random() for r in survey.respondents()]

	# select complete records
	dep, control = DataUtilities.get_version(version)
	#for var in [dep] + control:
	#	print r'\verb"%s",' % var

	attrs = [dep] + control
	complete = survey.subsample(lambda r: r.is_complete(attrs))

	return survey, complete