r/excel • u/Sweet_Ambition_7215 • 21d ago
solved Excel data analysis question: regression-LINEST() function returns error
Hi everyone. I'm working on a data science project for economics and could really use some help :)
I need to collect some data from WDI and adjust it. But some of the original data is missing and appears as "..". When I apply the adjustment formula, the corresponding cells return "#VALUE!".
When I try to run the regression using excel's data analysis, I get an error saying "Input range contains non-numeric data".
I just asked AI and it suggested leaving the cells containing "#VALUE!" blank. But after doing that I now get another error: "LINEST() function returns error. Please check input ranges again."
I also noticed that one of the adjusted values is "-2E-05". I tried changing its cell format to Number, but the regression still doesn't work.
Does anyone have any idea how I can fix them? Thanks!
1
5
u/Curious_Cat_314159
128
21d ago
edited 21d ago
•
This is really a stat question, not so much an Excel question. Yes, LINEST does not tolerate empty and non-numeric cells.
I am not a professional stat person. And in my experience, you might not find one at r/askstatistics, where this question might belong.
But what I do in such cases (related time-series data) is: I replace the empty or non-numeric values with a formula that is a linear interpolation of valid surrounding cells.
Where there is only on empty or non-numeric value (in E20, e.g.), that is as simple as =AVERAGE(E19, E21).
For multiple empty or non-numeric values (in E19:E21, e.g.), I use FORECAST in a form like the following in E19:
=FORECAST(ROW(A2), CHOOSE({1,2}, E$18, E$22), CHOOSE({1,2}, 1, 5))
EDIT.... In your case, where you have consecutive numbers in a
parallel column (year numbers in A18:A22, e.g.), you might write:
=FORECAST($A19, CHOOSE({1,2}, E$18, E$22), CHOOSE({1,2}, $A$18, $A$22))The use of relative and semi-absolute references allows the formula to be copied down and across.
The use of CHOOSE might be old-school (Excel 2010). There might be a better way to do the same thing in modern versions of Excel.
Caveat: Beware of adjacent cells that cross categories. For example, it would be dubious to "interpolate" between Germany 2019 and UK 2011.
1
u/pdf_to_excel_nerd
1
21d ago
•
Two things are probably going on. LINEST and the Data Analysis regression tool can't handle text, errors or empty strings anywhere in the ranges, and if your adjustment formula returns "" for the missing years that counts as text, not blank. Also the rows have to line up, so you can't just blank one cell in X or Y. You need to drop the whole row (both X and Y) wherever a value is missing.
Easiest fix: make a copy of the data, filter the ".." rows out, paste values only into a clean block, and run the regression on that. Or wrap the adjustment in IFERROR and use FILTER to build the clean range. The -2E-05 is fine by the way, it's just -0.00002 shown in scientific notation, and it's a real number so it won't break anything.
If you ever move this to LibreOffice or CSV, pandas with dropna() does the same cleanup in one line.
1
u/Decronym 21d ago edited 21d ago
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.
Beep-boop, I am a helper bot. Please do not verify me as a solution.
8 acronyms in this thread; the most compressed thread commented on today has 27 acronyms.
[Thread #49672 for this sub, first seen 12th Nov 2026, 16:08] [FAQ] [Full list] ^[Contact] [Source code]
1
u/frazorblade 4 21d ago
I’ve been through this exercise before and ended up creating my own VBA UDF for a non-contiguous ranges version of LINEST, but that was before we got array formulas.
The simple answer is you have to remove those values, or in your case the entire rows and essentially treat those rows as outliers.
You could write an array formula that filters out the non-numeric data into a new range and run LINEST on that, or do it within the LINEST formula.
Something like this =FILTER(A2:A10, ISNUMBER(A2:A10)) will get you started.
1

•
u/AutoModerator 21d ago
/u/Sweet_Ambition_7215 - Your post was submitted successfully.
Once your problem is solved, reply to the answer(s) saying
Solution Verifiedto close the thread.Follow the submission rules -- particularly 1 and 2. To fix the body, click edit. To fix your title, delete and re-post.
Include your Excel version and all other relevant information
Failing to follow these steps may result in your post being removed without warning.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.