[R] bootpred for multinomial

Uwe Ligges ligges at statistik.tu-dortmund.de
Wed Jun 9 16:14:36 CEST 2010



On 09.06.2010 15:15, azam jaafari wrote:
> Thank you very much
>
> I used bootpred for multinomial logistic reg. similar below:
> theta.fit<- function(x,y){lsfit(x,y)}
>     theta.predict<- function(fit,x){
>                 cbind(1,x)%*%fit$coef
>                 }
>     sq.err<- function(y,yhat) { (y-yhat)^2}
>     results<- bootpred(x,y,20,theta.fit,theta.predict,
>       err.meas=sq.err)
>
> x=data
> mlr=multinom(y~x1+x2+x3+x4+x5, data)
>
> after run results:
>> results<- bootpred(data, mlr,50,theta.fit,theta.predict, sq.err)
> Error in as.vector(data) :
>    no method for coercing this S4 class to a vector
>
> Is it incorrect?


First guess: bootpred() is from the "bootstrap" packages (you just told 
about nnet).


 From that help page (?bootpred):
x 	a matrix containing the predictor (regressor) values. Each row 
corresponds to an observation.

And your data is some S4 class object, obviously, but bootpred expects a 
matrix according to the docs ....

Uwe Ligges


> Azam
>
>
>
>
>
>
>
> --- On Wed, 6/9/10, Uwe Ligges<ligges at statistik.tu-dortmund.de>  wrote:
>
>
> From: Uwe Ligges<ligges at statistik.tu-dortmund.de>
> Subject: Re: [R] bootpred for multinomial
> To: "azam jaafari"<azamjaafari at yahoo.com>
> Cc: "R-help"<r-help at r-project.org>
> Date: Wednesday, June 9, 2010, 5:46 AM
>
>
>
>
> On 09.06.2010 13:26, azam jaafari wrote:
>> I applied bootpred for multinomial logistic reg. (with nnet package). I used same as theta.fit and theta.predict of R for my data. but give me error. Can I do this with
>> response vriable;7 levels
>> predictor variables:5 (1 classifier, 4 continuous)?
>>
>> Thanks alot
>> Azam
>>
>>
>>
>>
>>      [[alternative HTML version deleted]]
>>
>>
>>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
> Yes, PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented,
> minimal, self-contained, reproducible code.
>
> otherwise it is hard to help without your code and without any error
> message.
>
> Uwe Ligges
>
>
>
>
>
> 	[[alternative HTML version deleted]]
>
>
>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list