I need to calculate a CDF for a regression.I have N observations, I need to reestimate coefficients(beta) in a joint distribution. Yobs is my observations and Y is calculated by X(matrix of predctors)* array of coefficients(betas)
def CDF(beta):
Y = X.dot(beta)
sigma = 0
for n in range(0,N):
sigma = sigma + (np.square(Yobs[n] - Y[n])) # summation of squarred of residuals
SSR = sigma / N # mu (mean or expectation)
dof = N - P - 1 # degree of freedom
var = sigma / dof # the mean square of residuals
PDF = np.zeros(N)
CDF = np.zeros(N) # I want to calculate the F(X < Yobs)
for n in range (0,N):
PDF[n] = (1/np.sqrt(2*np.pi*var))*np.exp(-SSR/(2*var)) # probability density function
CDF[n] = integrate.quad(PDF, -np.inf , (Yobs+a)) # CDF
return CDF
Where am I wrong? I think CDF is wrong since I haven't determined the arg, but how can I define? can I simply use?
from scipy.stats import norm
def CDF(beta):
Y = X.dot(beta)
sigma = 0
for n in range(0,N):
sigma = sigma + (np.square(Yobs[n] - Y[n])) # summation of squarred of residuals
SSR = sigma / N # mu (mean or expectation)
dof = N - P - 1 # degree of freedom
var = sigma / dof # the mean square of residuals
CDF = np.zeros(N)
for n in range(0,N): # I want to calculate the F(X < Yobs)
CDF[n] = norm.cdf(Yobs[n],SSR,var)
return CDF