Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions