Hi guys and gals!
I've scoured the internet for a solution, but have yet to find a proper solution. What I want to do is quite simple: individually regress columns B-J (RAD to TPD) against Column O (Mkt-Rf) in my spreadsheet. I really want to use DataAnalysis, too, because it gives me everything I need for the CAPM finance model (Beta, Alpha, & T-Stat). My current code doesn't work, this is what it looks like:
Dim i As Integer
Dim stock_name As String
Dim y_Range As Range
Dim x_Range As Range
i = 1
Set y_Range = Range("B2:B123")
Set x_Range = Range("O2:O123")
For i = 1 To 9
stock_name = y_Range.Cells(1, 1)
Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range(y_Range), _
ActiveSheet.Range(x_Range), False, True, , stock_name, False, False, False _
, False, , False
y_Range = y_Range.Offset(0, 1).Select
Next i
End Sub
This is what my data looks like (I'm doing a linear regression for CAPM, for all you finance heads out there)
[TABLE="width: 920"]
<tbody>[TR]
[TD]Date[/TD]
[TD]RAD[/TD]
[TD]WAG[/TD]
[TD]CVS[/TD]
[TD]ARBR[/TD]
[TD]FAY[/TD]
[TD]MSII[/TD]
[TD]ECK[/TD]
[TD]BIGB[/TD]
[TD]TPD[/TD]
[TD][/TD]
[TD]Date[/TD]
[TD]S&P 500[/TD]
[TD]3-Mo T-Bill[/TD]
[TD]Mkt-Rf[/TD]
[/TR]
[TR]
[TD]5/29/1987[/TD]
[TD]-4.53%[/TD]
[TD]1.03%[/TD]
[TD]3.05%[/TD]
[TD]-15.49%[/TD]
[TD]-1.45%[/TD]
[TD]4.76%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5/29/1987[/TD]
[TD]0.60%[/TD]
[TD="align: right"]5.67%[/TD]
[TD]-5.07%[/TD]
[/TR]
[TR]
[TD]6/30/1987[/TD]
[TD]-4.06%[/TD]
[TD]12.24%[/TD]
[TD]8.50%[/TD]
[TD]0.00%[/TD]
[TD]2.94%[/TD]
[TD]6.82%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]6/30/1987[/TD]
[TD]4.79%[/TD]
[TD="align: right"]5.69%[/TD]
[TD]-0.90%[/TD]
[/TR]
[TR]
[TD]7/31/1987[/TD]
[TD]10.81%[/TD]
[TD]2.12%[/TD]
[TD]8.52%[/TD]
[TD]6.67%[/TD]
[TD]-1.43%[/TD]
[TD]-3.19%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]7/31/1987[/TD]
[TD]4.82%[/TD]
[TD="align: right"]6.04%[/TD]
[TD]-1.22%[/TD]
[/TR]
[TR]
[TD]8/31/1987[/TD]
[TD]1.49%[/TD]
[TD]-1.19%[/TD]
[TD]-1.57%[/TD]
[TD]-4.69%[/TD]
[TD]2.90%[/TD]
[TD]6.59%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]8/31/1987[/TD]
[TD]3.50%[/TD]
[TD="align: right"]6.40%[/TD]
[TD]-2.90%[/TD]
[/TR]
[TR]
[TD]9/30/1987[/TD]
[TD]-22.62%[/TD]
[TD]-4.21%[/TD]
[TD]-4.94%[/TD]
[TD]-16.39%[/TD]
[TD]-7.04%[/TD]
[TD]3.61%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]9/30/1987[/TD]
[TD]-2.42%[/TD]
[TD="align: right"]6.13%[/TD]
[TD]-8.55%[/TD]
[/TR]
[TR]
[TD]10/30/1987[/TD]
[TD]-22.40%[/TD]
[TD]-23.51%[/TD]
[TD]-28.02%[/TD]
[TD]-29.41%[/TD]
[TD]-22.73%[/TD]
[TD]-29.35%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]10/30/1987[/TD]
[TD]-21.76%[/TD]
[TD="align: right"]5.69%[/TD]
[TD]-27.45%[/TD]
[/TR]
[TR]
[TD]11/30/1987[/TD]
[TD]-0.16%[/TD]
[TD]-13.11%[/TD]
[TD]-12.35%[/TD]
[TD]-9.72%[/TD]
[TD]0.00%[/TD]
[TD]5.63%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]11/30/1987[/TD]
[TD]-8.53%[/TD]
[TD="align: right"]5.77%[/TD]
[TD]-14.30%[/TD]
[/TR]
</tbody>[/TABLE]
I appreciate your help!
-Rejexted
I've scoured the internet for a solution, but have yet to find a proper solution. What I want to do is quite simple: individually regress columns B-J (RAD to TPD) against Column O (Mkt-Rf) in my spreadsheet. I really want to use DataAnalysis, too, because it gives me everything I need for the CAPM finance model (Beta, Alpha, & T-Stat). My current code doesn't work, this is what it looks like:
Dim i As Integer
Dim stock_name As String
Dim y_Range As Range
Dim x_Range As Range
i = 1
Set y_Range = Range("B2:B123")
Set x_Range = Range("O2:O123")
For i = 1 To 9
stock_name = y_Range.Cells(1, 1)
Application.Run "ATPVBAEN.XLAM!Regress", ActiveSheet.Range(y_Range), _
ActiveSheet.Range(x_Range), False, True, , stock_name, False, False, False _
, False, , False
y_Range = y_Range.Offset(0, 1).Select
Next i
End Sub
This is what my data looks like (I'm doing a linear regression for CAPM, for all you finance heads out there)
[TABLE="width: 920"]
<tbody>[TR]
[TD]Date[/TD]
[TD]RAD[/TD]
[TD]WAG[/TD]
[TD]CVS[/TD]
[TD]ARBR[/TD]
[TD]FAY[/TD]
[TD]MSII[/TD]
[TD]ECK[/TD]
[TD]BIGB[/TD]
[TD]TPD[/TD]
[TD][/TD]
[TD]Date[/TD]
[TD]S&P 500[/TD]
[TD]3-Mo T-Bill[/TD]
[TD]Mkt-Rf[/TD]
[/TR]
[TR]
[TD]5/29/1987[/TD]
[TD]-4.53%[/TD]
[TD]1.03%[/TD]
[TD]3.05%[/TD]
[TD]-15.49%[/TD]
[TD]-1.45%[/TD]
[TD]4.76%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]5/29/1987[/TD]
[TD]0.60%[/TD]
[TD="align: right"]5.67%[/TD]
[TD]-5.07%[/TD]
[/TR]
[TR]
[TD]6/30/1987[/TD]
[TD]-4.06%[/TD]
[TD]12.24%[/TD]
[TD]8.50%[/TD]
[TD]0.00%[/TD]
[TD]2.94%[/TD]
[TD]6.82%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]6/30/1987[/TD]
[TD]4.79%[/TD]
[TD="align: right"]5.69%[/TD]
[TD]-0.90%[/TD]
[/TR]
[TR]
[TD]7/31/1987[/TD]
[TD]10.81%[/TD]
[TD]2.12%[/TD]
[TD]8.52%[/TD]
[TD]6.67%[/TD]
[TD]-1.43%[/TD]
[TD]-3.19%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]7/31/1987[/TD]
[TD]4.82%[/TD]
[TD="align: right"]6.04%[/TD]
[TD]-1.22%[/TD]
[/TR]
[TR]
[TD]8/31/1987[/TD]
[TD]1.49%[/TD]
[TD]-1.19%[/TD]
[TD]-1.57%[/TD]
[TD]-4.69%[/TD]
[TD]2.90%[/TD]
[TD]6.59%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]8/31/1987[/TD]
[TD]3.50%[/TD]
[TD="align: right"]6.40%[/TD]
[TD]-2.90%[/TD]
[/TR]
[TR]
[TD]9/30/1987[/TD]
[TD]-22.62%[/TD]
[TD]-4.21%[/TD]
[TD]-4.94%[/TD]
[TD]-16.39%[/TD]
[TD]-7.04%[/TD]
[TD]3.61%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]9/30/1987[/TD]
[TD]-2.42%[/TD]
[TD="align: right"]6.13%[/TD]
[TD]-8.55%[/TD]
[/TR]
[TR]
[TD]10/30/1987[/TD]
[TD]-22.40%[/TD]
[TD]-23.51%[/TD]
[TD]-28.02%[/TD]
[TD]-29.41%[/TD]
[TD]-22.73%[/TD]
[TD]-29.35%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]10/30/1987[/TD]
[TD]-21.76%[/TD]
[TD="align: right"]5.69%[/TD]
[TD]-27.45%[/TD]
[/TR]
[TR]
[TD]11/30/1987[/TD]
[TD]-0.16%[/TD]
[TD]-13.11%[/TD]
[TD]-12.35%[/TD]
[TD]-9.72%[/TD]
[TD]0.00%[/TD]
[TD]5.63%[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]11/30/1987[/TD]
[TD]-8.53%[/TD]
[TD="align: right"]5.77%[/TD]
[TD]-14.30%[/TD]
[/TR]
</tbody>[/TABLE]
I appreciate your help!
-Rejexted