Skip to content
Prev 319749 / 398513 Next

try/tryCatch

here is the error:
Error in asMethod(object) : matrix is not symmetric [1,2]



metatrials, the function that i am attempting to convert with try/tryCatch,
gives me back a matrix with as many rows are there are simulations  (z) in
the aray with dim(x,y,z). with the data i attached, x is 500(number of
patients), y is 9 (these are covariates), and z is 500.


metatrials<-function(mydata){

a<-matrix(data=NA, nrow=dim(mydata)[3], ncol=5)
colnames(a)=c("sens", "spec", "corr", "sens_se", "spec_se")

for(ii in 1:dim(mydata)[3]){
    tmp<-mydata[,,ii]
    tmp1<-as.data.frame(tmp)
    names(tmp1)=c("persons", "d1", "tp", "fn", "fp", "fn", "detect", "d0",
"outcome")
    lm1<-lmer(outcome~0+d1+d0+(0+d1+d0 | persons), family=binomial,
data=tmp1, nAGQ=3)
    a[ii,1]=lm1 at fixef[1]
    a[ii,2]=lm1 at fixef[2]
    a[ii,3]=vcov(lm1)[1,2]/prod(sqrt(diag(vcov(lm1))))
    a[ii,4:5]=sqrt(diag(vcov(lm1)))

    }
    return(a)
}


######################


what i want is for the function to go on to the next data set in the array
and simply return an NA for that line in the metatrials results. so
basically, just keep going.


thanks so much for your help!


-Lisa
On Mon, Mar 18, 2013 at 4:24 PM, jim holtman <jholtman at gmail.com> wrote: