[R] Error: NA/NaN/Inf in foreign function call (arg 1)

Rainier Sabangan rainier_sabangan at yahoo.com
Thu Oct 22 03:37:42 CEST 2009


Hi,

Below is the code that is giving me this error message:

#===================================================================
#The code below results in error: Error: NA/NaN/Inf in foreign function #call (arg 1)
#===================================================================
A=rep(c(-1,1),8);B=rep(c(-1,-1,1,1),4);C=rep(c(-1,-1,-1,-1,1,1,1,1),2)
D=c(rep(-1,8),rep(1,8))
y=c(38.01697,42.04596,43.89677,47.78144,37.34869,41.90744,44.01468,47.96458,37.97263,41.83482,44.01936,48.12203,38.73267,42.92054,44.16163,48.88900)
bcols=c(1,2)
dcols=c(3,4)
locmodel=glm(y~A+B)
mlcoefs=locmodel$coef
res=locmodel$residuals
ressq=res^2
dispmodel=glm(ressq~C+D,family=Gamma(link = "log"))

#===================================================================
#The code below results in error message: 
# Warning message: In glm.fit(x = X, y = Y, weights = weights, start = 
# start, etastart = #etastart,  : algorithm did not converge
#===================================================================
A=rep(c(-1,1),8)
B=rep(c(-1,-1,1,1),4)
C=rep(c(-1,-1,-1,-1,1,1,1,1),2)
D=c(rep(-1,8),rep(1,8))
y=c(37.93499,42.19333,44.02388,48.04979,37.52459,41.90613,43.44424,47.81314,
 38.04942,42.06124,44.00249,47.89033,39.00372,40.47911,43.78126,48.55228)
locmodel=glm(y~A+B)
mlcoefs=locmodel$coef
res=locmodel$residuals
ressq=res^2
dispmodel=glm(ressq~C+D,family=Gamma(link = "log"))
#===============================

I researched on this error and it can be caused by missing values, which is not the case for this example. 
I would really appreciate any help that can be extended.

Rainier Sabangan
BGSU MSAS Student




More information about the R-help mailing list