Message Boards Message Boards

1
|
2928 Views
|
2 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Unexpected results from LinearModelFit

Posted 2 years ago

I'm struggling to understand why Mathematica 13.1 gives multiple linear regression coefficients that are greatly different from the Data Analysis package in Excel and Maple's LinearFit function.

I'm assisting a colleague who is using Excel to find a model for data with 4 independent variables and 1 response variable. All she had access to was Excel, and I attempted to extol the virtues of Mathematica.

Assuming she had selected a reasonable approach, (exponential fitting by transforming the response variable to ln(y)), I tried to duplicate that effort in Mathematica. (Then I would go on to try nonlinear regression.)

But I came up with regression coefficients that were vastly different. I assumed Excel was wrong, so I used Maple to confirm. Nope. Maple agrees with Excel. Even the multiple linear regression calculator on Statistics Kingdom agrees with Excel and Maple. https://www.statskingdom.com/410multilinearregression.html

Notebook is attached. Please see the "subsubsection" entitled "exponential". A screenshot from Excel is embedded for comparison. I used the "ParameterTable" option to show the coefficients.

So, I think that Mathematica is reporting what I don't understand. Does anyone have any ideas?

Thanks!

POSTED BY: Glen Deering
2 Replies
Posted 2 years ago

Thank you!

I didn't even think of using ReplaceAt. I had thought Delete then AppendTo was changing the list.

Well, heck!

That was simple...

POSTED BY: Glen Deering
Posted 2 years ago

Hi Glen,

There is an error during the evaluation of dataTransformed so it is not transformed.

dataTransformed == data
(* True *)

Try

dataTransformed = ReplaceAt[data, y_ :> Log@y, {All, 5}] /. Indeterminate -> 0
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract