Skip to content

Commit

Permalink
Specify more clearly in code and docs that a statsmodel RegressionRes…
Browse files Browse the repository at this point in the history
…ults object is returned.
  • Loading branch information
DeanHenze committed Oct 21, 2022
1 parent eff3f3f commit 758744b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 11 additions & 2 deletions isoxcal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def fit(data, iso, nord):
weighted linear regression from the statsmodels package (weights are the
water concentrations).
Inputs
------
data: pandas.DataFrame.
Sensor measurements.
Expand All @@ -32,6 +34,10 @@ def fit(data, iso, nord):
nord: is 3-tuple of ints.
The highest power to include for each of the predictor variables logq,
isotope-ratio, and their crossterm (in that order).
Returns
-------
A statsmodels RegressionResults object (model parameters and fit metrics).
"""
# Pandas df of predictor vars:
interterm = np.log(data['h2o_tot2'])*data[iso+'_tot2'] # Interaction term.
Expand All @@ -45,8 +51,11 @@ def fit(data, iso, nord):
predictvars_poly = get_poly_terms(predictvars, pwr_range)

# Return model fit:
return sm.WLS(data[iso+'_tot1'], predictvars_poly, missing='drop',
weights=data['h2o_tot2']).fit()
model = sm.WLS(
data[iso+'_tot1'], predictvars_poly,
missing='drop', weights=data['h2o_tot2']
)
return model.fit()



Expand Down
5 changes: 4 additions & 1 deletion qxcal_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def fit(data, k_s1, k_s2):
Sensor measurements.
k_s1, k_s2: str's
Dataframe keys for sensor 1 and 2, respectively.
Returns
-------
A statsmodels RegressionResults object (model parameters and fit metrics).
"""
return sm.OLS(data[k_s1], data[k_s2], missing='drop').fit()

0 comments on commit 758744b

Please sign in to comment.