Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

3
Very basic R coding query for fama French model - somehow I'm making some mistake
Post Flair (click to view more posts with a particular flair)
Post Body

Hi everyone!

I am someone who's not a coder at all. However, I need to run a very basic R code to do some regression analysis and it somehow just doesn't happen. I have ChatGPT'd the hell out of it. YT videos, everything and somehow my regression doesn't work properly. So please help if possible.

I am attaching the screenshot of the excel with the data for which I need to run the R code.

Year CompanyName 1 year return (%) Market rate - Risk free rate (%) SMB (%) HML (%) Riskfree rate (%) Excessreturn (%)
2023 ABC Ltd -2.5% 21.7% -3.24% -13.6% 5% -7.5%
2023 XYZ Ltd -72.5% 21.7% -3.24% -13.6% 5% -77.5%
2023 DEF Ltd 18.9% 21.7% -3.24% -13.6% 5% 13.95%
2023 GHI Ltd 151.7% 21.7% -3.24% -13.6% 5% 146.8%

the idea is that, I need to simply calculate the regression for Excess returns with independent variables being SML, HML and (market rate - risk free rate). The problem is SMB,HML and (market rate - risk free rate) has to be the same for each company. This is because SMB, HML and (market rate - risk free rate) remain the same over the year and only change ever year (so for 2022 those data points are different) However, the excess return is different for each company in each year.

The SMB, HML, Risk free rate and (market rate - risk free rate) are hard coded numbers where as the excessreturn is calculated as 1 year company return minus the risk free rate

You can think of this as a 4 company portfolio sorted based on a particular parameter and now I want to check whether there is any correlation. The problem that I am facing is whenever I run the regression using the code

lm(Excessreturn ~ SMB HML, data=Data) the coefficient for SMB comes out to NA and the error that pops up is "2 not defined due to singularities", can anyone please help me with this. This is just a sample data. I have data from the year 2000 to 2023 and hence will want multiple regressions but I need at least this one to work.

Thank you!

Author
Account Strength
70%
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
1,812
Link Karma
64
Comment Karma
1,677
Profile updated: 1 week ago
Posts updated: 3 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 months ago