Dear all
I am trying to understand the logit regression code below and although it is a function I tried to run step by step as a sub to understand it. the xraw and y ranges in this context doesn't work, it gives me an error. then I've replaced the N and K by:
N = Cells(Rows.Count, 1).End(xlUp).Row
K = Cells(1, Columns.Count).End(xlToLeft).Column + constant
The first step is to create a vector of ones (1) when it goes to xraw(i, j - constant) it gives me an error
Also shall I state that constant is = 1?
Could you please advise?
__________________________________________________________________________________________
Function logit(y As Range, xraw As Range, Optional constant, Optional stats)
If IsMissing(constant) Then constant = 1
If IsMissing(stats) Then stats = 0
'Count variables
Dim i As Integer, j As Integer, jj As Integer
'Read data dimensions
Dim K As Integer, N As Integer
N = y.Rows.Count
K = xraw.Columns.Count + constant
'Some error checking
If xraw.Rows.Count <> N Then MsgBox "error"
'Adding a vector of ones to the x matrix if constant=1, name xraw=x from now on
Dim x() As Double
ReDim x(1 To N, 1 To K)
For i = 1 To N
x(i, 1) = 1
For j = 1 + constant To K
x(i, j) = xraw(i, j - constant)
Next j
Next i
I am trying to understand the logit regression code below and although it is a function I tried to run step by step as a sub to understand it. the xraw and y ranges in this context doesn't work, it gives me an error. then I've replaced the N and K by:
N = Cells(Rows.Count, 1).End(xlUp).Row
K = Cells(1, Columns.Count).End(xlToLeft).Column + constant
The first step is to create a vector of ones (1) when it goes to xraw(i, j - constant) it gives me an error
Also shall I state that constant is = 1?
Could you please advise?
__________________________________________________________________________________________
Function logit(y As Range, xraw As Range, Optional constant, Optional stats)
If IsMissing(constant) Then constant = 1
If IsMissing(stats) Then stats = 0
'Count variables
Dim i As Integer, j As Integer, jj As Integer
'Read data dimensions
Dim K As Integer, N As Integer
N = y.Rows.Count
K = xraw.Columns.Count + constant
'Some error checking
If xraw.Rows.Count <> N Then MsgBox "error"
'Adding a vector of ones to the x matrix if constant=1, name xraw=x from now on
Dim x() As Double
ReDim x(1 To N, 1 To K)
For i = 1 To N
x(i, 1) = 1
For j = 1 + constant To K
x(i, j) = xraw(i, j - constant)
Next j
Next i