From: Achim Zeileis <Achim.Zeileis_at_wu-wien.ac.at>

Date: Wed 08 Jun 2005 - 00:49:22 EST

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jun 08 01:00:38 2005

Date: Wed 08 Jun 2005 - 00:49:22 EST

On Tue, 7 Jun 2005 09:48:13 -0400 (EDT) Anders Schwartz Corr wrote:

> My attempt to test a model using ordglm code is running into problems,

*> and I thought if you have a moment you might illucidate the situation.
*

Please indicate which package you are using, I guess you are referring to ordglm() in Jim Lindsey's gnlm package.

> Here is the data:

*>
**> http://www.people.fas.harvard.edu/~corr/6.4.05.RData
*

You are kidding, right? A 4.9M file with some 30 objects for an example like the one below?? *Please* do read the posting guide.

> Here is the code:

*>
**> # I coerce tcn8 matrix data to a vector, because ordglm will not
**> # accept
**> matrix data.
**> y<-as.vector(tcn8[,62])
**> x<-as.vector(tcn8[,60])
**> wt<-as.vector(tcn8[,61])
**> cbind(y,x,wt)->tc
**> colnames(tc) <- c("y","x","wt")
**> ordglm(y ~ x, weights=wt, data=tc, link = "logit")
**>
**> Here is the output:
**>
**> > y<-as.vector(tcn8[,62])
**> > x<-as.vector(tcn8[,60])
**> > wt<-as.vector(tcn8[,61])
**> > cbind(y,x,wt)->tc
**> > colnames(tc) <- c("y","x","wt")
**> > ordglm(y ~ x, weights=wt, data=tc, link = "logit")
**> Error in model.frame.default(mt, data, na.action = na.fail) :
**> `data' must be a data.frame, not a matrix or array
**>
**> Perhaps it is a problem of having NAs and NaNs in my data? I
**> appreciate any pointers. Do I need to set model.frame first?
*

I think the error message is very explicit: `data' (in your case the object `tc') needs to be a "data.frame", but it is a "matrix". So you did a good job in replacing the matrix `tcn8' with the matrix `tc'.

You can coerce it relatively easy to a "data.frame" using as.data.frame(). Then ordglm() will complain about NAs, which you could for example na.omit(). But then ordglm() says that `y' has to be numeric which made me realize that your variables `y', `x' and `wt' are in fact "character"s.

In summary this means:

- Hold your variables in an appropriate format, e.g., numeric vectors in a "data.frame". Maybe some basic R manuals like "An Introduction to R" can help here.
- Read the man page of ordglm() and also read the error messages, they are very informative.
- Read the posting guide before posting to the lists.

hth,

Z

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Jun 08 01:00:38 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:32:27 EST
*