[R] (sans objet)
    Prof Brian Ripley 
    ripley at stats.ox.ac.uk
       
    Tue Jun 15 14:50:16 CEST 2004
    
    
  
On Tue, 15 Jun 2004, Benjamin Esterni wrote:
> I have a problem with the dr function: "dimension reduction".
It seems that you are using it inappropriately.
> I give you my example, and i'll be pleased to read your comments.
> 
> #let be X a matrix 50*100:
> 
> library(dr);
You should not be terminating lines with ;.  This is R, not C.
> X<- matrix(rnorm(50*100,5,1),50,100);
> 
> #and let be Y a vector response:
> Y<- sample(0:1,50,replace=T);
> 
> #I choose (for the expérience, but in reality i don't have it) a few variables #which are censed to explain Y:
> 
> index<- sample(1:100,10);
> X[Y==1,index]<-10*X[Y==1,index];
> 
> #so now I want to proceed to a logistic regression, but I don't know the vector #"index". So I have to reduce the dimension of X, and that's why I use the function #"dr" (dr package).
> 
> model<- dr(Y~X,family="binomial",method="phdy");
> 
> edr<- dr.direction(model);
> 
> #And now my problem: I hope that edr is a matrix constructed with linear
> #combinaison of X, prinipally the "index" vectors of X. But in reality
> it's not the #situation:
Your variables have no predictive power at all.  Look at
pairs(cbind(Y, edr))
> library(nnet);
> fit<-multinom(Y~.,data=data.frame(edr));
Take a look at this.  The fit is useless, because your variables are.
> pred<-predict(fit,data.frame(edr));
> table(Y,pred)
> 0  21
> 0  19
Given that Y has 50 values and that table labels dims, how on earth did 
you get that?
-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595
    
    
More information about the R-help
mailing list