[R] partitioning data [SEC=UNCLASSIFIED]

Crombie, Joe Joe.Crombie at brs.gov.au
Tue Oct 16 06:39:15 CEST 2007


Hi Stephen,

Check the help for predict.glm().  The argument for passing new data is
actually 'newdata', as in:

> pred =  predict(glm.model, newdata=form[150001:200000,-1], 
> type="response")
 
Cheers  Joe

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of stephenc at ics.mq.edu.au
Sent: Tuesday, 16 October 2007 5:30 AM
To: r-help at stat.math.ethz.ch
Subject: [R] partitioning data

I am trying to train on part of my data and test on another part:

> glm.model = glm(as.factor(h_finished) ~ . , family=binomial,
data=form[1:150000,])
> pred =  predict(glm.model, data=form[150001:200000,-1],
> type="response") t = table(pred, form[150001:200000,1])
Error in table(pred, form[150001:2e+05, 1]) :
        all arguments must have the same length

but try as I might my pred has too many lines:

> length(pred)
[1] 150000
> length(form[150000:200000, 1])
[1] 50000

[150000:200000, 1] works in the table function and indeed immediately
above. How can I make the [150000:200000, 1] work the predict function?

______________________________________________
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.

------IMPORTANT - This message has been issued by The Department of Agriculture, Fisheries and Forestry (DAFF). The information transmitted is for the use of the intended recipient only and may contain confidential and/or legally privileged material. It is your responsibility to check any attachments for viruses and defects before opening or sending them on. 

Any reproduction, publication, communication, re-transmission, disclosure, dissemination or other use of the information contained in this e-mail by persons or entities other than the intended recipient is prohibited. The taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. If you have received this e-mail in error please notify the sender and delete all copies of this transmission together with any attachments. If you have received this e-mail as part of a valid mailing list and no longer want to receive a message such as this one advise the sender by return e-mail accordingly. Only e-mail correspondence which includes this footer, has been authorised by DAFF 
------



More information about the R-help mailing list