question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

diagnostic: link test - nonlinearity test for many model

See original GitHub issue

see Stata ‘r.pdf’ manual

estimate y with exog_test = (fittedvalues, fittedvalues**2) reject correct specification if fittedvalues**2 is significant

there might be something similar for OLS already, but Stata’s link test works for discrete models, e.g. after Logit. For example for Logit we have to run a Logit(endog, exog_test).fit(...) again. (do we have all information to run model and fit with the same options again?)

if rejected: either some missing non-linearities in the explanatory variables or incorrectly specified link function

edit don’t use fittedvalues, use predict(linear=True), fittedvalues should be refactored to return the transformed, expected mean or estimated mean function E(y|x).

Issue Analytics

  • State:open
  • Created 10 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
josef-pktcommented, Apr 9, 2019

look at https://github.com/statsmodels/statsmodels/blob/master/statsmodels/stats/outliers_influence.py#L102

Essentially we need the same thing for other models than OLS. The call to OLS needs to be replace by a GLM model. The extra keywords that the user used when creating the model like offset, exposure and weights in the GLM case are available in the _init_kwds attribute. There should be some examples for the creation of a new GLM model in the statsmodels source, but I don’t remember where.

0reactions
mina1987commented, Apr 9, 2019

see Stata ‘r.pdf’ manual

estimate y with exog_test = (fittedvalues, fittedvalues**2) reject correct specification if fittedvalues**2 is significant

there might be something similar for OLS already, but Stata’s link test works for discrete models, e.g. after Logit. For example for Logit we have to run a Logit(endog, exog_test).fit(...) again. (do we have all information to run model and fit with the same options again?)

if rejected: either some missing non-linearities in the explanatory variables or incorrectly specified link function

edit don’t use fittedvalues, use predict(linear=True), fittedvalues should be refactored to return the transformed, expected mean or estimated mean function E(y|x).

I am trying to contribute to this issue but having trouble figuring out what needs to be done. Is it about a linktest for GLM that takes model as an argument?

Read more comments on GitHub >

github_iconTop Results From Across the Web

8. Diagnosing and Correcting Nonlinearity and Other Ills
▻ Discrete explanatory variables divide the data into groups. • A simple incremental F-test for nonlinearity compares the sum of squares accounted for...
Read more >
Is there formal test of non-linearity in linear regression?
Fit a non-linear regression (e.g. spline model like GAM) and then compare it to the linear model using AIC or likelihood ratio test....
Read more >
[PDF] Nonlinear Model Specification/Diagnostics: Insights ...
PDF | A single statistical test for nonlinearity can indicate whether or not the generating mechanism of a time series is or is...
Read more >
Diagnostic Checking in Regression Relationships
These diagnostic tests are not only useful in econometrics but also in many other fields where linear regression is used, which we will...
Read more >
A DIAGNOSTIC TEST FOR NONLINEAR SERIAL ...
The simulations indicate that the test has substantial power for many models. In addition, theoretical and empirical results are presented which show that ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found