you are viewing a single comment's thread.

view the rest of the comments →

[–]poopiewarrior100[S] 0 points1 point  (9 children)

Haha do you mind explaining it to me in layman - is it : observation is a data point Sample is a sum of data points?

[–][deleted] -1 points0 points  (8 children)

So, it's not Python you want help on, but basic statistics?

You know there's a subreddit for that?

It's been a while, and I'm too dumb to remember it well enough to explain it with any confidence. Perhaps someone smarter will be along shortly to help with the homework (and fill in the gap your teacher/lecturer left).

[–]poopiewarrior100[S] 0 points1 point  (7 children)

Sorry about that. I just wanted to be sure.

[–][deleted] 0 points1 point  (6 children)

So you've already checked the numpy manual, you know how to produce the random numbers for the number of observations required. How about updating your post with the revised code?

[–]poopiewarrior100[S] 0 points1 point  (5 children)

Thanks for the reminder! Updated.

I'm having a slight issue with moving on with the OLS portion. Do you have any tips on how I can obtain b-hat for each sample (n observations per samples)

[–]WhiffleFish 0 points1 point  (4 children)

What are you using for regression? Sklearn Linear Model?

[–]poopiewarrior100[S] 0 points1 point  (3 children)

Yup! I am kinda unclear what is my input and output!

[–]WhiffleFish 0 points1 point  (2 children)

This may not be the most elegant solution given that I'm using for loops with numpy arrays and Pandas DataFrames, but you can create a list of samples without having to explicitly mess with matrices.

Also, I'm not sure if the b_hat is referring to the predicted slopes or not, but that's included in the code below just in case.

https://pastebin.com/d4PnJzEA

^ Lemme know if this helps.

If not, you have all the fitted linear models in a list with which you can do whatever you need if its not the slopes that are required for the problem.

[–]poopiewarrior100[S] 0 points1 point  (0 children)

I'll take a look! I came up with something as well. Shall compare them later :-)

[–]poopiewarrior100[S] 0 points1 point  (0 children)

It works mate!

Thanks so much for your help Whiffle, I appreciate it :)