On Jun 25, 2009, at 11:30 PM, Steven Matthew Anderson wrote:
Question: after fitting a gamma function to some data, how do I get
predicted values? I'm a SAS programmer, I new R, and am having
problems getting my brain to function with the concept of "object as
class ...". The following is specifics of what I am doing:
I'm trying to determine the pdf from data I have created in a
simulation.
I have generated frequency counts using the following:
Max.brks <- pretty(range(Max.Spread$Distance), 100)
Max.f<-hist(x=Max.Spread$Distance,
breaks=Max.brks,plot=FALSE )
Max.cnt<-as.data.frame(cbind(sim,Max.f$mids,Max.f$counts))
colnames(Max.cnt)<-c("Simulation","MidPoint","Count")
then I fit this to a gamma distribution function:
Using a non-base function without including the appropriate require()
or library() call is a bit like asking a SAS programmer to debug code
but not telling what PROC it's from;
modl<-
vglm
(Count
~
MidPoint
,gamma2
,data
=
subset(Max.cnt,select=(simulation,MidPoint,Count),trace=TRUE,crit="c")
print(coef(modl2,matrix=TRUE))
print(summary(modl2))
This produces the output:
snipped output
Now - how do I get this information to give me predicted values
given the same x-values I used in the experimental model (i.e. from
Max.brks <- pretty(range(Max.Spread$Distance), 100)).
Most regression functions in R, and vglm is no exception, have predict
methods. The default is to give back predictions for the data from
which the parameters were estimated, but if you want predictions on
specific new values there is a newdata option.
?predict.vglm
David Winsemius, MD
Heritage Laboratories
West Hartford, CT
______________________________________________
R-help@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.