Error in allvalues[[i%%length(allvalues) + 1]] : subscript out of bounds

2 replies [Last post]
tbates's picture
Offline
Joined: 07/31/2009

Hi,
getting this error, which is not very informative as to its source: The problem is a mis-use of rnorm which passes in an numeric(0), i.e. empty array.

Would be nice if we could say "Error in path from "Read7N": Empty list passed in for values : values must contain at least one number)"

Error in allvalues[[i%%length(allvalues) + 1]] : subscript out of bounds

Any clues as to how it could be made more diagnostic?

FYI: This is the path model generating it

test <- mxModel("TEST", type="RAM",
		manifestVars = manifests,
		latentVars = c("Reading","Origin", "Achieved"),
	#Make up latent Origin
		mxPath(from="PaternalSESfac"      , to="Origin"             , arrows=1, free=T, values=rnorm(.7)),
		mxPath(from="HousingTenure7fac"   , to="Origin"             , arrows=1, free=T, values=rnorm(.7)),
		mxPath(from="NumberRooms7n"       , to="Origin"             , arrows=1, free=T, values=rnorm(.7)),
	#Make up latent Reading
		mxPath(from="Reading"             , to="Read7n"             , arrows=1, free=T, values=rnorm(.5)),
		mxPath(from="Reading"             , to="ReadingRating7fac"  , arrows=1, free=T, values=rnorm(.5)),
		mxPath(from="Reading"             , to="ReadingLevel7fac"   , arrows=1, free=T, values=rnorm(.5)),
    #Make up latent Achieved
		mxPath(from= "Achieved"             , to=  "SES42fac"       , arrows=1, free=T, values=rnorm(.4)),
		mxPath(from="Achieved"           , to=   "Tenure42fac"      , arrows=1, free=T, values=rnorm(.4)),
		mxPath(from="Achieved"             , to="IncomeLog"         , arrows=1, free=T, values=rnorm(.4)),
    #Latent connections
	    mxPath(from="Origin"              , to="Reading"            , arrows=1, free=T, values=rnorm(.3)),
	    mxPath(from="Origin"              , to="Achieved"           , arrows=1, free=T, values=rnorm(.3)),
	    mxPath(from="Reading"              , to="Achieved"          , arrows=1, free=T, values=rnorm(.3)),
   	 #Bivariate paths for manifests
		mxPath(from=manifestsOrigin, connect="unique.bivariate"     , arrows=2, free=T, values=rnorm(1)),
 
	# what do I need for my residual, or my fixed variance?
        mxPath(from="Read7n"           , arrows=2, free=T, values=rnorm(.3)),
		mxPath(from="ReadingRating7fac", arrows=2, free=T, values=rnorm(.3)),
 		mxPath(from="ReadingLevel7fac" , arrows=2, free=T, values=rnorm(.3)),
 
 		mxPath(from="SES42fac"   , arrows=2, free=T, values=rnorm(.3)),
		mxPath(from="Tenure42fac", arrows=2, free=T, values=rnorm(.3)),
		mxPath(from="IncomeLog"  , arrows=2, free=T, values=rnorm(.3)),
     #Data from covariance matrix
        mxData(dfTEST, type="cov", numObs = 18558)
)
 
test <- mxRun(test); summary(test)

mspiegel's picture
Offline
Joined: 07/31/2009
Oops. I added error checking

Oops. I added error checking for 0 length arguments to mxPath().

tbates's picture
Offline
Joined: 07/31/2009
Error in A_free[to, from] <- nextfree : subscript out of bounds

This is another one that could helpfully point to the path which is (in this case) mucking up the asymmetric matrix somehow

# Error in A_free[to, from] <- nextfree : subscript out of bounds