1

I having problem to adjust with ols class the equation y = b0 + b1x1 + b2x2

The code:

xs = numpy.loadtxt('teste.csv', skiprows=1, dtype=float, delimiter=';', usecols=(0,1)) y = log(xs[:,0]) x = 1/xs[:,1] x2 = (1/xs[:,1])**2 mymodel = ols.ols(y,x,'y',['x1', 'x2']) mymodel.summary()` 

I got this error:

print '''% -5s % -5.6f % -5.6f % -5.6f % -5.6f''' % tuple([self.x_varnm[i],self.b[i],self.se[i],self.t[i],self.p[i]]) IndexError: index out of bounds 

Someone can help me?

1 Answer 1

1

Try defining your x as:

x = 1/xs[:,1:2] # slice to keep (n, 1) shape x2 = (1/xs[:,1:2])**2 x = np.hstack((x, x2)) 

You are telling ols to expect a two column matrix for x, but are passing a single one in, hence the error.

Sign up to request clarification or add additional context in comments.

1 Comment

or x = 1/xs[:,1,np.newaxis] which looks less like a mistake to me. x[1:2] is the kind of thing I'll go back and change in old code :P

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.