Nerd of Darkness
2013-Dec-16 01:04 UTC
[R] possible overflow/underflow error causing NaN in .trval when invoking trmat with degree 4
Hello all, I have two copies of the same data; I want to compare trend matrices for degrees 3 and 4, so I name the copies "triplo" and "quatro".> triploSurface<-surf.ls(3,triplo) > triploMat<-trmat(triploSurface,-150.0000,150.0000,-150.0000,150.0000, 300)[This produces the expected triploSurface and triploMat results and can be graphed.]> quatroSurface<-surf.ls(4,quatro) > quatroMat<-trmat(quatroSurface, -150,150,-150,150, 300)Error in .trval(object, x, y) : NA/NaN/Inf in foreign function call (arg 5) [This produces an apparently correct quatroSurface result but does not produce any quatroMat result, just an error message.] I think this is an overflow or underflow - i.e. I think I'm demanding too much precision from the numbers. The tail of the quatroSurface looks like this: 0.0238192479364594, NaN, -0.785397268575074, 0.258979557395067, 0.416633191734089, 0.48818709354019, 0.303158973109538, 0.0976576257799269, 0.0203250815697912, -0.24213596942919, -0.0892132957309183, 0.975147904903443, 0.176878824295857, 0.0452657395908427, 0.0635179944972253, NaN, NaN), beta = c(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN), wz = c(NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN, NaN), rx = c(-126.5463, 108.6537 ), ry = c(-128.3801, 135.6199), call = quote(surf.ls(np = 4, x = quatro))), .Names = c("x", "y", "z", "np", "f", "r", "beta", "wz", "rx", "ry", "call"), class = "trls") The tail of the triploSurface looks similar, but all its values are well-behaved without any NaN problems 0.0351979976095227, -1.36626369439296, -0.280695994275675, 0.40206378062954, 0.0633634395824397, 0.00569741981675165, -0.513420054181769 ), beta = c(106.769396311982, -2.24615036637542, 0.156526774285082, 1.80159305847556, -3.09710659318204, -0.524195072882179, 2.70901190859632, -1.02836821322134, 4.80130168312262, 2.37977833647081), wz c(-0.0728849622348235, -0.186585406288444, 0.415603707564799, 0.233806471348331, 0.330715976834796, -0.0613265591678669, -0.242396311982404, -1.18446693543041, -0.0285404338742694, 1.01075743539955, -0.210496969514736, -0.0515734891310018, 0.0473874764761177 ), rx = c(-126.5463, 108.6537), ry = c(-128.3801, 135.6199), call = quote(surf.ls(np = 3, x = triplo))), .Names = c("x", "y", "z", "np", "f", "r", "beta", "wz", "rx", "ry", "call"), class = "trls") There seem to be two obvious possibilities: A - I could get a well-behaved result with degree 4 if only I could manage to use the correct commands. B - This data doesn't have the right characteristics to support a degree 4 trend and thus I should limit myself to degree 3. Any comments are welcome. Thanks.