# Summary of sem: can I remove the summary of variables?

7 posts / 0 new
Offline
Joined: 12/08/2009 - 09:29
Summary of sem: can I remove the summary of variables?

Hi

I'm using openMx in a sweave file, where I show the output of a sem model. I wonder if it is possible to show only the bottom of what is printed by summary, i.e., only the coefficients table and the index, not the individual summary, whihc is pretty long?

Is this possible?

As second question: how do I see the code for summary? I'm not quite comfortable with S4 modelling, in S3 I would have done:
getAnywhere(summary.MxRAMModel)

How do I do with S4?

Thanks a lot!

Offline
Joined: 07/30/2009 - 14:03
Good point. We need to do

Good point. We need to do some work on the summary call. Currently it prints whether or not you are assigning the summary to variable. We should suppress printing when the summary is being assigned to an R variable or if only a part of it is being extracted.

For instance,

summary(myModel)$parameters  should just print the parameters, but instead prints the whole summary. That one goes on the bug list. Offline Joined: 07/31/2009 - 15:24 Umm, actually this is not a Umm, actually this is not a bug. The recommended implementation of summary() is to return its value using the invisible() function. In other words, what is printed to the console is independent of the value that is returned. In addition, the console output of summary() should not be context-sensitive. In order to silence the output of summary(), use the following: null <- tryCatch(suppressWarnings(file('/dev/null', 'w')), error = function(e) { file('nul', 'w') } ) sink(null, type = 'output') summary(foo) sink(type = 'output')  WRT your other question, you can either use selectMethod(summary, list("MxModel")) or look at the source code here: http://openmx.psyc.virginia.edu/repoview/1/trunk/R/MxSummary.R. Offline Joined: 07/30/2009 - 14:03 Not sure which Not sure which recommendations you are reading, but here's the behavior that people expect to see: > x<-rnorm(100,0,1) > tData <- data.frame(x=x,y=0.5*x+rnorm(100,0,1)) > tLMout <- lm(y~x,data=tData) > summary(tLMout) Call: lm(formula = y ~ x, data = tData) Residuals: Min 1Q Median 3Q Max -2.47965 -0.63571 0.03767 0.66997 1.96593 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) -0.03222 0.09146 -0.352 0.725 x 0.45711 0.09205 4.966 2.89e-06 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.9126 on 98 degrees of freedom Multiple R-squared: 0.2011, Adjusted R-squared: 0.1929 F-statistic: 24.66 on 1 and 98 DF, p-value: 2.89e-06 > tLMsummary <- summary(tLMout) > summary(tLMout)$coef
Estimate Std. Error    t value     Pr(>|t|)
(Intercept) -0.03221798 0.09146109 -0.3522588 7.254006e-01
x            0.45711266 0.09204594  4.9661359 2.890150e-06
>


Note that when summary is assigned it is silenced and when a part of the summary's list is extracted only that part is printed. This is the behavior of summary for all of the estimation functions of which I'm aware.

Offline
Joined: 07/31/2009 - 15:24
Ah ok. It looks like we both

Ah ok. It looks like we both had correct information, but only partial information. is.object(tLMsummary) returns TRUE and isS4(tLMsummary) returns FALSE. I'm going to make the assumption that summary(tLMout) returns a S3 object. The S3 class of the object is summary.lm and that's why there exists a print.summary.lm method. Sorry, I was wrong. It looks like we need to create a summary object for MxModel objects. We can create S3 or S4 objects. I am inclined to create S3 objects so that we mimic the behavior of lm. But I can see an argument to make a S4 object.

Offline
Joined: 07/31/2009 - 15:24
Yes, if we create S3 objects

Yes, if we create S3 objects then they have an identical interface to plain lists, which is how summary.lm objects behave. The user expects to use '$' to access elements of the summary, instead of '@' for S4 objects. (Of course we could always override the '$' operator for our S4 summary object, but this seems convoluted).

Offline
Joined: 07/31/2009 - 15:24
OK the summary() function has

OK the summary() function has been changed to behave like the summary() function in the stats package. The change can be found in the source code repository before the next binary release comes out. See the howto for building from the source code repository: http://openmx.psyc.virginia.edu/wiki/howto-build-openmx-source-repository
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.19813832640647888, "perplexity": 1720.6284908400462}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2018-05/segments/1516084891791.95/warc/CC-MAIN-20180123072105-20180123092105-00040.warc.gz"}