Message Boards Message Boards

GROUPS:

Import data from a .xlsx file and perform a regression analysis with Fit?

Posted 23 days ago
163 Views
|
3 Replies
|
2 Total Likes
|

I am working with a dataset, where I have 51 rows and 4 columns ( I am using SemanticImport to bring in my .xlsx document. ). I want to do some regression analysis, but cannot see how to convert the dataset into coordinates for Fit. How do you get the data into the necessary format?

Fit[{education[;; , "SpendPerPupil"], 
  education[;; , "8thMathScore"]}, x, x] is what I tried, but is obviously not right.
3 Replies

Giving some sample data would likely get you quicker and better help.

Hi Justin,

I'm not entirely sure what you're trying to do, but the attached notebook (which is based on something I put together while teaching myself how to use the fitting functions in conjunction with datasets) may give you some pointers.

One observation on your code is that, assuming your dataset is called "education", I believe you'll need to apply the function Normal to the dataset to transform it into a more conventional list as I don't think Fit operates on pure datasets. This could be easily achieved as follows...

Fit[{education[;; , "SpendPerPupil"]//Normal, education[;; , "8thMathScore"]//Normal}, x, x]

I hope this helps,

Ian

Attachments:
Posted 22 days ago

Thank you. I will look at that Notebook, Ian. I am looking at seeing how different predictors (teacher salary, class size, median household income) correlate with test scores (just out of curiousity). Plotting it in Excel, I saw that teacher salary/median salary is negatively correlated, which piqued my interest. I wanted to bring it into Mathematica to look more deeply.
Here are the first few lines of my table. Hope that helps make sense of what I am looking at.

Stat......... AverageStartSalary..... MedianIncome SpendPerPupil 8thMathScore

Alabama......... $38,477.00............. $44,765.00....... $9,236.00........... 268

Alaska........ $46,785.00................. $73,355.00 ...... $17,510.00......... 277

Arizona ..... $34,068.00 .......... $51,492.00 ....... $7,613.00 .......... 282

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