[R] predicted values after fitting gamma2 function
Steven Matthew Anderson
AdAstra69 at me.com
Fri Jun 26 05:30:17 CEST 2009
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:
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:
VGLM linear loop 1 : coefficients =
3.231473495, 0.597085743, -0.195591168
...
VGLM linear loop 20 : coefficients =
3.663316903, 0.897355891, -0.620449146
log(mu) log(shape)
(Intercept) 3.6633169 0.8973559
MidPoint -0.6204491 0.0000000
Call:
vglm(formula = Count ~ MidPoint, family = gamma2, data = modl.subset,
trace = TRUE, crit = "c")
Pearson Residuals:
Min 1Q Median 3Q Max
log(mu) -1.4846 -0.715285 -0.15436 0.61641 2.17298
log(shape) -5.8348 -0.099617 0.42094 0.61865 0.70901
Coefficients:
Value Std. Error t value
(Intercept):1 3.66332 0.131643 27.8277
(Intercept):2 0.89736 0.138591 6.4749
MidPoint -0.62045 0.047505 -13.0607
Number of linear predictors: 2
Names of linear predictors: log(mu), log(shape)
Dispersion Parameter for gamma2 family: 1
Log-likelihood: -276.0009 on 181 degrees of freedom
Number of Iterations: 20
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)).
Steven Matthew Anderson
Anderson Research, LLC
Statistical Programming and Analysis
SAS (R) Certified Professional
AdAstra69 at mac.com
Ad Astra per Aspera
שָׁלוֹם
More information about the R-help
mailing list