Thank you Bert, I wasn?t aware of ?str. The only mention of fitted-values is: $ maximum : atomic [1:1] -9824 ..- attr(*, "fitted.values")= num [1:3460] 1.39 1.3 1.3 1.32 1.27 ... When I try attr(mymodel$maximum, ?fitted.values?), I get the same results as attr(AIC(mymodel), ?fitted.values?), which is a list of number starting with (1.39 1.3 1.3 1.32 1.27 ?). I don?t see how these can be fitted values for the response variable, patents, which are larger numbers (30, 3, 48, 1, 2, 32, ?). Is this output not supped to represent the fitted values for patents? Another way to obtain fitted values would be using residuals.?pglm also includes residuals in its list of elements. However, str(mymodel) does not mention residuals. Does that mean it?s just not there? - Simon> On Apr 12, 2019, at 10:44 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote: > > ?fitted > ?predict > ## This is what one usually does, but I have not checked pglm. > > You also need to get friendly with ?str > > ... and probably also spend time with an R tutorial or two to become familiar with R modeling conventions. > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Fri, Apr 12, 2019 at 7:35 AM Simon Berrebi <simon at berrebi.net <mailto:simon at berrebi.net>> wrote: > Hello everyone, > > I am using the pglm function in R to fit a Poisson fixed-effects model. According to the documentation <https://cran.r-project.org/web/packages/pglm/pglm.pdf <https://cran.r-project.org/web/packages/pglm/pglm.pdf>>, the pglm object should have fitted.values. However, fitted.values(mymodel) returns "NULL". > > When I run AIC(mymodel) the AIC is followed by "attr(,"fitted.values")" and a long list of number. I have included an example below and attached a text file with the output. > > Are these fitted values? If so, is there a way to obtain them directly? Can I also get fitted-values based on a synthetic dataset (i.e. predict())? > > install.packages("pglm") > library(pglm) > > data("PatentsRDUS", package="pglm") > > > mymodel <- pglm(patents ~ log(rd) + as.numeric(year)+ I(log(capital72)*as.numeric(year)) , PatentsRDUS, > family = poisson(link=log), model = "within", index = c("cusip", "year")) > > fitted.values(mymodel) > AIC(mymodel) > > Cordially, > ? > Dr. Simon J Berrebi > Postdoctoral Fellow > Civil and Environmental Engineering > Georgia Institute of Technology > > > > > > > > > ______________________________________________ > R-help at r-project.org <mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code.[[alternative HTML version deleted]]
?fitted Read and follow. As I said, you appear to need to spend time with a tutorial. I do not provide this service, though others may. -- Bert On Fri, Apr 12, 2019 at 10:07 AM Simon Berrebi <simon at berrebi.net> wrote:> Thank you Bert, > > I wasn?t aware of ?str. The only mention of fitted-values is: > > $ maximum : atomic [1:1] -9824 > ..- attr(*, "fitted.values")= num [1:3460] 1.39 1.3 1.3 1.32 1.27 ... > > When I try attr(mymodel$maximum, ?fitted.values?), I get the same results > as attr(AIC(mymodel), ?fitted.values?), which is a list of number > starting with (1.39 1.3 1.3 1.32 1.27 ?). I don?t see how these can be > fitted values for the response variable, patents, which are larger numbers > (30, 3, 48, 1, 2, 32, ?). Is this output not supped to represent the fitted > values for patents? > > Another way to obtain fitted values would be using residuals.?pglm also > includes residuals in its list of elements. However, str(mymodel) does not > mention residuals. Does that mean it?s just not there? > > - Simon > > On Apr 12, 2019, at 10:44 AM, Bert Gunter <bgunter.4567 at gmail.com> wrote: > > ?fitted > ?predict > ## This is what one usually does, but I have not checked pglm. > > You also need to get friendly with ?str > > ... and probably also spend time with an R tutorial or two to become > familiar with R modeling conventions. > > Bert Gunter > > "The trouble with having an open mind is that people keep coming along and > sticking things into it." > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > On Fri, Apr 12, 2019 at 7:35 AM Simon Berrebi <simon at berrebi.net> wrote: > >> Hello everyone, >> >> I am using the pglm function in R to fit a Poisson fixed-effects model. >> According to the documentation < >> https://cran.r-project.org/web/packages/pglm/pglm.pdf>, the pglm object >> should have fitted.values. However, fitted.values(mymodel) returns "NULL". >> >> When I run AIC(mymodel) the AIC is followed by "attr(,"fitted.values")" >> and a long list of number. I have included an example below and attached a >> text file with the output. >> >> Are these fitted values? If so, is there a way to obtain them directly? >> Can I also get fitted-values based on a synthetic dataset (i.e. predict())? >> >> install.packages("pglm") >> library(pglm) >> >> data("PatentsRDUS", package="pglm") >> >> >> mymodel <- pglm(patents ~ log(rd) + as.numeric(year)+ >> I(log(capital72)*as.numeric(year)) , PatentsRDUS, >> family = poisson(link=log), model = "within", index = c("cusip", >> "year")) >> >> fitted.values(mymodel) >> AIC(mymodel) >> >> Cordially, >> ? >> Dr. Simon J Berrebi >> Postdoctoral Fellow >> Civil and Environmental Engineering >> Georgia Institute of Technology >> >> >> >> >> >> >> >> >> ______________________________________________ >> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> <http://www.r-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. > > >[[alternative HTML version deleted]]
You should ask the maintainer of the package about this: bug.report(package="pglm") or maintainer("pglm") should give you contact information. The help file for pglm seems all wrong - it says pglm's output has class "pglm" with components like "fitted.values", but the the example calls to pglm return things of class c("maxLik", "maxim", "list"). Bill Dunlap TIBCO Software wdunlap tibco.com On Fri, Apr 12, 2019 at 11:09 AM Simon Berrebi <simon at berrebi.net> wrote:> Thank you Bert, > > I wasn?t aware of ?str. The only mention of fitted-values is: > > $ maximum : atomic [1:1] -9824 > ..- attr(*, "fitted.values")= num [1:3460] 1.39 1.3 1.3 1.32 1.27 ... > > When I try attr(mymodel$maximum, ?fitted.values?), I get the same results > as attr(AIC(mymodel), ?fitted.values?), which is a list of number > starting with (1.39 1.3 1.3 1.32 1.27 ?). I don?t see how these can be > fitted values for the response variable, patents, which are larger numbers > (30, 3, 48, 1, 2, 32, ?). Is this output not supped to represent the fitted > values for patents? > > Another way to obtain fitted values would be using residuals.?pglm also > includes residuals in its list of elements. However, str(mymodel) does not > mention residuals. Does that mean it?s just not there? > > - Simon > > > On Apr 12, 2019, at 10:44 AM, Bert Gunter <bgunter.4567 at gmail.com> > wrote: > > > > ?fitted > > ?predict > > ## This is what one usually does, but I have not checked pglm. > > > > You also need to get friendly with ?str > > > > ... and probably also spend time with an R tutorial or two to become > familiar with R modeling conventions. > > > > Bert Gunter > > > > "The trouble with having an open mind is that people keep coming along > and sticking things into it." > > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > > > > On Fri, Apr 12, 2019 at 7:35 AM Simon Berrebi <simon at berrebi.net > <mailto:simon at berrebi.net>> wrote: > > Hello everyone, > > > > I am using the pglm function in R to fit a Poisson fixed-effects model. > According to the documentation < > https://cran.r-project.org/web/packages/pglm/pglm.pdf < > https://cran.r-project.org/web/packages/pglm/pglm.pdf>>, the pglm object > should have fitted.values. However, fitted.values(mymodel) returns "NULL". > > > > When I run AIC(mymodel) the AIC is followed by "attr(,"fitted.values")" > and a long list of number. I have included an example below and attached a > text file with the output. > > > > Are these fitted values? If so, is there a way to obtain them directly? > Can I also get fitted-values based on a synthetic dataset (i.e. predict())? > > > > install.packages("pglm") > > library(pglm) > > > > data("PatentsRDUS", package="pglm") > > > > > > mymodel <- pglm(patents ~ log(rd) + as.numeric(year)+ > I(log(capital72)*as.numeric(year)) , PatentsRDUS, > > family = poisson(link=log), model = "within", index = c("cusip", > "year")) > > > > fitted.values(mymodel) > > AIC(mymodel) > > > > Cordially, > > ? > > Dr. Simon J Berrebi > > Postdoctoral Fellow > > Civil and Environmental Engineering > > Georgia Institute of Technology > > > > > > > > > > > > > > > > > > ______________________________________________ > > R-help at r-project.org <mailto:R-help at r-project.org> mailing list -- To > UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help < > https://stat.ethz.ch/mailman/listinfo/r-help> > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html < > http://www.r-project.org/posting-guide.html> > > and provide commented, minimal, self-contained, reproducible code. > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. >[[alternative HTML version deleted]]
Thank you both for your responses! Bert - Are there specific tutorials you recommend on the subject? William - I first contacted the pglm maintainer before posting here (and also Stack Exchange <https://stats.stackexchange.com/questions/401741/are-fitted-values-available-in-pglm>). Haven?t heard back. - Simon> On Apr 12, 2019, at 2:44 PM, William Dunlap <wdunlap at tibco.com> wrote: > > You should ask the maintainer of the package about this: bug.report(package="pglm") or maintainer("pglm") should give you contact information. > > The help file for pglm seems all wrong - it says pglm's output has class "pglm" with components like "fitted.values", but the the example calls to pglm return things of class c("maxLik", "maxim", "list"). > > Bill Dunlap > TIBCO Software > wdunlap tibco.com <http://tibco.com/> > > On Fri, Apr 12, 2019 at 11:09 AM Simon Berrebi <simon at berrebi.net <mailto:simon at berrebi.net>> wrote: > Thank you Bert, > > I wasn?t aware of ?str. The only mention of fitted-values is: > > $ maximum : atomic [1:1] -9824 > ..- attr(*, "fitted.values")= num [1:3460] 1.39 1.3 1.3 1.32 1.27 ... > > When I try attr(mymodel$maximum, ?fitted.values?), I get the same results as attr(AIC(mymodel), ?fitted.values?), which is a list of number starting with (1.39 1.3 1.3 1.32 1.27 ?). I don?t see how these can be fitted values for the response variable, patents, which are larger numbers (30, 3, 48, 1, 2, 32, ?). Is this output not supped to represent the fitted values for patents? > > Another way to obtain fitted values would be using residuals.?pglm also includes residuals in its list of elements. However, str(mymodel) does not mention residuals. Does that mean it?s just not there? > > - Simon > > > On Apr 12, 2019, at 10:44 AM, Bert Gunter <bgunter.4567 at gmail.com <mailto:bgunter.4567 at gmail.com>> wrote: > > > > ?fitted > > ?predict > > ## This is what one usually does, but I have not checked pglm. > > > > You also need to get friendly with ?str > > > > ... and probably also spend time with an R tutorial or two to become familiar with R modeling conventions. > > > > Bert Gunter > > > > "The trouble with having an open mind is that people keep coming along and sticking things into it." > > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > > > > > On Fri, Apr 12, 2019 at 7:35 AM Simon Berrebi <simon at berrebi.net <mailto:simon at berrebi.net> <mailto:simon at berrebi.net <mailto:simon at berrebi.net>>> wrote: > > Hello everyone, > > > > I am using the pglm function in R to fit a Poisson fixed-effects model. According to the documentation <https://cran.r-project.org/web/packages/pglm/pglm.pdf <https://cran.r-project.org/web/packages/pglm/pglm.pdf> <https://cran.r-project.org/web/packages/pglm/pglm.pdf <https://cran.r-project.org/web/packages/pglm/pglm.pdf>>>, the pglm object should have fitted.values. However, fitted.values(mymodel) returns "NULL". > > > > When I run AIC(mymodel) the AIC is followed by "attr(,"fitted.values")" and a long list of number. I have included an example below and attached a text file with the output. > > > > Are these fitted values? If so, is there a way to obtain them directly? Can I also get fitted-values based on a synthetic dataset (i.e. predict())? > > > > install.packages("pglm") > > library(pglm) > > > > data("PatentsRDUS", package="pglm") > > > > > > mymodel <- pglm(patents ~ log(rd) + as.numeric(year)+ I(log(capital72)*as.numeric(year)) , PatentsRDUS, > > family = poisson(link=log), model = "within", index = c("cusip", "year")) > > > > fitted.values(mymodel) > > AIC(mymodel) > > > > Cordially, > > ? > > Dr. Simon J Berrebi > > Postdoctoral Fellow > > Civil and Environmental Engineering > > Georgia Institute of Technology > > > > > > > > > > > > > > > > > > ______________________________________________ > > R-help at r-project.org <mailto:R-help at r-project.org> <mailto:R-help at r-project.org <mailto:R-help at r-project.org>> mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help> <https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help>> > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html> <http://www.r-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html>> > > and provide commented, minimal, self-contained, reproducible code. > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org <mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help <https://stat.ethz.ch/mailman/listinfo/r-help> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code.[[alternative HTML version deleted]]