I have the following lm
function in R:
in_data <- c(0.5, 0.6, 0.7)
minutes <- c(30, 60, 90)
foobar <- lm(log(in_data) ~ 0 + hours)
Questions
- I understand the
~
operator is used to separate the left- and right-hand sides in a model formula. So in this case, does it translate tolog(in_data) is dependent on 0 and hours
??? I'm totally lost here, especially on how the log of a vector depends on 0 and another vector - If I were to attempt to port this to Pandas, what would be the most straightforward way? I tried something on the lines of:
.
import statsmodels.formula.api as sm
import numpy as np
result = sm.ols(formula="np.log(in_data) ~ 0 + minutes", data=model_data).fit()
But that threw an error:
patsy.PatsyError: Number of rows mismatch between data argument and np.log(in_data) (1 versus 4)
np.log(in_data) ~ 0 + minutes
^^^^^^^^^^^^^^^^^