On Fri, 14 Feb 2003 16:37:42 +1100 [EMAIL PROTECTED] wrote: > This is my first post to this list so I suppose a quick intro is in > order. I've been using SPLUS 2000 and R1.6.2 for just a couple of days, > and love S already. I'm reading MASS and also John Fox's book - both have > been very useful. My background in stat software was mainly SPSS (which > I've never much liked - thanks heavens I've found S!), and Perl is my > tool of choice for general-purpose programming (I chaired the > perl6-language-data working group, responsible for improving the data > analysis capabilities in Perl). > > I have just completed my first S project, and I now have 8 lm.objects. > The models are all reasonably complex with multiple numeric and factor > variables and some 2-way and 3-way interactions. I now need to use these > models in other environments, such as C code, SQL functions (using CASE) > and in Perl - I can not work out how to do this. > > The difficulty I am having is that the output of coef() is not really > parsable, since there is no marker in the name of an coefficient of > separate out the components. For instance, in SPSS the name of a > coefficient might be: > > var1=[a]*var2=[b]*var3 > > ...which is easy to write a little script to pull that apart and turn it > into a line of SQL, C, or whatever. In S however the name looks like: > > var1avar2bvar3 > > ...which provides no way to pull the bits apart. > > So my question is, how do I export an lm.object in some form that I can > then apply to prediction in C, SQL, or some other language? All I'm > looking for is some well-structured textual or data frame output that I > can then manipulate with appropriate tools, whether it be S itself, or > something like Perl. > > Thanks in advance for any suggestions (and apologies in advance if this > is well documented somewhere!), > > Jeremy >
Some functions that may give you some ideas, from the Design library (http://hesweb1.med.virginia.edu/biostat/s/Design.html).: Function(fit): generate S function to obtain predicted values from a regression fit that was done with Design in effect (i.e., fit with ols, cph, lrm, psm, glmD) latex(fit): generate LaTeX code for typesetting the model fit sascode(Function(fit)): translate formula to SAS notation What I think would be very useful would be a function like Function that instead symbolically creates the design matrix, and translating that function to SQL etc. This would allow computation of confidence limits. -- Frank E Harrell Jr Prof. of Biostatistics & Statistics Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat ______________________________________________ [EMAIL PROTECTED] mailing list http://www.stat.math.ethz.ch/mailman/listinfo/r-help
