Thanks Bill, that worked great!!
> You ask:
# How can I use
> predict here, 'newdata'
>
> crashes
predict(m1,newdata=wolf$predicted);wolf # it doesn't work
To
>
> use predict() you need to give a fitted model object (here m1) and a
> *data
> frame* to specify the values of the predictors for which you want
>
> predictions. Here wolf$predicted is not a data frame, it is a
>
> vector.
What I think you want is
pv <- predict(m1, newdata =
>
> wolf)
That will get you linear predictors. To get probabilities
> you
> need to say so as
probs <- predict(m1, newdata = wolf,
> type =
> "response")
You can put these back into the data frame if
> you wish,
> e.g.
wolf <- within(wold, {
lpreds <-
>
> predict(m1, wolf)
probs <- predict(m1, wolf, type =
>
> "response")
})
Now if you look at
head(wolf)
you will
>
> see two extra columns.
-----Original Message-----
From:
> > ymailto="mailto:>
> > href="mailto:[email protected]">[email protected]"
>
> href="mailto:>
> href="mailto:[email protected]">[email protected]">>
> ymailto="mailto:[email protected]"
> href="mailto:[email protected]">[email protected]
>
> [mailto:> href="mailto:> ymailto="mailto:[email protected]"
> href="mailto:[email protected]">[email protected]">>
> ymailto="mailto:[email protected]"
> href="mailto:[email protected]">[email protected]] On
>
> Behalf Of Felipe Carrillo
Sent: Saturday, 26 June 2010 10:35
> AM
To: > ymailto="mailto:>
href="mailto:[email protected]">[email protected]"
>
> href="mailto:>
> href="mailto:[email protected]">[email protected]">>
> ymailto="mailto:[email protected]"
> href="mailto:[email protected]">[email protected]
Subject:
>
> [R] predict newdata question
Hi:
I am using a subset of the
> below
> dataset to predict PRED_SUIT for
the whole dataset but I am
> having trouble
> with 'newdata'. The model
was created with 153
> records and want to predict
> for 208 records.
[lots of stuff
>
>
> omitted]
wolf$prob99<-(exp(wolf$predicted))/(1+exp(wolf$predicted))
head(wolf);dim(wolf)
>
> # How can I use predict here, 'newdata'
>
> crashes
predict(m1,newdata=wolf$predicted);wolf # it doesn't
>
> work
Thanks for any hints
Felipe D. Carrillo
Supervisory
>
> Fishery Biologist
Department of the Interior
US Fish &
> Wildlife
> Service
California,
>
> USA
______________________________________________
>
> ymailto="mailto:> href="mailto:[email protected]">[email protected]"
>
> href="mailto:> href="mailto:[email protected]">[email protected]">>
> ymailto="mailto:[email protected]"
> href="mailto:[email protected]">[email protected] mailing list
>
> href="> >https://stat.ethz.ch/mailman/listinfo/r-help" target=_blank
> >> href="https://stat.ethz.ch/mailman/listinfo/r-help" target=_blank
> >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.
______________________________________________
> ymailto="mailto:[email protected]"
> href="mailto:[email protected]">[email protected] mailing list
> href="https://stat.ethz.ch/mailman/listinfo/r-help" target=_blank
> >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.
______________________________________________
[email protected] 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.