Rounding error ?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Rounding error ?

drfg2008
SPSS V17 / Vista

Rounding error

I have the following syntax

input program.
loop HH_nr =1 to 100 by 1.
end case.
end loop.
end file.
end input program.
exe.

comp personen =RV.BINOM(10,0.5).
COMP hh_einkommen=RV.NORMAL(2500,100).
EXECUTE .

COMPUTE durchschnittseinkommen=hh_einkommen / (1+(0.7* (personen -1))).
EXECUTE.


The first few lines are:

1 8 2323 393,77869
2 4 2384 769,02137
3 7 2601 500,25118
4 4 2473 797,85974
5 4 2402 774,81290
6 7 2469 474,72022


but Excel (and my calculator) yield the following results for "income".

393,7288136
769,0322581
500,1923077
797,7419355
774,8387097
474,8076923
668,4210526


Question: Are there problems with rounding errors in SPSS?

Thank you
Dr. Frank Gaeth

Reply | Threaded
Open this post in threaded view
|

Re: Rounding error ?

Jon K Peck
There should be no rounding errors (other than the inevitable fraction representation in any floating point hardware).  How did you transfer the numbers to Excel?  The printed values from SPSS by default are not showing all 16-17 significant figures, so you will get a different result if you use less than the full precision in Excel.

Here is your calculation done after exporting the actual SPSS dataset to Excel and adding a column with the calculation done in Excel.

HH_nr        personen        hh_einkommen        durchschnittseinkommen                
1        4        2509.889179        809.641671                809.641671
2        2        2478.245698        1457.791587                1457.791587
3        3        2580.955828        1075.398261                1075.398262
4        6        2559.882314        568.862736                568.862736
5        3        2651.888882        1104.953701                1104.953701
6        6        2589.740341        575.497854                575.497854

Jon Peck
Senior Software Engineer, IBM
[hidden email]
312-651-3435




From:        drfg2008 <[hidden email]>
To:        [hidden email]
Date:        02/26/2011 10:46 AM
Subject:        [SPSSX-L] Rounding error ?
Sent by:        "SPSSX(r) Discussion" <[hidden email]>




SPSS V17 / Vista

Rounding error

I have the following syntax

input program.
loop HH_nr =1 to 100 by 1.
end case.
end loop.
end file.
end input program.
exe.

comp    personen        =RV.BINOM(10,0.5).
COMP hh_einkommen=RV.NORMAL(2500,100).
EXECUTE .

COMPUTE durchschnittseinkommen=hh_einkommen / (1+(0.7* (personen -1))).
EXECUTE.


The first few lines are:

1       8       2323    393,77869
2       4       2384    769,02137
3       7       2601    500,25118
4       4       2473    797,85974
5       4       2402    774,81290
6       7       2469    474,72022


but Excel (and my calculator) yield the following results for "income".

393,7288136
769,0322581
500,1923077
797,7419355
774,8387097
474,8076923
668,4210526


Question: Are there problems with rounding errors in SPSS?

Thank you

-----
FUB

--
View this message in context:
http://spssx-discussion.1045642.n5.nabble.com/Rounding-error-tp3401590p3401590.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD

Reply | Threaded
Open this post in threaded view
|

Re: Rounding error ?

drfg2008
o.k. now I see. I export the income with no decimals. My mistake. Thank you
Dr. Frank Gaeth