Re: [R] predict() works with the design matrix but throws error with some rows of that matrix

2015-11-20 Thread Damir Cosic
Peter, this is extremely helpful. It is my first time using model.matrix() and I was not very clear about it.Thank you for clarifying it! It also helped me figure out how to do out-of-sample prediction. I add it here in case someone else needs help with this. oos.df<-data.frame(x=c(0,1), z=factor

Re: [R] predict() works with the design matrix but throws error with some rows of that matrix

2015-11-20 Thread Damir Cosic
Right on! I was using the expression for binomial logit. Thank you so much! On Fri, Nov 20, 2015 at 12:23 PM, peter dalgaard wrote: > > > On 20 Nov 2015, at 17:17 , Damir Cosic wrote: > > > > > > To do the same with matrix multiplication, I use the expression > 1/(1+exp(-xb)): > > > > head(1/(

Re: [R] predict() works with the design matrix but throws error with some rows of that matrix

2015-11-20 Thread peter dalgaard
> On 20 Nov 2015, at 17:17 , Damir Cosic wrote: > > > To do the same with matrix multiplication, I use the expression > 1/(1+exp(-xb)): > > head(1/(1+exp(-(cbind(c(1), mm) %*% coef(m)[2,] > > which should produce the third column above, but it doesn't: > I'm rusty on this, but I suspec

Re: [R] predict() works with the design matrix but throws error with some rows of that matrix

2015-11-20 Thread peter dalgaard
On 20 Nov 2015, at 10:07 , peter dalgaard wrote: >> >> On 20 Nov 2015, at 04:53 , Damir Cosic wrote: >> >> Hello, >> >> I am having problems with predict() after a multinomial logit regression by >> multinom(). I generate a design matrix with model.matrix() and use it to >> estimate the mode

Re: [R] predict() works with the design matrix but throws error with some rows of that matrix

2015-11-20 Thread peter dalgaard
> On 20 Nov 2015, at 04:53 , Damir Cosic wrote: > > Hello, > > I am having problems with predict() after a multinomial logit regression by > multinom(). I generate a design matrix with model.matrix() and use it to > estimate the model. Then, if I pass the entire design matrix to predict(), > it

[R] predict() works with the design matrix but throws error with some rows of that matrix

2015-11-19 Thread Damir Cosic
Hello, I am having problems with predict() after a multinomial logit regression by multinom(). I generate a design matrix with model.matrix() and use it to estimate the model. Then, if I pass the entire design matrix to predict(), it returns the same output as fitted(), which is expected. But if I