I'm trying to debug an issue I'm having with the LINEST function. It appears that I'm getting different results depending on version. Particularly Excel 2007 vs. later versions.
For....reasons... I am attempting to produce a quadratic regression that uses only a subset of the values. The trick is that subset can change dynamically based on user input.
Here's the data for the particular case where I identified the bug:
Y keep x x^2
1 1 .0001 .00000001
2 1 .0001 .00000001
3 1 .0024 .00000576
4 1 .0024 .00000576
5 1 .0037 .00000729
6 0 0 0
7 0 0 0
8 0 0 0
9 0 0 0
10 0 0 0
I am using the keep variable to produce the intercept. Here's the actual function I'm using to get the coefficients:
b2: LINEST(Table[y], Table[[keep]:[x^2]], FALSE, FALSE)
b1: INDEX(LINEST(Table[y], Table[[keep]:[x^2]], FALSE, FALSE),2)
b0: INDEX(LINEST(Table[y], Table[[keep]:[x^2]], FALSE, FALSE),3)
This seems to work correctly in later versions of excel and I get a value of 1588628.76 for b2. In Excel 2007, I'm getting a value of 0. Clearly that is a problem.
I have not been able to find any documented differences in the implementation of LINEST between versions. Is anyone aware of what the difference is and how I might be able to make this function robust to version differences?
After a bit more thought, I decided it best to just revert to the math to ensure a robust solution. Here's what I used:
b2: =INDEX(MMULT(MMULT(MINVERSE(MMULT(TRANSPOSE(Table[[keep]:[x^2]]),Table[[keep]:[x^2]])),TRANSPOSE(Table[[keep]:[x^2]])),Table[y]),3)
b1: =INDEX(MMULT(MMULT(MINVERSE(MMULT(TRANSPOSE(Table[[keep]:[x^2]]),Table[[keep]:[x^2]])),TRANSPOSE(Table[[keep]:[x^2]])),Table[y]),2)
b0: =INDEX(MMULT(MMULT(MINVERSE(MMULT(TRANSPOSE(Table[[keep]:[x^2]]),Table[[keep]:[x^2]])),TRANSPOSE(Table[[keep]:[x^2]])),Table[y]),1)
Related
I have a practice column with these values in excel
apple
0 1 1/2
1 2 1/4
2 3 3/4
Excel turns these values into Fractions, so the output is like this:
app
0 1.50
1 2.25
2 3.75
All I am trying to do is a find/replace so the output turns into this
app
0 1
1 2
2 3
I've tried all kinds of things, but cant get it to work. I know how to do the find/replace part, just not how to remove the decimals or better yet, the fractions.
This are two different versions of turning the fractions into string values
fraction_df=df.astype({'app':'string'})
df['app']=df['app'].astype('string')
and then I tried to run find/replace
df=df.replace(['1/2','3/4','1/3'], '', regex=True)
A simple problem, but I can't seem to figure it out
To convert 1.5 to 1 do the following:
df['app'] = pd.to_numeric(df['app']).astype(int).astype(str)
To convert 1 1/2 to 1.5:
df['app'] = (df['app']
.str.extract('(?P<a>\d+)\s+(?P<b>\d+)/(?P<c>\d+)')
.astype(int).eval('a+b/c')
)
I would like to create a random, square table of 0's and 1's like so
0 1 0
0 0 1
0 1 0
but only bigger (around 14 x 14). The diagonal should be all 0's and the table should be symmetric across the diagonal. For example, this would not be good:
0 1 1
0 0 0
0 1 0
I would also like to have control over the number of 1 's that appear, or at least the probability that 1's appear.
I only need to make a few such tables, so this does not have to be fully automated by any means. I do not mind at all doing a lot of the work by hand.
If possible, I would greatly prefer doing this without coding in VBA (small code in cells is okay of course) since I do not know it at all.
Edit: amended so as to return a symmetrical array, as requested by the OP.
=LET(λ,RANDARRAY(ξ,ξ),IF(1-MUNIT(ξ),GESTEP(MOD(MMULT(λ,TRANSPOSE(λ)),1),1-ζ),0))
where ξ is the side length of the returned square array and ζ is an approximation as to the probability of a non-diagonal entry within that array being unity.
As ξ increases, so does the accuracy of ζ.
My goal is to count and potentially conditionally format the occurrences when a certain number of days pass with 0 sales.
I am trying to return the number of times 0 is repeated consecutively 3 or more times. So for this example I would like to see the return value of 3. So far I can't wrap my brain around how to do this, any ideas?
1
5
0
0
0
0
0
2
0
0
1
0
2
0
0
0
5
0
0
0
0
Thanks!
So #Barry Houdini's method applied to this problem would give
=SUM(--(FREQUENCY(IF(A1:A21=0,ROW(A1:1A21)),IF(A1:A21>0,ROW(A1:A21)))>=3))
entered as an array formula using CtrlShiftEnter
If you wanted to make it more dynamic and exclude blanks you could use
=SUM(--(FREQUENCY(IF(A1:A100<>"",IF(A1:A100=0,ROW(A1:A100))),IF(A1:A100>0,ROW(A1:A100)))>=3))
How about you make a help column with a simple sum formula with a "window" of three rows (or whatever you need). Then you conditionally format all values which are 0 in that column. That should provide you with the information you are looking for.
I am just using formulas in excel and was wondering how you could count all the 0s until a 1 is reached, and then start the process over again, based on subject number. If this is not possible simply with formulas, how could I write a VBA code for this?
Right now I am trying to use,
=IF(OR(F4=0,F3=1),"",COUNTIFS($A$2:A2, $A$2,$F$2:F2,0)-SUM($I$2:I2))
which I input in I3 and I change the COUNTIFS($A$#:A#, $A$#...) part for each subject number.
This seems to work with the exception of the last grouping, as it won't output a number before the next subject.
Example Data:
subid yes number_yes(output)
1 0
1 0
1 0 3
1 1
1 0 1
1 1
1 0
2 0
2 0 2
2 1
2 0
2 0
3
etc.
A blank cell is numerically zero and that is one of your accepted conditions. Differentiate between blanks and zero values.
=IF(and(f4<>"", OR(F4=0,F3=1)),"",COUNTIFS($A$2:A2, $A$2,$F$2:F2,0)-SUM($I$2:I2))
Based on #Jeeped answer. If you use -SUMIF($A$2:A2,A3,$I$2:I2) instead of -SUM($I$2:I2) you don't need to adjust this part for each subject number. Just use the following formula in I3 and copy it down.
=IF(AND(F4<>"",OR(F4=0,F3=1)),"",COUNTIFS($A$2:A3,A3,$F$2:F3,0)-SUMIF($A$2:A2,A3,$I$2:I2))
Note that I also changed the second parameter in the COUNTIFS to A3.
I'm struggling with MODE I have some surveys I am analysing.
Currently using =MODE(IF(AJ15:AJ24<>0,AJ15:AJ24))
One Question's answers are:
0
0
0
0
0
0
0
1
2
3
the formula is giving #VALUE error as there are no repeated numbers. Can anyone suggest how to get round this so it doesn't show an error.
=iferror(MODE(IF(AJ15:AJ24<>0,AJ15:AJ24)),"")
If your formula does not result in an error then the result of your formula is displayed. When your formula generates an error, "" or nothing is displayed.