Question: # Define the predictor variables and response variable X = Coaches[['School', 'TotalPay', 'Conference']] y = Coaches['SchoolPay'] # Add a constant to the predictor variables for

# Define the predictor variables and response variable X = Coaches[['School', 'TotalPay', 'Conference']] y = Coaches['SchoolPay']

# Add a constant to the predictor variables for the intercept X = sm.add_constant(X)

# Fit the linear model model = sm.OLS(y, X).fit()

Continue getting error:

ValueError: Pandas data cast to numpy dtype of object. Check input data with np.asarray(data).

import numpy as np

X = np.asarray(Coaches[['School', 'TotalPay', 'Conference']]) y = np.asarray(Coaches['SchoolPay'])

# Fit the linear model model = sm.OLS(y, X).fit()

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Coaches = Coaches.replace([np.inf, -np.inf], np.nan).dropna()

X = Coaches[['School', 'TotalPay', 'Conference']]

y = Coaches['SchoolPay']

X = sm.add_constant(X)

model = sm.OLS(y, X).fit()

ValueError: Pandas data cast to numpy dtype of object. Check input data with np.asarray(data).

X = np.asarray(Coaches[['School', 'TotalPay', 'Conference']])

y = np.asarray(Coaches['SchoolPay'])

model = sm.OLS(y, X).fit()

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Need help with a python code to fit the model.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!