[R] In da.norm Error: NA/NaN/Inf in foreign function call (arg 2)

mlz2+@pitt.edu mlz2+ at pitt.edu
Mon Oct 24 05:51:26 CEST 2005


I am conducting a simulation study generating multivariate normal data,
deleting observations to create a
data set with missing values and then using multiple imputation via
da.norm in Schafer's norm package.

>From da.norm, I get the following error message: "Error: NA/NaN/Inf in
foreign function call (arg 2)"
The frequency of the error message seems to depend on the ratio of n to p
and the percent of missingness.
for example, n=50, p=5, 50% missing, it fails about 9 in 10 runs. For
n=100, p=3, 50% missing it fails
about 1 in 10 runs.

I suspected that near-singularity of the starting covariance matrix might
be to blame, but I found instances
where the error message occurred, but the covariance was invertible.

Any suggestions as to the reason for the error or an alterative way to
generate the imputations?
Sample code is included below.
Thanks,
Melissa

I am using R 2.2.0 with norm 1.0-9 on Windows XP Professional.

#Sample code:
library(norm)
n<-50
p<-5
prob.miss<-.5
#generate complete data
x<-matrix(rnorm(n*p),nrow=n)
#create missing data
for (j in 1:p)
{miss<-rbinom(n,1,prob.miss)
for (i in 1:n){if (miss[i]==1) x[i,j]<-NA}}
#create imputations
seed<-1234
rngseed(seed)
s <- prelim.norm(x)
thetahat <- em.norm(s,showits=F)
da.norm(s,thetahat,steps=1000,showits=F,return.ymis=TRUE)




More information about the R-help mailing list